Frustum

Description

abstract class Tinman.Terrain.Meshing.Frustum

Extended by

DefaultFrustum
HullFrustum sealed

Represents a frustum in terrain-space.

Each plane of a frustum establishes two half-spaces: the inside and the outside. The intersection of all inside half-spaces defines the interior of the frustum. Usually, the frustum is a convex polyhedron with a finite volume. However, a frustum may also be open and thus have an infinite volume.

Public / Methods

Clip​Line​Segment


[Pure]
public method ClipLineSegment → (2)

ref : Vec3D

First point of line segment.

ref : Vec3D

Second point of line segment.

returns → int32

-1 if the line segment lies entirely outside of the frustum.
0 if the line segment lies entirely inside of the frustum.
1 if ref has been updated to represent the clipped line segment.
2 if ref has been updated to represent the clipped line segment.
3 if ref and ref have been updated to represent the clipped line segment.

Clips the given line segment with this frustum.

Plane​At


[Pure]
public method PlaneAt → (1)

index in : int32

[0..Frustum.PlaneCount-1]
The frustum plane index.

returns → Plane

The frustum plane.

Returns the index in-th frustum plane.

Test​Cuboid


[Pure]
public method TestCuboid → (2)

cuboid in : Cuboid

The cuboid.

insideMask opt : int32 = 0

A bitmask indicating for which planes the cuboid is already known to lie completely inside the planes inner half-space: for plane n within [0..PlaneCount-1], the corresponding bit is 2^n.

returns → int32

The resulting inside mask (with 0x7FFFFFFF indicating that the cuboid fully lies inside the frustum), -1 if the cuboid lies outside the frustum. Any other value indicates that the cuboid intersects with at least one frustum plane.

Tests if the given cuboid lies inside the frustum.

The current implementation only tests the corner vertices of the cuboid against each frustum plane, which will not detect the case when a cuboid face intersects with the frustum while all its vertices are outside.

Test​Extruded​Sphere


[Pure]
public method TestExtrudedSphere → (4)

center in : Vec3D

Coordinates of sphere center.

radius in : float64

Radius of sphere.

extrusion in : Vec3D

The vector along which to extrude the sphere.

insideMask opt : int32 = 0

A bitmask indicating for which planes the sphere is already known to lie completely inside the planes inner half-space: for plane n within [0..PlaneCount-1], the corresponding bit is 2^n.

returns → int32

The resulting inside mask (with 0x7FFFFFFF indicating that the sphere fully lies inside the frustum), -1 if the sphere lies outside the frustum. Any other value indicates that the sphere intersects with at least one frustum plane.

Tests if the given extruded sphere lies inside the frustum.

Test​Sphere

2 overloads


[Pure]
public method TestSphere1 → (2)

sphere in : Sphere

The sphere.

insideMask opt : int32 = 0

A bitmask indicating for which planes the sphere is already known to lie completely inside the planes inner half-space: for plane n within [0..PlaneCount-1], the corresponding bit is 2^n.

returns → int32

The resulting inside mask (with 0x7FFFFFFF indicating that the sphere fully lies inside the frustum), -1 if the sphere lies outside the frustum. Any other value indicates that the sphere intersects with at least one frustum plane.

Tests if the given sphere lies inside the frustum.


[Pure]
public method TestSphere2 → (3)

center in : Vec3D

Coordinates of sphere center.

radius in : float64

Radius of sphere.

insideMask opt : int32 = 0

A bitmask indicating for which planes the sphere is already known to lie completely inside the planes inner half-space: for plane n within [0..PlaneCount-1], the corresponding bit is 2^n.

returns → int32

The resulting inside mask (with 0x7FFFFFFF indicating that the sphere fully lies inside the frustum), -1 if the sphere lies outside the frustum. Any other value indicates that the sphere intersects with at least one frustum plane.

Tests if the given sphere lies inside the frustum.

Public / Attributes

Plane​Count


public attribute PlaneCount → (get)

value : int32

[0..31]
The number of frustum planes.

The number of frustum planes.

If a frustum has a plane count of zero, it contains all space.

Protected / Constructors

Frustum


protected constructor Frustum → (1)

planeCount in : int32

[0..31]
The number of frustum planes.

Creates a new frustum.

Protected / Attributes

plane​Count


protected attribute planeCount → (int32)

Number of frustum planes.

planes


protected readonly attribute planes → (Plane [ ])

The frustum planes.