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

Description of an axis-aligned box in world space. More...

#include <GREM/physics/Shape.hpp>

Public Types

using Unit = typename Position<N>::Unit
 Unit type.
using DimensionType = typename Unit::DimensionType
 Unit dimension type.
using MagnitudeType = typename Unit::MagnitudeType
 Unit magnitude type.

Public Member Functions

template<typename OtherUnitT>
requires (OtherUnitT::DIMENSION == LENGTH)
GREM_ALWAYS_INLINE constexpr grem::Box< N, Scalar > in (OtherUnitT unit) const noexcept
 Convert this physical box to a unitless box given a desired unit.
bool operator== (const Box &other) const =default
 Compare this box to another for equality.
GREM_ALWAYS_INLINE constexpr bool contains (const Position< N > &point) const noexcept
 Check if a given point is contained within the extents of this box.
GREM_ALWAYS_INLINE constexpr bool intersects (const Ray< N > &ray) const noexcept
 Check if this box intersects a given ray.
GREM_ALWAYS_INLINE constexpr RaycastResult< N > raycast (const Ray< N > &ray) const noexcept
 Find the closest intersection of this box with a given ray.
GREM_ALWAYS_INLINE constexpr Box< N > getBoundingBox () const noexcept
 Get the axis-aligned bounding box of the box.
GREM_ALWAYS_INLINE constexpr Box< N > getExpanded (Length< N > expansion) const noexcept
 Get a version of the box that is symmetrically expanded by a certain amount.
GREM_ALWAYS_INLINE constexpr Box< N > getExpanded (Distance expansion) const noexcept
 Get a version of the box that is symmetrically expanded by a certain amount.

Static Public Member Functions

template<typename T>
static GREM_ALWAYS_INLINE constexpr Box reinterpret (const grem::Box< N, T > &box) noexcept
 Reinterpret a unitless box as a physical box in default units.

Public Attributes

Position< N > min
 Position with the minimum coordinates of the box extents on each coordinate axis.
Position< N > max
 Position with the maximum coordinates of the box extents on each coordinate axis.

Static Public Attributes

static constexpr Unit UNIT {}
 Unit.
static constexpr DimensionType DIMENSION {}
 Unit dimension.
static constexpr MagnitudeType MAGNITUDE {}
 Unit magnitude.

Friends

GREM_ALWAYS_INLINE friend constexpr bool intersects (const Box &a, const Box &b) noexcept
 Check if two axis-aligned boxes intersect.

Detailed Description

template<size_t N>
struct grem::physics::Box< N >

Description of an axis-aligned box in world space.

Member Typedef Documentation

◆ Unit

template<size_t N>
using grem::physics::Box< N >::Unit = typename Position<N>::Unit

Unit type.

◆ DimensionType

template<size_t N>
using grem::physics::Box< N >::DimensionType = typename Unit::DimensionType

Unit dimension type.

◆ MagnitudeType

template<size_t N>
using grem::physics::Box< N >::MagnitudeType = typename Unit::MagnitudeType

Unit magnitude type.

Member Function Documentation

◆ reinterpret()

template<size_t N>
template<typename T>
GREM_ALWAYS_INLINE constexpr Box grem::physics::Box< N >::reinterpret ( const grem::Box< N, T > & box)
inlinestaticnodiscardconstexprnoexcept

Reinterpret a unitless box as a physical box in default units.

Parameters
boxbox to reinterpret.
Returns
the corresponding physical box.

◆ in()

template<size_t N>
template<typename OtherUnitT>
requires (OtherUnitT::DIMENSION == LENGTH)
GREM_ALWAYS_INLINE constexpr grem::Box< N, Scalar > grem::physics::Box< N >::in ( OtherUnitT unit) const
inlinenodiscardconstexprnoexcept

Convert this physical box to a unitless box given a desired unit.

Parameters
unitunit to get the box in.
Returns
the corresponding box in the given unit.

◆ operator==()

template<size_t N>
bool grem::physics::Box< N >::operator== ( const Box< N > & other) const
nodiscarddefault

Compare this box to another for equality.

Parameters
otherthe box to compare this box to.
Returns
true if the boxes are equal, false otherwise.

◆ contains()

template<size_t N>
GREM_ALWAYS_INLINE constexpr bool grem::physics::Box< N >::contains ( const Position< N > & point) const
inlinenodiscardconstexprnoexcept

Check if a given point is contained within the extents of this box.

Parameters
pointpoint to check.
Returns
true if the box contains the given point, false otherwise.

◆ intersects()

template<size_t N>
GREM_ALWAYS_INLINE constexpr bool grem::physics::Box< N >::intersects ( const Ray< N > & ray) const
inlinenodiscardconstexprnoexcept

Check if this box intersects a given ray.

Parameters
rayray to check.
Returns
true if an intersection was found, false otherwise.

◆ raycast()

template<size_t N>
GREM_ALWAYS_INLINE constexpr RaycastResult< N > grem::physics::Box< N >::raycast ( const Ray< N > & ray) const
inlinenodiscardconstexprnoexcept

Find the closest intersection of this box with a given ray.

Parameters
rayray to check.
Returns
the result of the raycast.

◆ getBoundingBox()

template<size_t N>
GREM_ALWAYS_INLINE constexpr Box< N > grem::physics::Box< N >::getBoundingBox ( ) const
inlinenodiscardconstexprnoexcept

Get the axis-aligned bounding box of the box.

Returns
an axis-aligned box that contains the entire box.

◆ getExpanded() [1/2]

template<size_t N>
GREM_ALWAYS_INLINE constexpr Box< N > grem::physics::Box< N >::getExpanded ( Length< N > expansion) const
inlinenodiscardconstexprnoexcept

Get a version of the box that is symmetrically expanded by a certain amount.

Parameters
expansiondistance to expand the box by along each axis. Each component must be non-negative.
Returns
the expanded box.

◆ getExpanded() [2/2]

template<size_t N>
GREM_ALWAYS_INLINE constexpr Box< N > grem::physics::Box< N >::getExpanded ( Distance expansion) const
inlinenodiscardconstexprnoexcept

Get a version of the box that is symmetrically expanded by a certain amount.

Parameters
expansiondistance to expand the box by along each axis. Must be non-negative.
Returns
the expanded box.

◆ intersects

template<size_t N>
GREM_ALWAYS_INLINE friend constexpr bool intersects ( const Box< N > & a,
const Box< N > & b )
friend

Check if two axis-aligned boxes intersect.

Parameters
afirst box.
bsecond box.
Returns
true if the first and second boxes are colliding with each other, false otherwise.

Member Data Documentation

◆ UNIT

template<size_t N>
Unit grem::physics::Box< N >::UNIT {}
staticconstexpr

Unit.

◆ DIMENSION

template<size_t N>
DimensionType grem::physics::Box< N >::DIMENSION {}
staticconstexpr

Unit dimension.

◆ MAGNITUDE

template<size_t N>
MagnitudeType grem::physics::Box< N >::MAGNITUDE {}
staticconstexpr

Unit magnitude.

◆ min

template<size_t N>
Position<N> grem::physics::Box< N >::min

Position with the minimum coordinates of the box extents on each coordinate axis.

◆ max

template<size_t N>
Position<N> grem::physics::Box< N >::max

Position with the maximum coordinates of the box extents on each coordinate axis.


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