Skip to content

Frustum

Represents a view frustum defined by six clipping planes.

Frustum encodes the camera’s visible volume using six inward-facing planes: left, right, top, bottom, near, and far. It is typically constructed from a combined view–projection matrix and used by the renderer for view frustum culling.

The class provides containment and intersection tests against points, axis-aligned bounding boxes, and bounding spheres. All checks assume that plane normals point into the frustum interior.

Construction

Constructors


Frustum() constexpr

Constructs a frustum from a view–projection matrix.

cpp
Frustum::Frustum(const Matrix4& view_proj);
ParameterDescription
view_projView–projection matrix.

Functions

ContainsPoint() bool

Checks whether a point lies inside the frustum.

cpp
bool Frustum::ContainsPoint(const Vector3& point) const;
ParameterDescription
pointWorld-space position to test.

IntersectsWithBox3() bool

Checks whether an axis-aligned bounding box intersects the frustum.

Uses a fast AABB–frustum test based on plane normals to reject boxes that lie completely outside the view volume.

cpp
bool Frustum::IntersectsWithBox3(const Box3& box) const;
ParameterDescription
boxBox to test.

IntersectsWithSphere() bool

Checks whether a sphere intersects the frustum.

cpp
bool Frustum::IntersectsWithSphere(const Sphere& sphere) const;
ParameterDescription
sphereBounding sphere to test.

SetWithViewProjection() void

Updates the frustum from a view–projection matrix.

Extracts the six planes from the matrix and normalizes them.

cpp
void Frustum::SetWithViewProjection(const Matrix4& view_proj);
ParameterDescription
view_projView–projection matrix.

Released under the MIT License.