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

View of a generic convex polytope shape. More...

#include <GREM/physics/Shape.hpp>

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

Public Member Functions

template<typename T>
requires (same_as<T, Shape<N>>)
GREM_ALWAYS_INLINE constexpr ConvexPolytopeShapeView (const T &shape) noexcept
 Construct a convex polytope shape view.
template<typename T>
requires (!same_as<T, Shape<N>> && variant_has_alternative_v<T, value_type> && convex_polytope_shape<T, N>)
GREM_ALWAYS_INLINE constexpr ConvexPolytopeShapeView (const T &shape) noexcept
 Construct a convex polytope shape view.
GREM_ALWAYS_INLINE constexpr ConvexPolytopeShapeView (ShapeView< N > shape)
 Construct a shape view.
ConvexPolytopeVertexIndex getLocalSupportPointVertexIndex (Direction< N > localDirection, ConvexPolytopeVertexIndex searchStartVertexIndex) const
 Get the vertex index of the farthest point on the shape in a certain local direction.
ConvexPolytopeVertexIndex getVertexCount () const
 Get the total number of vertices in the convex polytope defined by this shape.
ConvexPolytopeFaceIndex getFaceCount () const
 Get the total number of faces on the convex polytope defined by this shape.
ConvexPolytopeEdgeIndex getEdgeCount () const
 Get the total number of edges, including twin edges, on the convex polyhedron defined by this 3-dimensional shape.
Length< N > getLocalVertexOffset (ConvexPolytopeVertexIndex vertexIndex) const
 Get the local offset of a specific vertex in the convex polytope defined by this shape.
Length< N > getLocalFaceOffset (ConvexPolytopeFaceIndex faceIndex) const
 Get the local offset of a specific face on the convex polytope defined by this shape.
Direction< N > getLocalFaceNormal (ConvexPolytopeFaceIndex faceIndex) const
 Get the local normal of a specific face on the convex polytope defined by this shape.
ConvexPolytopeFaceIndex getFaceIndexWithMostFittingLocalNormal (Direction< N > localDirection, ConvexPolytopeFaceIndex searchStartFaceIndex) const
 Get the index of the face on the convex polytope defined by this shape whose local normal is the most parallel with a given local direction.
ConvexPolytopeVertexIndex getFirstVertexIndexOfEdge (ConvexPolytopeEdgeIndex edgeIndex) const
 Get the vertex index of the first point of a specific edge on the convex polyhedron defined by this 3-dimensional shape.
ConvexPolytopeFaceIndex getFaceIndexOfEdge (ConvexPolytopeEdgeIndex edgeIndex) const
 Get the index of the face that a specific edge is part of on the convex polyhedron defined by this 3-dimensional shape.
ConvexPolytopeEdgeIndex getNextEdgeIndex (ConvexPolytopeEdgeIndex edgeIndex) const
 Get the index of the next edge after another edge on the same face on the convex polyhedron defined by this 3-dimensional shape, which will eventually loop back around to the given edge again.
ConvexPolytopeEdgeIndex getFirstEdgeIndexOfFace (ConvexPolytopeFaceIndex faceIndex) const
 Get the index of the first edge that a specific face is made up of on the convex polyhedron defined by this 3-dimensional shape.
ConvexPolytopeEdgeIndex getSomeEdgeIndexOfVertex (ConvexPolytopeVertexIndex vertexIndex) const
 Get the index of some edge that has a specific vertex as its origin on the convex polyhedron defined by this 3-dimensional shape.
Public Member Functions inherited from grem::physics::ConvexShapeView< N >
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::ConvexPolytopeShapeView< N >

View of a generic convex polytope shape.

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

Constructor & Destructor Documentation

◆ ConvexPolytopeShapeView() [1/3]

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

Construct a convex polytope shape view.

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

◆ ConvexPolytopeShapeView() [2/3]

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

Construct a convex polytope shape view.

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

◆ ConvexPolytopeShapeView() [3/3]

template<size_t N>
GREM_ALWAYS_INLINE constexpr grem::physics::ConvexPolytopeShapeView< N >::ConvexPolytopeShapeView ( 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

◆ getLocalSupportPointVertexIndex()

template<size_t N>
ConvexPolytopeVertexIndex grem::physics::ConvexPolytopeShapeView< N >::getLocalSupportPointVertexIndex ( Direction< N > localDirection,
ConvexPolytopeVertexIndex searchStartVertexIndex ) const
nodiscard

Get the vertex index of 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.
searchStartVertexIndexinitial vertex index to start the search from. Must either be 0, or less than getVertexCount().
Returns
the vertex index of the farthest point on the shape in the given direction.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getVertexCount()

template<size_t N>
ConvexPolytopeVertexIndex grem::physics::ConvexPolytopeShapeView< N >::getVertexCount ( ) const
nodiscard

Get the total number of vertices in the convex polytope defined by this shape.

Returns
the number of vertices in the shape.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getFaceCount()

template<size_t N>
ConvexPolytopeFaceIndex grem::physics::ConvexPolytopeShapeView< N >::getFaceCount ( ) const
nodiscard

Get the total number of faces on the convex polytope defined by this shape.

Returns
the number of faces on the shape.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getEdgeCount()

template<size_t N>
ConvexPolytopeEdgeIndex grem::physics::ConvexPolytopeShapeView< N >::getEdgeCount ( ) const
nodiscard

Get the total number of edges, including twin edges, on the convex polyhedron defined by this 3-dimensional shape.

Returns
the number of edges, including twin edges, on the shape.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getLocalVertexOffset()

template<size_t N>
Length< N > grem::physics::ConvexPolytopeShapeView< N >::getLocalVertexOffset ( ConvexPolytopeVertexIndex vertexIndex) const
nodiscard

Get the local offset of a specific vertex in the convex polytope defined by this shape.

Parameters
vertexIndexindex of the vertex to get the offset of.
Returns
the offset of the given vertex from the center of the shape, in shape-local space.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getLocalFaceOffset()

template<size_t N>
Length< N > grem::physics::ConvexPolytopeShapeView< N >::getLocalFaceOffset ( ConvexPolytopeFaceIndex faceIndex) const
nodiscard

Get the local offset of a specific face on the convex polytope defined by this shape.

Parameters
faceIndexindex of the face to get the offset of.
Returns
an arbitrary point the given face, in shape-local space.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getLocalFaceNormal()

template<size_t N>
Direction< N > grem::physics::ConvexPolytopeShapeView< N >::getLocalFaceNormal ( ConvexPolytopeFaceIndex faceIndex) const
nodiscard

Get the local normal of a specific face on the convex polytope defined by this shape.

Parameters
faceIndexindex of the face to get the normal of.
Returns
a unit direction vector perpendicular to the given face, in shape-local space, pointing outwards from the center of the shape.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getFaceIndexWithMostFittingLocalNormal()

template<size_t N>
ConvexPolytopeFaceIndex grem::physics::ConvexPolytopeShapeView< N >::getFaceIndexWithMostFittingLocalNormal ( Direction< N > localDirection,
ConvexPolytopeFaceIndex searchStartFaceIndex ) const
nodiscard

Get the index of the face on the convex polytope defined by this shape whose local normal is the most parallel with a given local direction.

Parameters
localDirectionunit direction vector to search in, in object space. Must be a unit vector.
searchStartFaceIndexinitial face index to start the search from. Must either be 0, or less than getFaceCount().
Returns
the index of the face whose normal is pointing the most towards the given direction.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getFirstVertexIndexOfEdge()

template<size_t N>
ConvexPolytopeVertexIndex grem::physics::ConvexPolytopeShapeView< N >::getFirstVertexIndexOfEdge ( ConvexPolytopeEdgeIndex edgeIndex) const
nodiscard

Get the vertex index of the first point of a specific edge on the convex polyhedron defined by this 3-dimensional shape.

Parameters
edgeIndexindex of the edge whose vertex index to get.
Returns
the vertex index of the first point of the given edge.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getFaceIndexOfEdge()

template<size_t N>
ConvexPolytopeFaceIndex grem::physics::ConvexPolytopeShapeView< N >::getFaceIndexOfEdge ( ConvexPolytopeEdgeIndex edgeIndex) const
nodiscard

Get the index of the face that a specific edge is part of on the convex polyhedron defined by this 3-dimensional shape.

Parameters
edgeIndexindex of the edge to get the face index of.
Returns
the index of the face that the given edge belongs to.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getNextEdgeIndex()

template<size_t N>
ConvexPolytopeEdgeIndex grem::physics::ConvexPolytopeShapeView< N >::getNextEdgeIndex ( ConvexPolytopeEdgeIndex edgeIndex) const
nodiscard

Get the index of the next edge after another edge on the same face on the convex polyhedron defined by this 3-dimensional shape, which will eventually loop back around to the given edge again.

The winding order is counter-clockwise when viewed from outside of the shape.

Parameters
edgeIndexindex of the edge to get the next edge index of.
Returns
the index of the next edge on the same face.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getFirstEdgeIndexOfFace()

template<size_t N>
ConvexPolytopeEdgeIndex grem::physics::ConvexPolytopeShapeView< N >::getFirstEdgeIndexOfFace ( ConvexPolytopeFaceIndex faceIndex) const
nodiscard

Get the index of the first edge that a specific face is made up of on the convex polyhedron defined by this 3-dimensional shape.

Parameters
faceIndexindex of the face to get the first edge index of.
Returns
the index of the first edge that belongs to the given face.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

◆ getSomeEdgeIndexOfVertex()

template<size_t N>
ConvexPolytopeEdgeIndex grem::physics::ConvexPolytopeShapeView< N >::getSomeEdgeIndexOfVertex ( ConvexPolytopeVertexIndex vertexIndex) const
nodiscard

Get the index of some edge that has a specific vertex as its origin on the convex polyhedron defined by this 3-dimensional shape.

Parameters
vertexIndexindex of the vertex to get the edge index of.
Returns
some edge index that has the given vertex as its origin.
Exceptions
BadVariantAccessif the underlying shape type is not a convex polytope.

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