Skip to content

Engine → Core → frustum.h

frustum

Syntax

struct CONJURE_API frustum

Variables

AccessNameTypeDefaultDescription
publicplanesstd::array<plane, FRUSTUM_PLANE_COUNT>{}

Functions

Public

contains

[[nodiscard]] bool contains(
    const aabb &box) const noexcept;

True when the box is entirely inside or touching all six planes (n-vertex test).

[[nodiscard]] bool contains(
    vec3 point) const noexcept;

True when the point is inside or on every plane.

corners

[[nodiscard]] static std::array<vec3, 8> corners(
    const mat4 &inverseViewProjection) noexcept;

The eight corners of the volume described by an inverse view-projection matrix, in the order near bottom-left, near bottom-right, near top-right, near top-left, then the same for the far plane. Requires a finite projection: an infinite projection has no finite far corners, so the call asserts once and leaves the affected corners at their undivided clip-space value. With a reverse-Z matrix the first four corners lie on the far plane and the last four on the near plane.

from_view_projection

[[nodiscard]] static frustum from_view_projection(
    const mat4 &viewProjection) noexcept;

Extracts the planes from a view-projection (or projection) matrix using the Gribb-Hartmann method for clip space -w <= x <= w, -w <= y <= w, 0 <= z <= w (GLM_FORCE_DEPTH_ZERO_TO_ONE). Works for perspective, infinite and orthographic projections; planes are normalised. With a reverse-Z matrix the planes still bound the same volume, but NEAR_PLANE and FAR_PLANE are swapped; renderer::frustum_from_clip corrects the labels.

get

[[nodiscard]] const plane &get(
    frustum_plane which) const noexcept;

The plane with the given index.

intersects

[[nodiscard]] bool intersects(
    const aabb &box) const noexcept;

Conservative box test using the p-vertex (the corner furthest along each plane normal): false only when the box is entirely behind at least one plane, so boxes near an edge may report an intersection they do not have. Invalid boxes never intersect.

intersects_sphere

[[nodiscard]] bool intersects_sphere(
    vec3 center,
    f32 radius) const noexcept;

True when the sphere is not entirely behind any plane (exact for the planes, so conservative near edges like intersects(aabb)). Negative radii are treated as 0.

Operator Overloads

Public

operator==

[[nodiscard]] bool operator==(
    const frustum &other) const = default;