9 #include "imstkCollisionHandling.h"    10 #include "imstkPbdConstraint.h"    12 #include <unordered_map>    26 getContactCaseStr(PbdContactCase contactCase)
    30     case PbdContactCase::Body:
    32     case PbdContactCase::Edge:
    34     case PbdContactCase::Primitive:
    36     case PbdContactCase::Triangle:
    38     case PbdContactCase::Vertex:
    54     PbdContactCase elemAType;
    55     PbdContactCase elemBType;
    58     friend std::ostream& operator<<(std::ostream& os, 
const PbdCHTableKey& dt);
    63             (elemAType == other.elemAType)
    64             && (elemBType == other.elemBType)
    65             && (ccd == other.ccd);
    87         std::size_t v0 = 
static_cast<std::size_t
>(k.elemAType); 
    88         std::size_t v1 = 
static_cast<std::size_t
>(k.elemBType); 
    89         std::size_t v2 = 
static_cast<std::size_t
>(k.ccd);       
    90         return v0 ^ (v1 << 3) ^ (v2 << 5);
   133         ObjType objType = ObjType::Colliding;
   136         double compliance  = 0.0;
   137         double stiffness   = 0.0;
   163     double getRestitution()
 const { 
return m_restitution; }
   167     void setRestitution(
const double restitution) { m_restitution = restitution; }
   175     void setFriction(
const double friction) { m_friction = friction; }
   183     void setUseCorrectVelocity(
const bool useCorrectVelocity) { m_useCorrectVelocity = useCorrectVelocity; }
   190     void setCCDSubsteps(
const int ccdSubsteps) { m_ccdSubsteps = ccdSubsteps; }
   197     const bool getEnableBoundaryCollisions()
 const { 
return m_enableBoundaryCollisions; }
   206     double getRigidBodyCompliance()
 const { 
return m_compliance; }
   215     double getDeformableStiffnessA()
 const { 
return m_stiffness[0]; }
   216     void setDeformableStiffnessB(
const double stiffness) { m_stiffness[1] = stiffness; }
   217     double getDeformableStiffnessB()
 const { 
return m_stiffness[1]; }
   224     const std::vector<PbdConstraint*>& 
getConstraints()
 const { 
return m_collisionConstraints; }
   230     std::pair<PbdParticleId, Vec3d> getBodyAndContactPoint(
   235     std::array<PbdParticleId, 2> getEdge(
   238     std::array<PbdParticleId, 3> getTriangle(
   245     std::array<PbdParticleId, 1> getVertex(
   259     PbdContactCase getCaseFromElement(
const ColElemSide& elem);
   265         const std::vector<CollisionElement>& elementsA,
   266         const std::vector<CollisionElement>& elementsB) 
override;
   274     virtual void addConstraint_Body_V(
   277     virtual void addConstraint_Body_E(
   280     virtual void addConstraint_Body_T(
   284     virtual void addConstraint_Body_Body(
   289     virtual void addConstraint_V_T(
   292     virtual void addConstraint_E_E(
   295     virtual void addConstraint_E_E_CCD(
   298     virtual void addConstraint_V_E(
   301     virtual void addConstraint_V_V(
   306     double m_restitution = 0.0;  
   307     double m_friction    = 0.0;  
   311     bool   m_enableBoundaryCollisions = 
false;
   312     double m_compliance = 0.000001;
   313     bool   m_useCorrectVelocity       = 
true;
   314     std::array<double, 2> m_stiffness = { 0.3, 0.3 };
   315     int m_ccdSubsteps = 25;
   320     void deleteCollisionConstraints();
   328     void orderCollisionConstraints();
   353     T* getCachedConstraint(ConstraintType type);
   358     std::vector<PbdConstraint*> m_constraintBins[NumTypes];
   359     std::vector<PbdConstraint*> m_constraintCache[NumTypes];
 This class implements the position based dynamics model. The PbdModel is a constraint based model tha...
Base class for all geometries represented by discrete points and elements The pointsets follow a pipe...
Implements PBD based collision handling. Given an input PbdObject and CollisionData it creates & adds...
const std::vector< PbdConstraint * > & getConstraints() const
Return the constraints generated by this handler This list of constraints is ordered in orderCollisio...
int getCCDSubsteps() const
Get/Set the number of substeps used in CCD constraints. 
This class serves as the base class of DataArray, for typeless use. 
double getFriction() const
Get/Set the friction, which gives how much velocity is removed along the tangents during contact...
Returns a hash value for a PointEntry. 
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. 
Union of collision elements. We use a union to avoid polymorphism. There may be many elements and acc...
Base class for any geometrical representation. 
void setEnableBoundaryCollisions(const bool enableBoundaryCollisions)
Get enableBoundaryCollision. 
Base class for scene objects that move and/or deform under position based dynamics formulation...
bool getUseCorrectVelocity() const
Get/Set whether velocity is corrected (in some cases this could cause instabilities) ...
Base class for all collision handling classes. 
PointwiseMap can compute & apply a mapping between parent and child PointSet geometries. 
Packs the collision element together with the data it will need to process it (for swapping) ...
std::vector< PbdConstraint * > m_collisionConstraints
Vector of all collision constraints. 
void setDeformableStiffnessA(const double stiffness)
Get/Set stiffness of deformable contacts. Defaults to 1.0. This is what is needed most of the time bu...
A SceneObject with a geometry for collision. 
Used as a key in a function table to decide how to handle resulting collision.