Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Crux::Frustum Struct Reference

View frustum represented as six half-space planes. More...

#include <BoundingVolumes.h>

Public Types

enum  PlaneIndex : u8 {
  Left = 0 , Right = 1 , Bottom = 2 , Top = 3 ,
  Near = 4 , Far = 5
}

Public Member Functions

bool CullsSphere (const BoundingSphere &sphere) const
 Tests whether a sphere is fully outside the frustum.
bool CullsAABB (const AABB &aabb) const
 Tests whether an AABB is fully outside the frustum.
bool ContainsPoint (const vec3 &point) const
 Tests whether a point lies inside all six frustum planes.

Static Public Member Functions

static Frustum FromViewProjection (const mat4 &vp)
 Extracts the six frustum planes from a combined view-projection matrix.

Public Attributes

vec4 Planes [6]

Detailed Description

View frustum represented as six half-space planes.

Each plane is stored as a vec4(normal.x, normal.y, normal.z, d) where a point P satisfies the plane if dot(P, normal) + d > 0.

Member Enumeration Documentation

◆ PlaneIndex

Enumerator
Left 
Right 
Bottom 
Top 
Near 
Far 

Member Function Documentation

◆ ContainsPoint()

bool Crux::Frustum::ContainsPoint ( const vec3 & point) const
inline

Tests whether a point lies inside all six frustum planes.

Parameters
pointThe point to test.
Returns
True if the point is inside the frustum.

◆ CullsAABB()

bool Crux::Frustum::CullsAABB ( const AABB & aabb) const
inline

Tests whether an AABB is fully outside the frustum.

Uses the p-vertex test: for each plane, the corner of the box most aligned with the plane normal is tested. If that corner is behind the plane, the entire box is outside.

Parameters
aabbThe bounding box to test.
Returns
True if the AABB should be culled (lies fully outside the frustum).

◆ CullsSphere()

bool Crux::Frustum::CullsSphere ( const BoundingSphere & sphere) const
inline

Tests whether a sphere is fully outside the frustum.

A sphere is culled when its center is more than one radius behind any single plane.

Parameters
sphereThe bounding sphere to test.
Returns
True if the sphere should be culled (lies fully outside the frustum).

◆ FromViewProjection()

Frustum Crux::Frustum::FromViewProjection ( const mat4 & vp)
inlinestatic

Extracts the six frustum planes from a combined view-projection matrix.

Uses the Gribb-Hartmann method. Works for both perspective and orthographic projections. Planes are normalized so distances are in world-space units.

Parameters
vpRow-major view-projection matrix.
Returns
A Frustum whose planes correspond to the six sides of the view volume.

Member Data Documentation

◆ Planes

vec4 Crux::Frustum::Planes[6]

The documentation for this struct was generated from the following file: