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

Shape in 3-dimensional space. More...

#include <GREM/physics/Shape.hpp>

Inheritance diagram for grem::physics::Shape< 3 >:

Public Types

using value_type = Variant
Public Types inherited from grem::Variant< PointShape3D, LineSegmentShape3D, InfiniteLineShape3D, InfiniteHalfSpaceShape3D, InfinitePlaneShape3D, BoxShape3D, CubeShape3D, EllipsoidShape3D, SphereShape3D, CapsuleShape3D, TaperedCapsuleShape3D, CylinderShape3D, TaperedCylinderShape3D, ConvexPolytopeShape3D, TriangleMeshShape3D, LocallyTransformedShape3D, CompoundColliderShape3D >
using index_type
 Index type used to encode the active alternative type.

Public Member Functions

bool isConvexShapeType () const
 Check if the shape held by this wrapper is a convex shape type.
bool isConvexPolytopeShapeType () const
 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.
PrincipalMomentsOfInertia3D calculatePrincipalMomentsOfInertia (Mass mass) const
 Calculate an estimate of the local moment of inertia of the shape given a certain mass.
Optional< Box3D > getBoundingBox (const Transformation3D &transformation) const
 Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Optional< Distance > getBoundingRadius (const Basis3D &basis) const
 Get the radius of the bounding sphere of the shape.
Optional< Area > getReferenceArea (const Basis3D &basis, Direction3D 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.
RaycastResult3D castLocalRay (Length3D localRayOrigin, Direction3D localRayDirection, Distance maxLocalRayDistance) const
 Find the closest intersection of this shape with a given ray in local space.
constexpr Variant () noexcept(std::is_nothrow_default_constructible_v< variant_alternative_t< 0, Variant > >)
 Default-construct a variant with the first variant alternative, if it is default-constructible.
template<typename U>
requires (!std::is_same_v<std::remove_cvref_t<U>, Variant> && variant_has_alternative_v<decltype(F(std::forward<U>(value))), Variant> && std::is_constructible_v<decltype(F(std::forward<U>(value))), U>)
constexpr Variant (U &&value) noexcept(std::is_nothrow_constructible_v< decltype(F(std::forward< U >(value))), U >)
 Converting constructor.
template<typename T, typename... Args>
requires (variant_has_alternative_v<T, Variant> && std::is_constructible_v<T, Args...>)
constexpr Variant (std::in_place_type_t< T > type, Args &&... args)
 Construct a variant alternative in-place given its type.
template<typename T, typename U, typename... Args>
requires (variant_has_alternative_v<T, Variant> && std::is_constructible_v<T, std::initializer_list<U>&, Args...>)
constexpr Variant (std::in_place_type_t< T > type, std::initializer_list< U > ilist, Args &&... args)
 Construct a variant alternative in-place given its type, with an initializer list as the first constructor argument.
template<std::size_t Index, typename... Args>
requires (Index < sizeof...(Ts) && std::is_constructible_v<variant_alternative_t<Index, Variant>, Args...>)
constexpr Variant (std::in_place_index_t< Index > index, Args &&... args)
 Construct a variant alternative in-place given its index.
template<std::size_t Index, typename U, typename... Args>
requires (Index < sizeof...(Ts) && std::is_constructible_v<variant_alternative_t<Index, Variant>, std::initializer_list<U>&, Args...>)
constexpr Variant (std::in_place_index_t< Index > index, std::initializer_list< U > ilist, Args &&... args)
 Construct a variant alternative in-place given its index, with an initializer list as the first constructor argument.
constexpr Variant (const Variant &other)=delete
 Deleted copy constructor.
constexpr Variant (Variant &&other) noexcept=default
 Trivial move constructor.
Public Member Functions inherited from grem::Variant< PointShape3D, LineSegmentShape3D, InfiniteLineShape3D, InfiniteHalfSpaceShape3D, InfinitePlaneShape3D, BoxShape3D, CubeShape3D, EllipsoidShape3D, SphereShape3D, CapsuleShape3D, TaperedCapsuleShape3D, CylinderShape3D, TaperedCylinderShape3D, ConvexPolytopeShape3D, TriangleMeshShape3D, LocallyTransformedShape3D, CompoundColliderShape3D >
constexpr ~Variant ()
 Destructor.
constexpr Variant & operator= (const Variant &other)=delete
 Deleted copy assignment.
constexpr T & emplace (Args &&... args)
 Construct an alternative given its type, destroying the old value.
constexpr void swap (Variant &other) noexcept(((std::is_nothrow_move_constructible_v< Ts > &&std::is_nothrow_swappable_v< Ts >) &&...))
 Swap this variant's value with that of another.
constexpr index_type index () const noexcept
 Get the alternative index of the currently active value held by the variant.
constexpr bool valueless_by_exception () const noexcept
 Check if the variant is in the valueless by exception state.
constexpr bool is () const noexcept
 Check if the variant currently holds the alternative with the given type.
constexpr T & as () &noexcept
 Access the underlying value with the given type without a safety check.
constexpr T & get () &
 Access the underlying value with the given type.
constexpr T * get_if () noexcept
 Access the underlying value with the given type if it is the currently active alternative.

Additional Inherited Members

Static Public Member Functions inherited from grem::Variant< PointShape3D, LineSegmentShape3D, InfiniteLineShape3D, InfiniteHalfSpaceShape3D, InfinitePlaneShape3D, BoxShape3D, CubeShape3D, EllipsoidShape3D, SphereShape3D, CapsuleShape3D, TaperedCapsuleShape3D, CylinderShape3D, TaperedCylinderShape3D, ConvexPolytopeShape3D, TriangleMeshShape3D, LocallyTransformedShape3D, CompoundColliderShape3D >
static constexpr decltype(auto) visit (Visitor &&visitor, V &&variant)
 Call a visitor functor with the currently active underlying value of a variant.
static constexpr decltype(auto) visitIndex (index_type index, Visitor &&visitor)
 Call a visitor functor with the type corresponding to a variant index.
static constexpr decltype(auto) apply (Function &&function)
 Call a functor with all alternative types.
Static Public Attributes inherited from grem::Variant< PointShape3D, LineSegmentShape3D, InfiniteLineShape3D, InfiniteHalfSpaceShape3D, InfinitePlaneShape3D, BoxShape3D, CubeShape3D, EllipsoidShape3D, SphereShape3D, CapsuleShape3D, TaperedCapsuleShape3D, CylinderShape3D, TaperedCylinderShape3D, ConvexPolytopeShape3D, TriangleMeshShape3D, LocallyTransformedShape3D, CompoundColliderShape3D >
static constexpr index_type npos
 Invalid alternative index, representing the valueless by exception state.

Detailed Description

Shape in 3-dimensional space.

Member Typedef Documentation

◆ value_type

using grem::physics::Shape< 3 >::value_type = Variant

Member Function Documentation

◆ isConvexShapeType()

bool grem::physics::Shape< 3 >::isConvexShapeType ( ) const
inlinenodiscard

Check if the shape held by this wrapper is a convex shape type.

Returns
true if the underlying shape satisfies the convex_shape concept, false otherwise.

◆ isConvexPolytopeShapeType()

bool grem::physics::Shape< 3 >::isConvexPolytopeShapeType ( ) const
inlinenodiscard

Check if the shape held by this wrapper is a convex polytope shape type.

Returns
true if the underlying shape satisfies the convex_polytope_shape concept, false otherwise.

◆ calculateVolume()

Volume grem::physics::Shape< 3 >::calculateVolume ( ) const
inlinenodiscard

Calculate an estimate of the volume of the shape.

Returns
the estimated volume of the shape.

◆ calculatePrincipalMomentsOfInertia()

PrincipalMomentsOfInertia3D grem::physics::Shape< 3 >::calculatePrincipalMomentsOfInertia ( Mass mass) const
inlinenodiscard

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()

Optional< Box3D > grem::physics::Shape< 3 >::getBoundingBox ( const Transformation3D & 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()

Optional< Distance > grem::physics::Shape< 3 >::getBoundingRadius ( const Basis3D & 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()

Optional< Area > grem::physics::Shape< 3 >::getReferenceArea ( const Basis3D & basis,
Direction3D direction ) const
inlinenodiscard

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()

RaycastResult3D grem::physics::Shape< 3 >::castLocalRay ( Length3D localRayOrigin,
Direction3D localRayDirection,
Distance maxLocalRayDistance ) const
inlinenodiscard

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.

◆ Variant() [1/8]

grem::Variant< Ts >::Variant ( )
inlineconstexprnoexcept

Default-construct a variant with the first variant alternative, if it is default-constructible.

Exceptions
anyexception thrown by the underlying constructor of the first alternative type.

◆ Variant() [2/8]

template<typename U>
requires (!std::is_same_v<std::remove_cvref_t<U>, Variant> && variant_has_alternative_v<decltype(F(std::forward<U>(value))), Variant> && std::is_constructible_v<decltype(F(std::forward<U>(value))), U>)
grem::Variant< Ts >::Variant ( U && value)
inlineconstexprnoexcept

Converting constructor.

Chooses the variant alternative type to construct based on the overloading rules specified by std::variant.

Parameters
valueunderlying value to construct the variant from. Must be convertible to one of the variant's listed alternative types.
Exceptions
anyexception thrown by the underlying constructor of the relevant alternative type.

◆ Variant() [3/8]

template<typename T, typename... Args>
requires (variant_has_alternative_v<T, Variant> && std::is_constructible_v<T, Args...>)
grem::Variant< Ts >::Variant ( std::in_place_type_t< T > type,
Args &&... args )
inlineexplicitconstexpr

Construct a variant alternative in-place given its type.

Parameters
typestd::in_place_type<T>, where T is the alternative type to construct, which must be one of the variant's listed alternative types.
argsarguments to pass to the underlying value's constructor.
Exceptions
anyexception thrown by the underlying constructor of the relevant alternative type.

◆ Variant() [4/8]

template<typename T, typename U, typename... Args>
requires (variant_has_alternative_v<T, Variant> && std::is_constructible_v<T, std::initializer_list<U>&, Args...>)
grem::Variant< Ts >::Variant ( std::in_place_type_t< T > type,
std::initializer_list< U > ilist,
Args &&... args )
inlineexplicitconstexpr

Construct a variant alternative in-place given its type, with an initializer list as the first constructor argument.

Parameters
typestd::in_place_type<T>, where T is the alternative type to construct, which must be one of the variant's listed alternative types.
ilistfirst argument to pass to the underlying value's constructor.
argssubsequent arguments to pass to the underlying value's constructor.
Exceptions
anyexception thrown by the underlying constructor of the relevant alternative type.

◆ Variant() [5/8]

template<std::size_t Index, typename... Args>
requires (Index < sizeof...(Ts) && std::is_constructible_v<variant_alternative_t<Index, Variant>, Args...>)
grem::Variant< Ts >::Variant ( std::in_place_index_t< Index > index,
Args &&... args )
inlineexplicitconstexpr

Construct a variant alternative in-place given its index.

Parameters
indexstd::in_place_index<Index>, where Index is the alternative index to construct, which must be within the range of the variant's list of alternative types.
argsarguments to pass to the underlying value's constructor.
Exceptions
anyexception thrown by the underlying constructor of the relevant alternative type.

◆ Variant() [6/8]

template<std::size_t Index, typename U, typename... Args>
requires (Index < sizeof...(Ts) && std::is_constructible_v<variant_alternative_t<Index, Variant>, std::initializer_list<U>&, Args...>)
grem::Variant< Ts >::Variant ( std::in_place_index_t< Index > index,
std::initializer_list< U > ilist,
Args &&... args )
inlineexplicitconstexpr

Construct a variant alternative in-place given its index, with an initializer list as the first constructor argument.

Parameters
indexstd::in_place_index<Index>, where Index is the alternative index to construct, which must be within the range of the variant's list of alternative types.
ilistfirst argument to pass to the underlying value's constructor.
argssubsequent arguments to pass to the underlying value's constructor.
Exceptions
anyexception thrown by the underlying constructor of the relevant alternative type.

◆ Variant() [7/8]

grem::Variant< Ts >::Variant ( const Variant & other)
constexprdelete

Deleted copy constructor.

◆ Variant() [8/8]

grem::Variant< Ts >::Variant ( Variant && other)
constexprdefaultnoexcept

Trivial move constructor.


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