Bullet Collision Detection & Physics Library: btReducedDeformableContactConstraint.h Source File

Bullet Collision Detection & Physics Library

btReducedDeformableContactConstraint.h
Go to the documentation of this file.
1#include "../btDeformableContactConstraint.h"
2#include "btReducedDeformableBody.h"
3
4// ================= static constraints ===================
5 class btReducedDeformableStaticConstraint : public btDeformableStaticConstraint
6{
7 public:
8 btReducedDeformableBody* m_rsb;
9 btScalar m_dt;
10 btVector3 m_ri;
11 btVector3 m_targetPos;
12 btVector3 m_impulseDirection;
13 btMatrix3x3 m_impulseFactorMatrix;
14 btScalar m_impulseFactor;
15 btScalar m_rhs;
16 btScalar m_appliedImpulse;
17 btScalar m_erp;
18
19 btReducedDeformableStaticConstraint(btReducedDeformableBody* rsb,
20 btSoftBody::Node* node,
21 const btVector3& ri,
22 const btVector3& x0,
23 const btVector3& dir,
24 const btContactSolverInfo& infoGlobal,
25 btScalar dt);
26 // btReducedDeformableStaticConstraint(const btReducedDeformableStaticConstraint& other);
27 btReducedDeformableStaticConstraint() {}
28 virtual ~btReducedDeformableStaticConstraint() {}
29
30 virtual btScalar solveConstraint(const btContactSolverInfo& infoGlobal);
31
32 // this calls reduced deformable body's applyFullSpaceImpulse
33 virtual void applyImpulse(const btVector3& impulse);
34
35 btVector3 getDeltaVa() const;
36
37 // virtual void applySplitImpulse(const btVector3& impulse) {}
38};
39
40// ================= base contact constraints ===================
41 class btReducedDeformableRigidContactConstraint : public btDeformableRigidContactConstraint
42{
43 public:
44 bool m_collideStatic; // flag for collision with static object
45 bool m_collideMultibody; // flag for collision with multibody
46
47 int m_nodeQueryIndex;
48 int m_solverBodyId; // for debugging
49
50 btReducedDeformableBody* m_rsb;
51 btSolverBody* m_solverBody;
52 btScalar m_dt;
53
54 btScalar m_appliedNormalImpulse;
55 btScalar m_appliedTangentImpulse;
56 btScalar m_appliedTangentImpulse2;
57 btScalar m_normalImpulseFactor;
58 btScalar m_tangentImpulseFactor;
59 btScalar m_tangentImpulseFactor2;
60 btScalar m_tangentImpulseFactorInv;
61 btScalar m_tangentImpulseFactorInv2;
62 btScalar m_rhs;
63 btScalar m_rhs_tangent;
64 btScalar m_rhs_tangent2;
65
66 btScalar m_cfm;
67 btScalar m_cfm_friction;
68 btScalar m_erp;
69 btScalar m_erp_friction;
70 btScalar m_friction;
71
72 btVector3 m_contactNormalA; // surface normal for rigid body (opposite direction as impulse)
73 btVector3 m_contactNormalB; // surface normal for reduced deformable body (opposite direction as impulse)
74 btVector3 m_contactTangent; // tangential direction of the relative velocity
75 btVector3 m_contactTangent2; // 2nd tangential direction of the relative velocity
76 btVector3 m_relPosA; // relative position of the contact point for A (rigid)
77 btVector3 m_relPosB; // relative position of the contact point for B
78 btMatrix3x3 m_impulseFactor; // total impulse matrix
79
80 btVector3 m_bufferVelocityA; // velocity at the beginning of the iteration
81 btVector3 m_bufferVelocityB;
82 btVector3 m_linearComponentNormal; // linear components for the solver body
83 btVector3 m_angularComponentNormal; // angular components for the solver body
84 // since 2nd contact direction only applies to multibody, these components will never be used
85 btVector3 m_linearComponentTangent;
86 btVector3 m_angularComponentTangent;
87
88 btReducedDeformableRigidContactConstraint(btReducedDeformableBody* rsb,
89 const btSoftBody::DeformableRigidContact& c,
90 const btContactSolverInfo& infoGlobal,
91 btScalar dt);
92 // btReducedDeformableRigidContactConstraint(const btReducedDeformableRigidContactConstraint& other);
93 btReducedDeformableRigidContactConstraint() {}
94 virtual ~btReducedDeformableRigidContactConstraint() {}
95
96 void setSolverBody(const int bodyId, btSolverBody& solver_body);
97
98 virtual void warmStarting() {}
99
100 virtual btScalar solveConstraint(const btContactSolverInfo& infoGlobal);
101
102 void calculateTangentialImpulse(btScalar& deltaImpulse_tangent,
103 btScalar& appliedImpulse,
104 const btScalar rhs_tangent,
105 const btScalar tangentImpulseFactorInv,
106 const btVector3& tangent,
107 const btScalar lower_limit,
108 const btScalar upper_limit,
109 const btVector3& deltaV_rel);
110
111 virtual void applyImpulse(const btVector3& impulse) {}
112
113 virtual void applySplitImpulse(const btVector3& impulse) {} // TODO: may need later
114
115 virtual btVector3 getVa() const;
116 virtual btVector3 getDeltaVa() const = 0;
117 virtual btVector3 getDeltaVb() const = 0;
118};
119
120// ================= node vs rigid constraints ===================
121 class btReducedDeformableNodeRigidContactConstraint : public btReducedDeformableRigidContactConstraint
122{
123 public:
124 btSoftBody::Node* m_node;
125
126 btReducedDeformableNodeRigidContactConstraint(btReducedDeformableBody* rsb,
127 const btSoftBody::DeformableNodeRigidContact& contact,
128 const btContactSolverInfo& infoGlobal,
129 btScalar dt);
130 // btReducedDeformableNodeRigidContactConstraint(const btReducedDeformableNodeRigidContactConstraint& other);
131 btReducedDeformableNodeRigidContactConstraint() {}
132 virtual ~btReducedDeformableNodeRigidContactConstraint() {}
133
134 virtual void warmStarting();
135
136 // get the velocity of the deformable node in contact
137 virtual btVector3 getVb() const;
138
139 // get the velocity change of the rigid body
140 virtual btVector3 getDeltaVa() const;
141
142 // get velocity change of the node in contat
143 virtual btVector3 getDeltaVb() const;
144
145 // get the split impulse velocity of the deformable face at the contact point
146 virtual btVector3 getSplitVb() const;
147
148 // get the velocity change of the input soft body node in the constraint
149 virtual btVector3 getDv(const btSoftBody::Node*) const;
150
151 // cast the contact to the desired type
152 const btSoftBody::DeformableNodeRigidContact* getContact() const
153 {
154 return static_cast<const btSoftBody::DeformableNodeRigidContact*>(m_contact);
155 }
156
157 // this calls reduced deformable body's applyFullSpaceImpulse
158 virtual void applyImpulse(const btVector3& impulse);
159};
160
161// ================= face vs rigid constraints ===================
162 class btReducedDeformableFaceRigidContactConstraint : public btReducedDeformableRigidContactConstraint
163{
164 public:
165 btSoftBody::Face* m_face;
166 bool m_useStrainLimiting;
167
168 btReducedDeformableFaceRigidContactConstraint(btReducedDeformableBody* rsb,
169 const btSoftBody::DeformableFaceRigidContact& contact,
170 const btContactSolverInfo& infoGlobal,
171 btScalar dt,
172 bool useStrainLimiting);
173 // btReducedDeformableFaceRigidContactConstraint(const btReducedDeformableFaceRigidContactConstraint& other);
174 btReducedDeformableFaceRigidContactConstraint() {}
175 virtual ~btReducedDeformableFaceRigidContactConstraint() {}
176
177 // get the velocity of the deformable face at the contact point
178 virtual btVector3 getVb() const;
179
180 // get the split impulse velocity of the deformable face at the contact point
181 virtual btVector3 getSplitVb() const;
182
183 // get the velocity change of the input soft body node in the constraint
184 virtual btVector3 getDv(const btSoftBody::Node*) const;
185
186 // cast the contact to the desired type
187 const btSoftBody::DeformableFaceRigidContact* getContact() const
188 {
189 return static_cast<const btSoftBody::DeformableFaceRigidContact*>(m_contact);
190 }
191
192 // this calls reduced deformable body's applyFullSpaceImpulse
193 virtual void applyImpulse(const btVector3& impulse);
194};
btReducedDeformableBody.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btDeformableRigidContactConstraint
Definition: btDeformableContactConstraint.h:142
btDeformableRigidContactConstraint::m_contact
const btSoftBody::DeformableRigidContact * m_contact
Definition: btDeformableContactConstraint.h:149
btDeformableStaticConstraint
Definition: btDeformableContactConstraint.h:72
btMatrix3x3
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition: btMatrix3x3.h:50
btReducedDeformableBody
Definition: btReducedDeformableBody.h:12
btReducedDeformableFaceRigidContactConstraint
Definition: btReducedDeformableContactConstraint.h:163
btReducedDeformableFaceRigidContactConstraint::getDv
virtual btVector3 getDv(const btSoftBody::Node *) const
Definition: btReducedDeformableContactConstraint.cpp:560
btReducedDeformableFaceRigidContactConstraint::btReducedDeformableFaceRigidContactConstraint
btReducedDeformableFaceRigidContactConstraint()
Definition: btReducedDeformableContactConstraint.h:174
btReducedDeformableFaceRigidContactConstraint::getSplitVb
virtual btVector3 getSplitVb() const
Definition: btReducedDeformableContactConstraint.cpp:553
btReducedDeformableFaceRigidContactConstraint::getContact
const btSoftBody::DeformableFaceRigidContact * getContact() const
Definition: btReducedDeformableContactConstraint.h:187
btReducedDeformableFaceRigidContactConstraint::m_useStrainLimiting
bool m_useStrainLimiting
Definition: btReducedDeformableContactConstraint.h:166
btReducedDeformableFaceRigidContactConstraint::getVb
virtual btVector3 getVb() const
Definition: btReducedDeformableContactConstraint.cpp:546
btReducedDeformableFaceRigidContactConstraint::~btReducedDeformableFaceRigidContactConstraint
virtual ~btReducedDeformableFaceRigidContactConstraint()
Definition: btReducedDeformableContactConstraint.h:175
btReducedDeformableFaceRigidContactConstraint::applyImpulse
virtual void applyImpulse(const btVector3 &impulse)
Definition: btReducedDeformableContactConstraint.cpp:576
btReducedDeformableFaceRigidContactConstraint::m_face
btSoftBody::Face * m_face
Definition: btReducedDeformableContactConstraint.h:165
btReducedDeformableNodeRigidContactConstraint
Definition: btReducedDeformableContactConstraint.h:122
btReducedDeformableNodeRigidContactConstraint::~btReducedDeformableNodeRigidContactConstraint
virtual ~btReducedDeformableNodeRigidContactConstraint()
Definition: btReducedDeformableContactConstraint.h:132
btReducedDeformableNodeRigidContactConstraint::getSplitVb
virtual btVector3 getSplitVb() const
Definition: btReducedDeformableContactConstraint.cpp:511
btReducedDeformableNodeRigidContactConstraint::btReducedDeformableNodeRigidContactConstraint
btReducedDeformableNodeRigidContactConstraint()
Definition: btReducedDeformableContactConstraint.h:131
btReducedDeformableNodeRigidContactConstraint::getDeltaVa
virtual btVector3 getDeltaVa() const
Definition: btReducedDeformableContactConstraint.cpp:457
btReducedDeformableNodeRigidContactConstraint::getVb
virtual btVector3 getVb() const
Definition: btReducedDeformableContactConstraint.cpp:452
btReducedDeformableNodeRigidContactConstraint::m_node
btSoftBody::Node * m_node
Definition: btReducedDeformableContactConstraint.h:124
btReducedDeformableNodeRigidContactConstraint::getDv
virtual btVector3 getDv(const btSoftBody::Node *) const
Definition: btReducedDeformableContactConstraint.cpp:516
btReducedDeformableNodeRigidContactConstraint::applyImpulse
virtual void applyImpulse(const btVector3 &impulse)
Definition: btReducedDeformableContactConstraint.cpp:521
btReducedDeformableNodeRigidContactConstraint::warmStarting
virtual void warmStarting()
Definition: btReducedDeformableContactConstraint.cpp:365
btReducedDeformableNodeRigidContactConstraint::getContact
const btSoftBody::DeformableNodeRigidContact * getContact() const
Definition: btReducedDeformableContactConstraint.h:152
btReducedDeformableNodeRigidContactConstraint::getDeltaVb
virtual btVector3 getDeltaVb() const
Definition: btReducedDeformableContactConstraint.cpp:505
btReducedDeformableRigidContactConstraint
Definition: btReducedDeformableContactConstraint.h:42
btReducedDeformableRigidContactConstraint::solveConstraint
virtual btScalar solveConstraint(const btContactSolverInfo &infoGlobal)
Definition: btReducedDeformableContactConstraint.cpp:107
btReducedDeformableRigidContactConstraint::m_collideMultibody
bool m_collideMultibody
Definition: btReducedDeformableContactConstraint.h:45
btReducedDeformableRigidContactConstraint::m_tangentImpulseFactorInv
btScalar m_tangentImpulseFactorInv
Definition: btReducedDeformableContactConstraint.h:60
btReducedDeformableRigidContactConstraint::m_collideStatic
bool m_collideStatic
Definition: btReducedDeformableContactConstraint.h:44
btReducedDeformableRigidContactConstraint::m_angularComponentNormal
btVector3 m_angularComponentNormal
Definition: btReducedDeformableContactConstraint.h:83
btReducedDeformableRigidContactConstraint::btReducedDeformableRigidContactConstraint
btReducedDeformableRigidContactConstraint()
Definition: btReducedDeformableContactConstraint.h:93
btReducedDeformableRigidContactConstraint::warmStarting
virtual void warmStarting()
Definition: btReducedDeformableContactConstraint.h:98
btReducedDeformableRigidContactConstraint::m_solverBodyId
int m_solverBodyId
Definition: btReducedDeformableContactConstraint.h:48
btReducedDeformableRigidContactConstraint::setSolverBody
void setSolverBody(const int bodyId, btSolverBody &solver_body)
Definition: btReducedDeformableContactConstraint.cpp:81
btReducedDeformableRigidContactConstraint::applySplitImpulse
virtual void applySplitImpulse(const btVector3 &impulse)
Definition: btReducedDeformableContactConstraint.h:113
btReducedDeformableRigidContactConstraint::calculateTangentialImpulse
void calculateTangentialImpulse(btScalar &deltaImpulse_tangent, btScalar &appliedImpulse, const btScalar rhs_tangent, const btScalar tangentImpulseFactorInv, const btVector3 &tangent, const btScalar lower_limit, const btScalar upper_limit, const btVector3 &deltaV_rel)
Definition: btReducedDeformableContactConstraint.cpp:290
btReducedDeformableRigidContactConstraint::m_bufferVelocityA
btVector3 m_bufferVelocityA
Definition: btReducedDeformableContactConstraint.h:80
btReducedDeformableRigidContactConstraint::m_tangentImpulseFactor
btScalar m_tangentImpulseFactor
Definition: btReducedDeformableContactConstraint.h:58
btReducedDeformableRigidContactConstraint::m_dt
btScalar m_dt
Definition: btReducedDeformableContactConstraint.h:52
btReducedDeformableRigidContactConstraint::~btReducedDeformableRigidContactConstraint
virtual ~btReducedDeformableRigidContactConstraint()
Definition: btReducedDeformableContactConstraint.h:94
btReducedDeformableRigidContactConstraint::m_angularComponentTangent
btVector3 m_angularComponentTangent
Definition: btReducedDeformableContactConstraint.h:86
btReducedDeformableRigidContactConstraint::m_rsb
btReducedDeformableBody * m_rsb
Definition: btReducedDeformableContactConstraint.h:50
btReducedDeformableRigidContactConstraint::m_linearComponentNormal
btVector3 m_linearComponentNormal
Definition: btReducedDeformableContactConstraint.h:82
btReducedDeformableRigidContactConstraint::applyImpulse
virtual void applyImpulse(const btVector3 &impulse)
Definition: btReducedDeformableContactConstraint.h:111
btReducedDeformableRigidContactConstraint::getDeltaVb
virtual btVector3 getDeltaVb() const =0
btReducedDeformableRigidContactConstraint::m_friction
btScalar m_friction
Definition: btReducedDeformableContactConstraint.h:70
btReducedDeformableRigidContactConstraint::m_contactNormalB
btVector3 m_contactNormalB
Definition: btReducedDeformableContactConstraint.h:73
btReducedDeformableRigidContactConstraint::m_cfm_friction
btScalar m_cfm_friction
Definition: btReducedDeformableContactConstraint.h:67
btReducedDeformableRigidContactConstraint::m_rhs_tangent
btScalar m_rhs_tangent
Definition: btReducedDeformableContactConstraint.h:63
btReducedDeformableRigidContactConstraint::m_contactNormalA
btVector3 m_contactNormalA
Definition: btReducedDeformableContactConstraint.h:72
btReducedDeformableRigidContactConstraint::m_tangentImpulseFactor2
btScalar m_tangentImpulseFactor2
Definition: btReducedDeformableContactConstraint.h:59
btReducedDeformableRigidContactConstraint::m_bufferVelocityB
btVector3 m_bufferVelocityB
Definition: btReducedDeformableContactConstraint.h:81
btReducedDeformableRigidContactConstraint::m_tangentImpulseFactorInv2
btScalar m_tangentImpulseFactorInv2
Definition: btReducedDeformableContactConstraint.h:61
btReducedDeformableRigidContactConstraint::m_contactTangent2
btVector3 m_contactTangent2
Definition: btReducedDeformableContactConstraint.h:75
btReducedDeformableRigidContactConstraint::m_linearComponentTangent
btVector3 m_linearComponentTangent
Definition: btReducedDeformableContactConstraint.h:85
btReducedDeformableRigidContactConstraint::m_normalImpulseFactor
btScalar m_normalImpulseFactor
Definition: btReducedDeformableContactConstraint.h:57
btReducedDeformableRigidContactConstraint::m_erp_friction
btScalar m_erp_friction
Definition: btReducedDeformableContactConstraint.h:69
btReducedDeformableRigidContactConstraint::m_nodeQueryIndex
int m_nodeQueryIndex
Definition: btReducedDeformableContactConstraint.h:47
btReducedDeformableRigidContactConstraint::m_appliedTangentImpulse
btScalar m_appliedTangentImpulse
Definition: btReducedDeformableContactConstraint.h:55
btReducedDeformableRigidContactConstraint::m_rhs
btScalar m_rhs
Definition: btReducedDeformableContactConstraint.h:62
btReducedDeformableRigidContactConstraint::m_impulseFactor
btMatrix3x3 m_impulseFactor
Definition: btReducedDeformableContactConstraint.h:78
btReducedDeformableRigidContactConstraint::m_contactTangent
btVector3 m_contactTangent
Definition: btReducedDeformableContactConstraint.h:74
btReducedDeformableRigidContactConstraint::m_relPosB
btVector3 m_relPosB
Definition: btReducedDeformableContactConstraint.h:77
btReducedDeformableRigidContactConstraint::m_cfm
btScalar m_cfm
Definition: btReducedDeformableContactConstraint.h:66
btReducedDeformableRigidContactConstraint::m_solverBody
btSolverBody * m_solverBody
Definition: btReducedDeformableContactConstraint.h:51
btReducedDeformableRigidContactConstraint::m_rhs_tangent2
btScalar m_rhs_tangent2
Definition: btReducedDeformableContactConstraint.h:64
btReducedDeformableRigidContactConstraint::m_erp
btScalar m_erp
Definition: btReducedDeformableContactConstraint.h:68
btReducedDeformableRigidContactConstraint::getDeltaVa
virtual btVector3 getDeltaVa() const =0
btReducedDeformableRigidContactConstraint::m_relPosA
btVector3 m_relPosA
Definition: btReducedDeformableContactConstraint.h:76
btReducedDeformableRigidContactConstraint::m_appliedNormalImpulse
btScalar m_appliedNormalImpulse
Definition: btReducedDeformableContactConstraint.h:54
btReducedDeformableRigidContactConstraint::m_appliedTangentImpulse2
btScalar m_appliedTangentImpulse2
Definition: btReducedDeformableContactConstraint.h:56
btReducedDeformableRigidContactConstraint::getVa
virtual btVector3 getVa() const
Definition: btReducedDeformableContactConstraint.cpp:97
btReducedDeformableStaticConstraint
Definition: btReducedDeformableContactConstraint.h:6
btReducedDeformableStaticConstraint::m_dt
btScalar m_dt
Definition: btReducedDeformableContactConstraint.h:9
btReducedDeformableStaticConstraint::m_impulseFactor
btScalar m_impulseFactor
Definition: btReducedDeformableContactConstraint.h:14
btReducedDeformableStaticConstraint::m_appliedImpulse
btScalar m_appliedImpulse
Definition: btReducedDeformableContactConstraint.h:16
btReducedDeformableStaticConstraint::m_ri
btVector3 m_ri
Definition: btReducedDeformableContactConstraint.h:10
btReducedDeformableStaticConstraint::m_rsb
btReducedDeformableBody * m_rsb
Definition: btReducedDeformableContactConstraint.h:8
btReducedDeformableStaticConstraint::m_impulseDirection
btVector3 m_impulseDirection
Definition: btReducedDeformableContactConstraint.h:12
btReducedDeformableStaticConstraint::m_erp
btScalar m_erp
Definition: btReducedDeformableContactConstraint.h:17
btReducedDeformableStaticConstraint::m_targetPos
btVector3 m_targetPos
Definition: btReducedDeformableContactConstraint.h:11
btReducedDeformableStaticConstraint::btReducedDeformableStaticConstraint
btReducedDeformableStaticConstraint()
Definition: btReducedDeformableContactConstraint.h:27
btReducedDeformableStaticConstraint::m_rhs
btScalar m_rhs
Definition: btReducedDeformableContactConstraint.h:15
btReducedDeformableStaticConstraint::applyImpulse
virtual void applyImpulse(const btVector3 &impulse)
Definition: btReducedDeformableContactConstraint.cpp:47
btReducedDeformableStaticConstraint::getDeltaVa
btVector3 getDeltaVa() const
Definition: btReducedDeformableContactConstraint.cpp:53
btReducedDeformableStaticConstraint::solveConstraint
virtual btScalar solveConstraint(const btContactSolverInfo &infoGlobal)
Definition: btReducedDeformableContactConstraint.cpp:28
btReducedDeformableStaticConstraint::~btReducedDeformableStaticConstraint
virtual ~btReducedDeformableStaticConstraint()
Definition: btReducedDeformableContactConstraint.h:28
btReducedDeformableStaticConstraint::m_impulseFactorMatrix
btMatrix3x3 m_impulseFactorMatrix
Definition: btReducedDeformableContactConstraint.h:13
btSoftBody::DeformableFaceRigidContact
Definition: btSoftBody.h:391
btSoftBody::DeformableNodeRigidContact
Definition: btSoftBody.h:379
btSoftBody::DeformableRigidContact
Definition: btSoftBody.h:360
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
btContactSolverInfo
Definition: btContactSolverInfo.h:76
btSoftBody::Face
Definition: btSoftBody.h:306
btSoftBody::Node
Definition: btSoftBody.h:268
btSolverBody
The btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packe...
Definition: btSolverBody.h:105