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

Triangle mesh shape. More...

#include <GREM/physics/Shape.hpp>

Public Types

using Vertex = typename TriangleMesh<N, float>::Vertex
 Vertex type of the triangle mesh shape.
using VertexIndex = typename TriangleMesh<N, float>::VertexIndex
 Vertex index type of the triangle mesh shape.
using FaceIndex = typename TriangleMesh<N, float>::FaceIndex
 Face index type of the triangle mesh shape.

Public Member Functions

GREM_ALWAYS_INLINE TriangleMeshShape (SharedPointer< TriangleMesh< N, float > > mesh) noexcept
 Construct a triangle mesh shape from an existing triangle mesh.
 TriangleMeshShape (Allocation< Vertex > vertices, Allocation< VertexIndex > indices)
 Construct a triangle mesh shape from a set of vertices.
 TriangleMeshShape (Span< const Vertex > vertices, Span< const VertexIndex > indices)
 Construct a triangle mesh shape from a set of vertices and indices.
GREM_ALWAYS_INLINE const SharedPointer< TriangleMesh< N, float > > & getTriangleMesh () const noexcept
 Get the underlying triangle mesh of the 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::TriangleMeshShape< N >

Triangle mesh shape.

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

Member Typedef Documentation

◆ Vertex

template<size_t N>
using grem::physics::TriangleMeshShape< N >::Vertex = typename TriangleMesh<N, float>::Vertex

Vertex type of the triangle mesh shape.

◆ VertexIndex

template<size_t N>
using grem::physics::TriangleMeshShape< N >::VertexIndex = typename TriangleMesh<N, float>::VertexIndex

Vertex index type of the triangle mesh shape.

◆ FaceIndex

template<size_t N>
using grem::physics::TriangleMeshShape< N >::FaceIndex = typename TriangleMesh<N, float>::FaceIndex

Face index type of the triangle mesh shape.

Constructor & Destructor Documentation

◆ TriangleMeshShape() [1/3]

template<size_t N>
GREM_ALWAYS_INLINE grem::physics::TriangleMeshShape< N >::TriangleMeshShape ( SharedPointer< TriangleMesh< N, float > > mesh)
inlineexplicitnoexcept

Construct a triangle mesh shape from an existing triangle mesh.

Parameters
meshshared pointer to the mesh. Must not be nullptr.

◆ TriangleMeshShape() [2/3]

template<size_t N>
grem::physics::TriangleMeshShape< N >::TriangleMeshShape ( Allocation< Vertex > vertices,
Allocation< VertexIndex > indices )

Construct a triangle mesh shape from a set of vertices.

Parameters
verticesset of vertices to construct the triangle mesh from.
indicesset of vertex indices to construct the triangle mesh from. Each index must be less than the number of vertices. Size must be a multiple of 3.
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.

◆ TriangleMeshShape() [3/3]

template<size_t N>
grem::physics::TriangleMeshShape< N >::TriangleMeshShape ( Span< const Vertex > vertices,
Span< const VertexIndex > indices )

Construct a triangle mesh shape from a set of vertices and indices.

Parameters
verticesread-only view over a set of vertices to construct the triangle mesh from.
indicesread-only view over a set of vertex indices to construct the triangle mesh from. Each index must be less than the number of vertices. Size must be a multiple of 3.
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

◆ getTriangleMesh()

template<size_t N>
GREM_ALWAYS_INLINE const SharedPointer< TriangleMesh< N, float > > & grem::physics::TriangleMeshShape< N >::getTriangleMesh ( ) const
inlinenodiscardnoexcept

Get the underlying triangle mesh of the shape.

Returns
a read-only reference to the underlying triangle mesh.

◆ calculateVolume()

template<size_t N>
Volume grem::physics::TriangleMeshShape< 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::TriangleMeshShape< 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::TriangleMeshShape< 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::TriangleMeshShape< 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::TriangleMeshShape< 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::TriangleMeshShape< 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: