Unravel Engine C++ Reference
Loading...
Searching...
No Matches
math::frustum Class Reference

Storage for frustum planes / values and wraps up common functionality. More...

#include <frustum.h>

Public Member Functions

 frustum ()
 Default constructor.
 
 frustum (const transform &view, const transform &proj, bool homogeneousDepth)
 Constructs a frustum from view and projection matrices.
 
 frustum (const bbox &sourceBounds)
 Constructs a frustum from an axis-aligned bounding box.
 
void update (const transform &view, const transform &proj, bool _oglNDC)
 Updates the frustum based on the specified view and projection matrices.
 
void set_planes (const std::array< plane, 6 > &new_planes)
 Sets the frustum planes.
 
void recompute_points ()
 Recomputes the frustum's corner points based on its planes.
 
auto classify_vertices (const vec3 *vertices, size_t count) const -> volume_query
 Classifies vertices with respect to the frustum.
 
auto classify_aabb (const bbox &bounds) const -> volume_query
 Classifies an axis-aligned bounding box (AABB) with respect to the frustum.
 
auto classify_aabb (const bbox &bounds, unsigned int &frustumBits, int &lastOutside) const -> volume_query
 Classifies an axis-aligned bounding box (AABB) with respect to the frustum.
 
auto classify_obb (const bbox &bounds, const transform &t) const -> volume_query
 Classifies an oriented bounding box (OBB) with respect to the frustum.
 
auto classify_sphere (const bsphere &sphere) const -> volume_query
 Classifies a sphere with respect to the frustum.
 
auto classify_plane (const plane &plane) const -> volume_query
 Classifies a plane with respect to the frustum.
 
auto test_vertices (const vec3 *vertices, size_t count) const -> bool
 Tests if vertices are inside or intersect the frustum.
 
auto test_point (const vec3 &point) const -> bool
 Tests if a point is inside or intersecting the frustum.
 
auto test_aabb (const bbox &bounds) const -> bool
 Tests if an axis-aligned bounding box (AABB) is inside or intersecting the frustum.
 
auto test_obb (const bbox &bounds, const transform &t) const -> bool
 Tests if an oriented bounding box (OBB) is inside or intersecting the frustum.
 
auto test_sphere (const bsphere &sphere) const -> bool
 Tests if a sphere is inside or intersecting the frustum.
 
auto test_sphere (const bsphere &sphere, const transform &t) const -> bool
 Tests if a transformed sphere is inside or intersecting the frustum.
 
auto test_swept_sphere (const bsphere &sphere, const vec3 &sweepDirection) const -> bool
 Determine whether or not the specified sphere, swept along the provided direction vector, intersects the frustum in some way.
 
auto test_frustum (const frustum &frustum) const -> bool
 Tests if another frustum intersects this frustum.
 
auto test_line (const vec3 &v1, const vec3 &v2) const -> bool
 Tests if a line intersects the frustum.
 
auto mul (const transform &t) -> frustum &
 Multiplies the frustum by a transform.
 
auto operator== (const frustum &f) const -> bool
 Equality operator.
 

Public Attributes

std::array< plane, 6 > planes
 < The 6 planes of the frustum.
 
std::array< vec3, 8 > points
 The originating position of the frustum.
 
vec3 position = {0.0f, 0.0f, 0.0f}
 
float near_distance_ {}
 
float far_distance_ {}
 

Detailed Description

Storage for frustum planes / values and wraps up common functionality.

Definition at line 17 of file frustum.h.

Constructor & Destructor Documentation

◆ frustum() [1/3]

math::frustum::frustum ( )

Default constructor.

Definition at line 29 of file frustum.cpp.

◆ frustum() [2/3]

math::frustum::frustum ( const transform & view,
const transform & proj,
bool homogeneousDepth )

Constructs a frustum from view and projection matrices.

Parameters
viewThe view transform.
projThe projection transform.
homogeneousDepthTrue when NDC depth is in [-1, 1] range, otherwise its [0, 1].

Definition at line 37 of file frustum.cpp.

◆ frustum() [3/3]

math::frustum::frustum ( const bbox & sourceBounds)

Constructs a frustum from an axis-aligned bounding box.

Parameters
sourceBoundsThe bounding box to construct the frustum from.

Definition at line 42 of file frustum.cpp.

Member Function Documentation

◆ classify_aabb() [1/2]

auto math::frustum::classify_aabb ( const bbox & bounds) const -> volume_query

Classifies an axis-aligned bounding box (AABB) with respect to the frustum.

Parameters
boundsThe bounding box to classify.
Returns
The classification result.

Definition at line 227 of file frustum.cpp.

◆ classify_aabb() [2/2]

auto math::frustum::classify_aabb ( const bbox & bounds,
unsigned int & frustumBits,
int & lastOutside ) const -> volume_query

Classifies an axis-aligned bounding box (AABB) with respect to the frustum.

Parameters
boundsThe bounding box to classify.
frustumBitsBits representing the frustum planes.
lastOutsideIndex of the last outside plane.
Returns
The classification result.

Definition at line 263 of file frustum.cpp.

◆ classify_obb()

auto math::frustum::classify_obb ( const bbox & bounds,
const transform & t ) const -> volume_query

Classifies an oriented bounding box (OBB) with respect to the frustum.

Parameters
boundsThe bounding box to classify.
tThe transform to apply to the bounding box.
Returns
The classification result.

Definition at line 257 of file frustum.cpp.

◆ classify_plane()

auto math::frustum::classify_plane ( const plane & plane) const -> volume_query

Classifies a plane with respect to the frustum.

Parameters
planeThe plane to classify.
Returns
The classification result.

Definition at line 581 of file frustum.cpp.

◆ classify_sphere()

auto math::frustum::classify_sphere ( const bsphere & sphere) const -> volume_query

Classifies a sphere with respect to the frustum.

Parameters
sphereThe sphere to classify.
Returns
The classification result.

Definition at line 390 of file frustum.cpp.

◆ classify_vertices()

auto math::frustum::classify_vertices ( const vec3 * vertices,
size_t count ) const -> volume_query

Classifies vertices with respect to the frustum.

Parameters
verticesThe vertices to classify.
countThe number of vertices.
Returns
The classification result.

Definition at line 184 of file frustum.cpp.

◆ mul()

auto math::frustum::mul ( const transform & t) -> frustum&

Multiplies the frustum by a transform.

Parameters
tThe transform to multiply by.
Returns
A reference to the multiplied frustum.

Definition at line 687 of file frustum.cpp.

◆ operator==()

auto math::frustum::operator== ( const frustum & f) const -> bool

Equality operator.

Parameters
fThe frustum to compare with.
Returns
True if the frustums are equal, false otherwise.

Definition at line 710 of file frustum.cpp.

◆ recompute_points()

void math::frustum::recompute_points ( )

Recomputes the frustum's corner points based on its planes.

Definition at line 153 of file frustum.cpp.

◆ set_planes()

void math::frustum::set_planes ( const std::array< plane, 6 > & new_planes)

Sets the frustum planes.

Parameters
new_planesThe new planes to set.

Definition at line 140 of file frustum.cpp.

◆ test_aabb()

auto math::frustum::test_aabb ( const bbox & bounds) const -> bool

Tests if an axis-aligned bounding box (AABB) is inside or intersecting the frustum.

Parameters
boundsThe bounding box to test.
Returns
True if the bounding box is inside or intersecting the frustum, false otherwise.

Definition at line 334 of file frustum.cpp.

◆ test_frustum()

auto math::frustum::test_frustum ( const frustum & frustum) const -> bool

Tests if another frustum intersects this frustum.

Parameters
frustumThe other frustum to test.
Returns
True if the frustums intersect, false otherwise.

Definition at line 617 of file frustum.cpp.

◆ test_line()

auto math::frustum::test_line ( const vec3 & v1,
const vec3 & v2 ) const -> bool

Tests if a line intersects the frustum.

Parameters
v1The start point of the line.
v2The end point of the line.
Returns
True if the line intersects the frustum, false otherwise.

Definition at line 526 of file frustum.cpp.

◆ test_obb()

auto math::frustum::test_obb ( const bbox & bounds,
const transform & t ) const -> bool

Tests if an oriented bounding box (OBB) is inside or intersecting the frustum.

Parameters
boundsThe bounding box to test.
tThe transform to apply to the bounding box.
Returns
True if the bounding box is inside or intersecting the frustum, false otherwise.

Definition at line 384 of file frustum.cpp.

◆ test_point()

auto math::frustum::test_point ( const vec3 & point) const -> bool

Tests if a point is inside or intersecting the frustum.

Parameters
pointThe point to test.
Returns
True if the point is inside or intersecting the frustum, false otherwise.

Definition at line 521 of file frustum.cpp.

◆ test_sphere() [1/2]

auto math::frustum::test_sphere ( const bsphere & sphere) const -> bool

Tests if a sphere is inside or intersecting the frustum.

Parameters
sphereThe sphere to test.
Returns
True if the sphere is inside or intersecting the frustum, false otherwise.

Definition at line 417 of file frustum.cpp.

◆ test_sphere() [2/2]

auto math::frustum::test_sphere ( const bsphere & sphere,
const transform & t ) const -> bool

Tests if a transformed sphere is inside or intersecting the frustum.

Parameters
sphereThe sphere to test.
tThe transform to apply to the sphere.
Returns
True if the transformed sphere is inside or intersecting the frustum, false otherwise.

Definition at line 436 of file frustum.cpp.

◆ test_swept_sphere()

auto math::frustum::test_swept_sphere ( const bsphere & sphere,
const vec3 & sweepDirection ) const -> bool

Determine whether or not the specified sphere, swept along the provided direction vector, intersects the frustum in some way.

Parameters
sphereThe sphere to test.
sweepDirectionThe direction to sweep the sphere.
Returns
True if the swept sphere intersects the frustum, false otherwise.

Definition at line 475 of file frustum.cpp.

◆ test_vertices()

auto math::frustum::test_vertices ( const vec3 * vertices,
size_t count ) const -> bool

Tests if vertices are inside or intersect the frustum.

Parameters
verticesThe vertices to test.
countThe number of vertices.
Returns
True if any vertex is inside or intersecting the frustum, false otherwise.

Definition at line 357 of file frustum.cpp.

◆ update()

void math::frustum::update ( const transform & view,
const transform & proj,
bool _oglNDC )

Updates the frustum based on the specified view and projection matrices.

Parameters
viewThe view transform.
projThe projection transform.
_oglNDCWhether the frustum uses OpenGL's NDC.

Definition at line 66 of file frustum.cpp.

Member Data Documentation

◆ far_distance_

float math::frustum::far_distance_ {}

Definition at line 233 of file frustum.h.

◆ near_distance_

float math::frustum::near_distance_ {}

Definition at line 232 of file frustum.h.

◆ planes

std::array<plane, 6> math::frustum::planes

< The 6 planes of the frustum.

The 8 corner points of the frustum.

Definition at line 226 of file frustum.h.

◆ points

std::array<vec3, 8> math::frustum::points

The originating position of the frustum.

Definition at line 228 of file frustum.h.

◆ position

vec3 math::frustum::position = {0.0f, 0.0f, 0.0f}

Definition at line 230 of file frustum.h.


The documentation for this class was generated from the following files: