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

View of a generic convex shape. More...

#include <GREM/physics/Shape.hpp>

Inheritance diagram for grem::physics::ConvexShapeView< N >:

Public Member Functions

template<typename T>
requires (same_as<T, Shape<N>>)
GREM_ALWAYS_INLINE constexpr ConvexShapeView (const T &shape) noexcept
 Construct a convex shape view.
template<typename T>
requires (!same_as<T, Shape<N>> && variant_has_alternative_v<T, value_type> && convex_shape<T, N>)
GREM_ALWAYS_INLINE constexpr ConvexShapeView (const T &shape) noexcept
 Construct a convex shape view.
GREM_ALWAYS_INLINE constexpr ConvexShapeView (ShapeView< N > shape)
 Construct a shape view.
bool containsLocalPoint (Length< N > localPoint) const
 Check if a local point relative to the origin of the shape is contained within the shape.
Length< N > getLocalSupportPointOffset (Direction< N > localDirection) const
 Get the local offset from the origin of the shape to the farthest point on the shape in a certain local direction.
Public Member Functions inherited from grem::physics::ShapeView< N >
template<typename T>
requires (same_as<T, Shape<N>>)
GREM_ALWAYS_INLINE constexpr ShapeView (const T &shape) noexcept
 Construct a shape view.
template<typename T>
requires (!same_as<T, Shape<N>> && variant_has_alternative_v<T, value_type>)
GREM_ALWAYS_INLINE constexpr ShapeView (const T &shape) noexcept
 Construct a shape view.
GREM_ALWAYS_INLINE constexpr const void * data () const noexcept
 Get an untyped pointer to the data of the underlying shape.
GREM_ALWAYS_INLINE constexpr index_type index () const noexcept
 Get the type index of the underlying shape.
constexpr bool valueless_by_exception () const noexcept
 Check if the shape view is in the valueless by exception state.
template<typename T>
requires (variant_has_alternative_v<T, value_type>)
constexpr bool is () const noexcept
 Check if the shape view currently references the alternative with the given type.
template<typename T>
requires (variant_has_alternative_v<T, value_type>)
constexpr const T & as () const &noexcept
 Access the underlying value with the given type without a safety check.
template<typename T>
requires (variant_has_alternative_v<T, value_type>)
constexpr const T & get () const &
 Access the underlying value with the given type.
template<typename T>
requires (variant_has_alternative_v<T, value_type>)
constexpr const T * get_if () const noexcept
 Access the underlying shape with the given type if it is the currently active alternative.
bool isConvexShapeType () const noexcept
 Check if the shape held by this wrapper is a convex shape type.
bool isConvexPolytopeShapeType () const noexcept
 Check if the shape held by this wrapper is a convex polytope shape type.
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.
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.
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.

Additional Inherited Members

Public Types inherited from grem::physics::ShapeView< N >
using value_type = typename Shape<N>::value_type
 Underling shape variant type.
using index_type = value_type::index_type
 Index type used to encode the active shape type.

Detailed Description

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

View of a generic convex shape.

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

Constructor & Destructor Documentation

◆ ConvexShapeView() [1/3]

template<size_t N>
template<typename T>
requires (same_as<T, Shape<N>>)
GREM_ALWAYS_INLINE constexpr grem::physics::ConvexShapeView< N >::ConvexShapeView ( const T & shape)
inlineexplicitconstexprnoexcept

Construct a convex shape view.

Parameters
shapereference to the shape to construct the view over. Must outlive its use in the view.

◆ ConvexShapeView() [2/3]

template<size_t N>
template<typename T>
requires (!same_as<T, Shape<N>> && variant_has_alternative_v<T, value_type> && convex_shape<T, N>)
GREM_ALWAYS_INLINE constexpr grem::physics::ConvexShapeView< N >::ConvexShapeView ( const T & shape)
inlineconstexprnoexcept

Construct a convex shape view.

Parameters
shapereference to the shape to construct the view over. Must outlive its use in the view.

◆ ConvexShapeView() [3/3]

template<size_t N>
GREM_ALWAYS_INLINE constexpr grem::physics::ConvexShapeView< N >::ConvexShapeView ( ShapeView< N > shape)
inlineexplicitconstexpr

Construct a shape view.

Parameters
shapereference to the shape to construct the view over. Must outlive its use in the view.

Member Function Documentation

◆ containsLocalPoint()

template<size_t N>
bool grem::physics::ConvexShapeView< N >::containsLocalPoint ( Length< N > localPoint) const
nodiscard

Check if a local point relative to the origin of the shape is contained within the shape.

Parameters
localPointpoint in shape-local space to check.
Returns
true if the shape contains the given point, false otherwise.
Exceptions
BadVariantAccessif the underlying shape type is not convex.

◆ getLocalSupportPointOffset()

template<size_t N>
Length< N > grem::physics::ConvexShapeView< N >::getLocalSupportPointOffset ( Direction< N > localDirection) const
nodiscard

Get the local offset from the origin of the shape to the farthest point on the shape in a certain local direction.

Parameters
localDirectionunit vector in shape-local space of the direction to evaluate. Must be a unit vector.
Returns
a relative vector from the origin of the shape to the farthest point on the shape in the given direction, in shape-local space.
Exceptions
BadVariantAccessif the underlying shape type is not convex.

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