PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
pbat::sim::contact::MeshVertexTetrahedronDcd Class Reference

Discrete contact detection system for vertex-tetrahedron contacts between multiple tetrahedral meshes. More...

#include <MeshVertexTetrahedronDcd.h>

Public Types

using ScalarType = Scalar
 Scalar type used in the contact detection system.
 
using IndexType = Index
 Index type used in the contact detection system.
 

Public Member Functions

PBAT_API MeshVertexTetrahedronDcd (Eigen::Ref< Eigen::Matrix< ScalarType, kDims, Eigen::Dynamic > > X, Eigen::Ref< Eigen::Matrix< IndexType, 4, Eigen::Dynamic > > T)
 Construct a new MeshVertexTetrahedronDcd object from input tetrahedron meshes.
 
PBAT_API void UpdateActiveSet (Eigen::Ref< Eigen::Matrix< ScalarType, kDims, Eigen::Dynamic > const > const &X, Eigen::Ref< Eigen::Matrix< IndexType, 4, Eigen::Dynamic > const > const &T)
 Update the active set of vertex-triangle contacts.
 
template<class FOnVertexTriangleContactPair>
void ForEachActiveVertexTriangleContact (IndexType v, FOnVertexTriangleContactPair fOnVertexTriangleContactPair) const
 Visit the triangles in active vertex-triangle contacts.
 
PBAT_API MultibodyTetrahedralMeshSystem< IndexType > const & MultibodySystem () const
 Get the multibody tetrahedral mesh system.
 

Static Public Attributes

static constexpr int kMaxVertexTriangleContacts
 Maximum number of contacting triangles per vertex.
 
static constexpr int kDims = 3
 Number of dimensions in the contact detection system.
 

Protected Member Functions

template<class TDerivedX>
void ComputeTriangleAabbs (Eigen::DenseBase< TDerivedX > const &X)
 Compute axis-aligned bounding boxes for triangles for DCD.
 
template<class TDerivedX, class TDerivedT>
void ComputeTetrahedronMeshAabbs (IndexType o, Eigen::DenseBase< TDerivedX > const &X, Eigen::DenseBase< TDerivedT > const &T)
 Computes AABBs for tetrahedra from mesh vertex positions.
 
PBAT_API void ComputeBodyAabbs ()
 Computes body AABBs from mesh vertex BVHs.
 
PBAT_API void UpdateMeshTriangleBvhs ()
 Recompute mesh triangle BVH bounding boxes.
 
PBAT_API void UpdateMeshTetrahedronHashGrid (IndexType bodyIndex)
 Recompute mesh tetrahedron hash grid for a specific body.
 
PBAT_API void RecomputeBodiesBvh ()
 Recompute bodies BVH tree and internal node bounding boxes.
 
template<class FOnBodyPair>
void ForEachBodyPair (FOnBodyPair &&fOnBodyPair) const
 Compute and visit all contacting body pairs.
 
template<class TDerivedX, class TDerivedT>
void MarkPenetratingVertices (IndexType ov, IndexType ot, Eigen::DenseBase< TDerivedX > const &X, Eigen::DenseBase< TDerivedT > const &T)
 Register all collision vertices of body ov that penetrate into body ot
 
template<class TDerivedX>
void FindNearestTrianglesToPenetratingVertices (IndexType ov, IndexType of, Eigen::DenseBase< TDerivedX > const &X)
 Find the nearest triangles on the triangle mesh of to penetrating vertices of body ov
 

Detailed Description

Discrete contact detection system for vertex-tetrahedron contacts between multiple tetrahedral meshes.

Uses an AABB tree hierarchy for the mesh vertices and an AABB tree hierarchy for the mesh triangles, as well as a spatial hash grid for the tetrahedra.

For each vertex, stores up to kMaxVertexTriangleContacts contacting triangles.

Constructor & Destructor Documentation

◆ MeshVertexTetrahedronDcd()

pbat::sim::contact::MeshVertexTetrahedronDcd::MeshVertexTetrahedronDcd ( Eigen::Ref< Eigen::Matrix< ScalarType, kDims, Eigen::Dynamic > > X,
Eigen::Ref< Eigen::Matrix< IndexType, 4, Eigen::Dynamic > > T )

Construct a new MeshVertexTetrahedronDcd object from input tetrahedron meshes.

Template Parameters
TDerivedXEigen type of the input vertex positions
Parameters
XkDims x |# vertices| matrix of vertex positions
T4 x |# tetrahedra| tetrahedron array

Member Function Documentation

◆ ComputeBodyAabbs()

void pbat::sim::contact::MeshVertexTetrahedronDcd::ComputeBodyAabbs ( )
protected

Computes body AABBs from mesh vertex BVHs.

Precondition
(Vertex) mesh BVHs must be up-to-date before calling this function, i.e. via a call to UpdateMeshVertexBvhs

◆ ComputeTetrahedronMeshAabbs()

template<class TDerivedX, class TDerivedT>
void pbat::sim::contact::MeshVertexTetrahedronDcd::ComputeTetrahedronMeshAabbs ( IndexType o,
Eigen::DenseBase< TDerivedX > const & X,
Eigen::DenseBase< TDerivedT > const & T )
inlineprotected

Computes AABBs for tetrahedra from mesh vertex positions.

Template Parameters
TDerivedXEigen type of vertex positions
TDerivedTEigen type of tetrahedron mesh elements/connectivity
Parameters
oIndex of the body to compute tetrahedron AABBs for
XkDims x |# vertices| matrix of vertex positions
T4 x |# tetrahedra| tetrahedron mesh elements/connectivity

◆ ComputeTriangleAabbs()

template<class TDerivedX>
void pbat::sim::contact::MeshVertexTetrahedronDcd::ComputeTriangleAabbs ( Eigen::DenseBase< TDerivedX > const & X)
inlineprotected

Compute axis-aligned bounding boxes for triangles for DCD.

Template Parameters
TDerivedXEigen type of vertex positions
Parameters
XkDims x |# vertices| matrix of vertex positions

◆ FindNearestTrianglesToPenetratingVertices()

template<class TDerivedX>
void pbat::sim::contact::MeshVertexTetrahedronDcd::FindNearestTrianglesToPenetratingVertices ( IndexType ov,
IndexType of,
Eigen::DenseBase< TDerivedX > const & X )
inlineprotected

Find the nearest triangles on the triangle mesh of to penetrating vertices of body ov

Template Parameters
TDerivedXEigen type of vertex positions
Parameters
ovIndex of the body whose collision vertices penetrate body of
ofIndex of the body penetrated by body ov
XkDims x |# vertices| matrix of vertex positions

◆ ForEachActiveVertexTriangleContact()

template<class FOnVertexTriangleContactPair>
void pbat::sim::contact::MeshVertexTetrahedronDcd::ForEachActiveVertexTriangleContact ( IndexType v,
FOnVertexTriangleContactPair fOnVertexTriangleContactPair ) const
inline

Visit the triangles in active vertex-triangle contacts.

Template Parameters
FOnVertexTriangleContactPairCallable type with signature void( IndexType f, IndexType k) where f is the index of the triangle and 0 <= k < kMaxVertexTriangleContacts is the index of the contact
Parameters
vIndex of the vertex whose active triangle contacts to visit
fOnVertexTriangleContactPairFunction to call for each vertex-triangle contact pair

◆ ForEachBodyPair()

template<class FOnBodyPair>
void pbat::sim::contact::MeshVertexTetrahedronDcd::ForEachBodyPair ( FOnBodyPair && fOnBodyPair) const
inlineprotected

Compute and visit all contacting body pairs.

Template Parameters
FOnBodyPairCallable type with signature void(IndexType oi, IndexType oj)
Parameters
fOnBodyPairFunction to call for each body pair

◆ MarkPenetratingVertices()

template<class TDerivedX, class TDerivedT>
void pbat::sim::contact::MeshVertexTetrahedronDcd::MarkPenetratingVertices ( IndexType ov,
IndexType ot,
Eigen::DenseBase< TDerivedX > const & X,
Eigen::DenseBase< TDerivedT > const & T )
inlineprotected

Register all collision vertices of body ov that penetrate into body ot

Template Parameters
TDerivedXEigen type of vertex positions
TDerivedTEigen type of tetrahedron mesh elements/connectivity
Parameters
ovIndex of the body whose collision vertices to check against body ot
otIndex of the body penetrated by body ov
XkDims x |# vertices| matrix of vertex positions
T4 x |# tetrahedra| tetrahedron mesh elements/connectivity

◆ UpdateActiveSet()

void pbat::sim::contact::MeshVertexTetrahedronDcd::UpdateActiveSet ( Eigen::Ref< Eigen::Matrix< ScalarType, kDims, Eigen::Dynamic > const > const & X,
Eigen::Ref< Eigen::Matrix< IndexType, 4, Eigen::Dynamic > const > const & T )

Update the active set of vertex-triangle contacts.

Template Parameters
TDerivedXEigen type of vertex positions
Parameters
XkDims x |# vertices| matrix of vertex positions
T4 x |# tetrahedra| tetrahedron array

◆ UpdateMeshTetrahedronHashGrid()

void pbat::sim::contact::MeshVertexTetrahedronDcd::UpdateMeshTetrahedronHashGrid ( IndexType bodyIndex)
protected

Recompute mesh tetrahedron hash grid for a specific body.

Parameters
bodyIndexIndex of the body to update the tetrahedron hash grid for

Member Data Documentation

◆ kMaxVertexTriangleContacts

int pbat::sim::contact::MeshVertexTetrahedronDcd::kMaxVertexTriangleContacts
staticconstexpr
Initial value:
=
8

Maximum number of contacting triangles per vertex.


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