GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::Frustum< T > Struct Template Reference

Truncated pyramid shape in 3D space. More...

#include <GREM/core/geometry.hpp>

Public Types

using Component = T
 Scalar coordinate component type.

Public Member Functions

template<typename U>
GREM_ALWAYS_INLINE constexpr operator Frustum< U > () const noexcept
 Convert this frustum to an equivalent frustum of another scalar type.
constexpr bool isPotentiallyIntersecting (const Box< 3, T > &aabb) const noexcept
 Check if an axis-aligned bounding box is potentially intersecting with the frustum.
constexpr bool isPotentiallyIntersecting (const Sphere< 3, T > &sphere) const noexcept
 Check if a sphere is potentially intersecting with the frustum.

Static Public Member Functions

static constexpr Frustum fromViewProjectionMatrix (const mat< 4, 4, T > &viewProjectionMatrix) noexcept
 Create a world-space view frustum from a combined view-projection matrix.
static constexpr Frustum fromCorners (StridedSpan< const Point< 3, T >, 8 > corners)
 Create a frustum from its corners.

Public Attributes

Array< vec< 4, T >, 6 > planes
 Plane equation coefficients of the 6 planes of the frustum, pointing inwards, in the following order:
Array< Point< 3, T >, 8 > corners
 Positions of the 8 corners of the frustum, in the following order:

Static Public Attributes

static constexpr size_t RANK = 3
 Number of dimensions of the vector space.

Detailed Description

template<typename T>
struct grem::Frustum< T >

Truncated pyramid shape in 3D space.

Template Parameters
Tscalar coordinate component type.

Member Typedef Documentation

◆ Component

template<typename T>
using grem::Frustum< T >::Component = T

Scalar coordinate component type.

Member Function Documentation

◆ fromViewProjectionMatrix()

template<typename T>
constexpr Frustum grem::Frustum< T >::fromViewProjectionMatrix ( const mat< 4, 4, T > & viewProjectionMatrix)
inlinestaticconstexprnoexcept

Create a world-space view frustum from a combined view-projection matrix.

Parameters
viewProjectionMatrixcombined view-projection matrix to create the frustum from.
Returns
the newly created frustum.

◆ fromCorners()

template<typename T>
constexpr Frustum grem::Frustum< T >::fromCorners ( StridedSpan< const Point< 3, T >, 8 > corners)
inlinestaticnodiscardconstexpr

Create a frustum from its corners.

Parameters
cornerspositions of the 8 corners of the frustum, in the following order:
  • [0]: Far bottom left
  • [1]: Far top left
  • [2]: Far bottom right
  • [3]: Far top right
  • [4]: Near bottom left
  • [5]: Near top left
  • [6]: Near bottom right
  • [7]: Near top right
Returns
the newly created frustum.
Note
If the given corners are not in the correct order, the result is unspecified.

◆ operator Frustum< U >()

template<typename T>
template<typename U>
GREM_ALWAYS_INLINE constexpr grem::Frustum< T >::operator Frustum< U > ( ) const
inlineexplicitconstexprnoexcept

Convert this frustum to an equivalent frustum of another scalar type.

Returns
the converted frustum.

◆ isPotentiallyIntersecting() [1/2]

template<typename T>
bool grem::Frustum< T >::isPotentiallyIntersecting ( const Box< 3, T > & aabb) const
inlinenodiscardconstexprnoexcept

Check if an axis-aligned bounding box is potentially intersecting with the frustum.

Parameters
aabbaxis-aligned bounding box to check.
Returns
true if the box may potentially be intersecting with the frustum, false if it is definitely not intersecting.

◆ isPotentiallyIntersecting() [2/2]

template<typename T>
bool grem::Frustum< T >::isPotentiallyIntersecting ( const Sphere< 3, T > & sphere) const
inlinenodiscardconstexprnoexcept

Check if a sphere is potentially intersecting with the frustum.

Parameters
spheresphere to check.
Returns
true if the sphere may potentially be intersecting with the frustum, false if it is definitely not intersecting.

Member Data Documentation

◆ RANK

template<typename T>
size_t grem::Frustum< T >::RANK = 3
staticconstexpr

Number of dimensions of the vector space.

◆ planes

template<typename T>
Array<vec<4, T>, 6> grem::Frustum< T >::planes

Plane equation coefficients of the 6 planes of the frustum, pointing inwards, in the following order:

  • [0]: Left
  • [1]: Right
  • [2]: Bottom
  • [3]: Top
  • [4]: Far
  • [5]: Near

◆ corners

template<typename T>
Array<Point<3, T>, 8> grem::Frustum< T >::corners

Positions of the 8 corners of the frustum, in the following order:

  • [0]: Far bottom left
  • [1]: Far top left
  • [2]: Far bottom right
  • [3]: Far top right
  • [4]: Near bottom left
  • [5]: Near top left
  • [6]: Near bottom right
  • [7]: Near top right

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