iMSTK
Interactive Medical Simulation Toolkit
|
Implements PBD based collision handling. Given an input PbdObject and CollisionData it creates & adds constraints in the PbdModel to be solved in order to resolve the collision. More...
#include <imstkPbdCollisionHandling.h>
Classes | |
struct | ColElemSide |
Packs the collision element together with the data it will need to process it (for swapping) More... | |
struct | CollisionSideData |
Public Types | |
enum | ObjType { PbdDeformable, PbdRigid, Colliding } |
Public Member Functions | |
const std::vector< PbdConstraint * > & | getConstraints () const |
Return the constraints generated by this handler This list of constraints is ordered in orderCollisionConstraints. | |
std::pair< PbdParticleId, Vec3d > | getBodyAndContactPoint (const CollisionElement &elem, const CollisionSideData &data) |
Get the body particle id from the collision side as well as the contact point on the body (in global space) | |
double | getRestitution () const |
Get/Set the restitution, which gives how much velocity is removed along the contact normals during contact. | |
void | setRestitution (const double restitution) |
double | getFriction () const |
Get/Set the friction, which gives how much velocity is removed along the tangents during contact. | |
void | setFriction (const double friction) |
bool | getUseCorrectVelocity () const |
Get/Set whether velocity is corrected (in some cases this could cause instabilities) | |
void | setUseCorrectVelocity (const bool useCorrectVelocity) |
int | getCCDSubsteps () const |
Get/Set the number of substeps used in CCD constraints. | |
void | setCCDSubsteps (const int ccdSubsteps) |
void | setEnableBoundaryCollisions (const bool enableBoundaryCollisions) |
Get enableBoundaryCollision. | |
const bool | getEnableBoundaryCollisions () const |
void | setRigidBodyCompliance (const double compliance) |
Get/Set compliance of rigid body contacts. Defaults to 0 compliance/infinitely stiff. This is what is needed most of the time but sometimes making a contact a bit softer can be helpful. | |
double | getRigidBodyCompliance () const |
void | setDeformableStiffnessA (const double stiffness) |
Get/Set stiffness of deformable contacts. Defaults to 1.0. This is what is needed most of the time but sometimes making a contact a bit softer can be helpful. | |
double | getDeformableStiffnessA () const |
void | setDeformableStiffnessB (const double stiffness) |
double | getDeformableStiffnessB () const |
![]() | |
virtual const std::string | getTypeName () const =0 |
void | setInputObjectA (std::shared_ptr< CollidingObject > objectA) |
Set the input objects. | |
void | setInputObjectB (std::shared_ptr< CollidingObject > objectB) |
std::shared_ptr< CollidingObject > | getInputObjectA () const |
Get the input objects. | |
std::shared_ptr< CollidingObject > | getInputObjectB () const |
virtual std::shared_ptr< Geometry > | getHandlingGeometryA () |
Get the geometry used for handling defaults to the collision geometry. | |
virtual std::shared_ptr< Geometry > | getHandlingGeometryB () |
void | setInputCollisionData (std::shared_ptr< CollisionData > collisionData) |
Set/Get the input collision data used for handling. | |
void | setInputCollisionData (std::shared_ptr< std::vector< std::shared_ptr< CollisionData >>> collisionVectorData) |
Set/Get the input collision data used for handling This supports collating information from multiple collision detect algorithms. | |
std::shared_ptr< const CollisionData > | getInputCollisionData () const |
void | update () |
Handle the input collision data. | |
Protected Types | |
enum | ConstraintType { BodyBody = 0, BodyVertex, BodyEdge, BodyTriangle, VertexVertex, VertexEdge, EdgeEdge, VertexTriangle, EdgeEdgeCCD, NumTypes } |
Protected Member Functions | |
std::array< PbdParticleId, 2 > | getEdge (const CollisionElement &elem, const CollisionSideData &side) |
std::array< PbdParticleId, 3 > | getTriangle (const CollisionElement &elem, const CollisionSideData &side) |
std::array< PbdParticleId, 1 > | getVertex (const CollisionElement &elem, const CollisionSideData &side) |
getVertex takes slightly differing paths than the others, as the cell vertex directly refers to the vertex buffer, not an index buffer | |
CollisionSideData | getDataFromObject (std::shared_ptr< CollidingObject > obj) |
Creates a CollisionSideData struct from the provided object, this gives all the info needed to response to collision. | |
PbdContactCase | getCaseFromElement (const ColElemSide &elem) |
Get the contact case from the collision element and data as additional context. | |
void | handle (const std::vector< CollisionElement > &elementsA, const std::vector< CollisionElement > &elementsB) override |
Add collision constraints based off contact data. | |
void | handleElementPair (ColElemSide sideA, ColElemSide sideB) |
Handle a single element. | |
virtual void | addConstraint_Body_V (const ColElemSide &sideA, const ColElemSide &sideB) |
virtual void | addConstraint_Body_E (const ColElemSide &sideA, const ColElemSide &sideB) |
virtual void | addConstraint_Body_T (const ColElemSide &sideA, const ColElemSide &sideB) |
virtual void | addConstraint_Body_Body (const ColElemSide &sideA, const ColElemSide &sideB) |
virtual void | addConstraint_V_T (const ColElemSide &sideA, const ColElemSide &sideB) |
virtual void | addConstraint_E_E (const ColElemSide &sideA, const ColElemSide &sideB) |
virtual void | addConstraint_E_E_CCD (const ColElemSide &sideA, const ColElemSide &sideB) |
virtual void | addConstraint_V_E (const ColElemSide &sideA, const ColElemSide &sideB) |
virtual void | addConstraint_V_V (const ColElemSide &sideA, const ColElemSide &sideB) |
template<class T > | |
T * | getCachedConstraint (ConstraintType type) |
![]() | |
void | updateCollisionData (std::shared_ptr< const CollisionData > data) |
Protected Attributes | |
std::vector< PbdConstraint * > | m_constraintBins [NumTypes] |
std::vector< PbdConstraint * > | m_constraintCache [NumTypes] |
std::vector< PbdConstraint * > | m_collisionConstraints |
Vector of all collision constraints. | |
std::unordered_map< PbdCHTableKey, std::function< void(const ColElemSide &elemA, const ColElemSide &elemB)> > | m_funcTable |
![]() | |
std::shared_ptr< CollidingObject > | m_inputObjectA |
std::shared_ptr< CollidingObject > | m_inputObjectB |
std::shared_ptr< const CollisionData > | m_colData |
Collision data. | |
std::shared_ptr< std::vector< std::shared_ptr< CollisionData > > > | m_colVectorData |
Expansion to allow collision detection to return multiple types of collision data. | |
std::function< void()> | m_updateFunction = []() {} |
bool | m_clearData = true |
bool | m_processConstraints = true |
Implements PBD based collision handling. Given an input PbdObject and CollisionData it creates & adds constraints in the PbdModel to be solved in order to resolve the collision.
This solve happens later together with all other collision constraints in the PbdModels collision solve step.
This supports PD (PointDirection) collision data as well as contacting feature collision data (ie: EE (Edge, Edge), VT (Vertex-Triangle), VV (Vertex-Vertex), VE (Vertex-Edge)). The VV and VE are often redundant but handled anyways for robustness to different inputs. The PD is often reported for point contacts, most commonly on primitive vs mesh collisions.
Definition at line 117 of file imstkPbdCollisionHandling.h.