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

Shape that combines multiple colliders. More...

#include <GREM/physics/Shape.hpp>

Public Member Functions

GREM_ALWAYS_INLINE CompoundColliderShape (SharedPointer< SubCollider< N >[]> subColliders) noexcept
 Construct a compound collider shape from a set of colliders.
 CompoundColliderShape (Span< const SubCollider< N > > subColliders)
 Construct a compound shape from a set of colliders.
GREM_ALWAYS_INLINE Span< const SubCollider< N > > getSubColliders () const noexcept
 Get the underlying set of colliders of this compound collider shape.
Volume calculateVolume () const
 Calculate an estimate of the volume of the shape.
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia (Mass mass) const
 Calculate an estimate of the local moment of inertia of the shape given a certain mass.
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox (const Transformation< N > &transformation) const
 Get the axis-aligned bounding box of the shape given its position and orientation in the world.
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius (const Basis< N > &basis) const
 Get the radius of the bounding sphere of the shape.
Optional< Area > getReferenceArea (const Basis< N > &basis, Direction< N > direction) const
 Get an estimate of the reference area of the shape for a certain direction, typically calculated as the area of the largest cross section orthogonal to the given direction.
RaycastResult< N > castLocalRay (Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
 Find the closest intersection of this shape with a given ray in local space.

Detailed Description

template<size_t N>
class grem::physics::CompoundColliderShape< N >

Shape that combines multiple colliders.

Template Parameters
Nnumber of dimensions of the world space (must be 2 or 3).

Constructor & Destructor Documentation

◆ CompoundColliderShape() [1/2]

template<size_t N>
GREM_ALWAYS_INLINE grem::physics::CompoundColliderShape< N >::CompoundColliderShape ( SharedPointer< SubCollider< N >[]> subColliders)
inlineexplicitnoexcept

Construct a compound collider shape from a set of colliders.

Parameters
subCollidersshared pointer to the colliders. Must not be nullptr.

◆ CompoundColliderShape() [2/2]

template<size_t N>
grem::physics::CompoundColliderShape< N >::CompoundColliderShape ( Span< const SubCollider< N > > subColliders)
explicit

Construct a compound shape from a set of colliders.

Parameters
subColliderscolliders to construct the compound shape from.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

Member Function Documentation

◆ getSubColliders()

template<size_t N>
GREM_ALWAYS_INLINE Span< const SubCollider< N > > grem::physics::CompoundColliderShape< N >::getSubColliders ( ) const
inlinenodiscardnoexcept

Get the underlying set of colliders of this compound collider shape.

Returns
a read-only view over the underlying colliders.

◆ calculateVolume()

template<size_t N>
Volume grem::physics::CompoundColliderShape< N >::calculateVolume ( ) const
nodiscard

Calculate an estimate of the volume of the shape.

Returns
the estimated volume of the shape.

◆ calculatePrincipalMomentsOfInertia()

template<size_t N>
PrincipalMomentsOfInertia< N > grem::physics::CompoundColliderShape< N >::calculatePrincipalMomentsOfInertia ( Mass mass) const
nodiscard

Calculate an estimate of the local moment of inertia of the shape given a certain mass.

Parameters
massassumed mass of the shape.
Returns
the estimated moment of inertia in shape-local space.

◆ getBoundingBox()

template<size_t N>
GREM_ALWAYS_INLINE Optional< Box< N > > grem::physics::CompoundColliderShape< N >::getBoundingBox ( const Transformation< N > & transformation) const
inlinenodiscard

Get the axis-aligned bounding box of the shape given its position and orientation in the world.

Parameters
transformationtransformation of the shape in world space.
Returns
an axis-aligned bounding box in world space that would contain the entire shape if the shape was at the given position and orientation in the world, or an empty optional if the shape extends infinitely and cannot be fit inside a finite box.

◆ getBoundingRadius()

template<size_t N>
GREM_ALWAYS_INLINE Optional< Distance > grem::physics::CompoundColliderShape< N >::getBoundingRadius ( const Basis< N > & basis) const
inlinenodiscard

Get the radius of the bounding sphere of the shape.

Parameters
basistransformation basis of the shape in world space.
Returns
the maximum distance from the origin of any point on the shape, or an empty optional if the shape extends infinitely and cannot be fit inside a finite sphere.

◆ getReferenceArea()

template<size_t N>
Optional< Area > grem::physics::CompoundColliderShape< N >::getReferenceArea ( const Basis< N > & basis,
Direction< N > direction ) const
nodiscard

Get an estimate of the reference area of the shape for a certain direction, typically calculated as the area of the largest cross section orthogonal to the given direction.

Parameters
basistransformation basis of the shape in world space.
directiondirection to get the reference area for.
Returns
the reference area, or an empty optional if an area cannot be determined, e.g. because the shape is infinite.

◆ castLocalRay()

template<size_t N>
RaycastResult< N > grem::physics::CompoundColliderShape< N >::castLocalRay ( Length< N > localRayOrigin,
Direction< N > localRayDirection,
Distance maxLocalRayDistance ) const
nodiscard

Find the closest intersection of this shape with a given ray in local space.

Parameters
localRayOriginoffset of the ray origin in shape-local space.
localRayDirectionunit direction vector of the ray in shape-local space. Must be a unit vector.
maxLocalRayDistancemaximum hit distance of the ray in shape-local space. Must be non-negative.
Returns
the result of the raycast.

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