Bullet Collision Detection & Physics Library
btDeformableContactConstraint.h
Go to the documentation of this file.
1/*
2 Written by Xuchen Han <xuchenhan2015@u.northwestern.edu>
3
4 Bullet Continuous Collision Detection and Physics Library
5 Copyright (c) 2019 Google Inc. http://bulletphysics.org
6 This software is provided 'as-is', without any express or implied warranty.
7 In no event will the authors be held liable for any damages arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it freely,
10 subject to the following restrictions:
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16#ifndef BT_DEFORMABLE_CONTACT_CONSTRAINT_H
17#define BT_DEFORMABLE_CONTACT_CONSTRAINT_H
18#include "btSoftBody.h"
19
20// btDeformableContactConstraint is an abstract class specifying the method that each type of contact constraint needs to implement
22{
23public:
24 // True if the friction is static
25 // False if the friction is dynamic
27
28 // normal of the contact
30
32 {
33 }
34
35 btDeformableContactConstraint(bool isStatic, const btVector3& normal): m_static(isStatic), m_normal(normal)
36 {
37 }
38
40 : m_static(other.m_static)
41 , m_normal(other.m_normal)
42 {
43
44 }
46
48
49 // solve the constraint with inelastic impulse and return the error, which is the square of normal component of velocity diffrerence
50 // the constraint is solved by calculating the impulse between object A and B in the contact and apply the impulse to both objects involved in the contact
52
53 // solve the position error by applying an inelastic impulse that changes only the position (not velocity)
54 virtual btScalar solveSplitImpulse(const btContactSolverInfo& infoGlobal) = 0;
55
56 // get the velocity of the object A in the contact
57 virtual btVector3 getVa() const = 0;
58
59 // get the velocity of the object B in the contact
60 virtual btVector3 getVb() const = 0;
61
62 // get the velocity change of the soft body node in the constraint
63 virtual btVector3 getDv(const btSoftBody::Node*) const = 0;
64
65 // apply impulse to the soft body node and/or face involved
66 virtual void applyImpulse(const btVector3& impulse) = 0;
67
68 // apply position based impulse to the soft body node and/or face involved
69 virtual void applySplitImpulse(const btVector3& impulse) = 0;
70
71 // scale the penetration depth by erp
72 virtual void setPenetrationScale(btScalar scale) = 0;
73};
74
75//
76// Constraint that a certain node in the deformable objects cannot move
78{
79public:
81
83
85 {
86 }
87
89 : m_node(other.m_node)
91 {
92
93 }
94
96
98 {
99 return 0;
100 }
101
103 {
104 return 0;
105 }
106
107 virtual btVector3 getVa() const
108 {
109 return btVector3(0,0,0);
110 }
111
112 virtual btVector3 getVb() const
113 {
114 return btVector3(0,0,0);
115 }
116
117 virtual btVector3 getDv(const btSoftBody::Node* n) const
118 {
119 return btVector3(0,0,0);
120 }
121
122 virtual void applyImpulse(const btVector3& impulse){}
123 virtual void applySplitImpulse(const btVector3& impulse){}
124 virtual void setPenetrationScale(btScalar scale){}
125};
126
127//
128// Anchor Constraint between rigid and deformable node
130{
131public:
133
138 {
139 }
140 virtual btScalar solveConstraint();
142 {
143 // todo xuchenhan@
144 return 0;
145 }
146 // object A is the rigid/multi body, and object B is the deformable node/face
147 virtual btVector3 getVa() const;
148 // get the velocity of the deformable node in contact
149 virtual btVector3 getVb() const;
150 virtual btVector3 getDv(const btSoftBody::Node* n) const
151 {
152 return btVector3(0,0,0);
153 }
154 virtual void applyImpulse(const btVector3& impulse);
155 virtual void applySplitImpulse(const btVector3& impulse)
156 {
157 // todo xuchenhan@
158 };
159 virtual void setPenetrationScale(btScalar scale){}
160};
161
162
163//
164// Constraint between rigid/multi body and deformable objects
166{
167public:
172
177 {
178 }
179
180 // object A is the rigid/multi body, and object B is the deformable node/face
181 virtual btVector3 getVa() const;
182
183 virtual btScalar solveConstraint();
184
185 virtual btScalar solveSplitImpulse(const btContactSolverInfo& infoGlobal);
186
187 virtual void setPenetrationScale(btScalar scale)
188 {
189 m_penetration *= scale;
190 }
191};
192
193//
194// Constraint between rigid/multi body and deformable objects nodes
196{
197public:
198 // the deformable node in contact
200
204
206 {
207 }
208
209 // get the velocity of the deformable node in contact
210 virtual btVector3 getVb() const;
211
212 // get the velocity change of the input soft body node in the constraint
213 virtual btVector3 getDv(const btSoftBody::Node*) const;
214
215 // cast the contact to the desired type
217 {
218 return static_cast<const btSoftBody::DeformableNodeRigidContact*>(m_contact);
219 }
220
221 virtual void applyImpulse(const btVector3& impulse);
222 virtual void applySplitImpulse(const btVector3& impulse);
223};
224
225//
226// Constraint between rigid/multi body and deformable objects faces
228{
229public:
234
236 {
237 }
238
239 // get the velocity of the deformable face at the contact point
240 virtual btVector3 getVb() const;
241
242 // get the velocity change of the input soft body node in the constraint
243 virtual btVector3 getDv(const btSoftBody::Node*) const;
244
245 // cast the contact to the desired type
247 {
248 return static_cast<const btSoftBody::DeformableFaceRigidContact*>(m_contact);
249 }
250
251 virtual void applyImpulse(const btVector3& impulse);
252 virtual void applySplitImpulse(const btVector3& impulse);
253};
254
255//
256// Constraint between deformable objects faces and deformable objects nodes
258{
259public:
265
267
269
271
272 virtual btScalar solveConstraint();
273
275 {
276 // todo: xuchenhan@
277 return 0;
278 }
279
280 // get the velocity of the object A in the contact
281 virtual btVector3 getVa() const;
282
283 // get the velocity of the object B in the contact
284 virtual btVector3 getVb() const;
285
286 // get the velocity change of the input soft body node in the constraint
287 virtual btVector3 getDv(const btSoftBody::Node*) const;
288
289 // cast the contact to the desired type
291 {
292 return static_cast<const btSoftBody::DeformableFaceNodeContact*>(m_contact);
293 }
294
295 virtual void applyImpulse(const btVector3& impulse);
296 virtual void applySplitImpulse(const btVector3& impulse)
297 {
298 // todo xuchenhan@
299 }
300 virtual void setPenetrationScale(btScalar scale){}
301};
302#endif /* BT_DEFORMABLE_CONTACT_CONSTRAINT_H */
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btDeformableContactConstraint(bool isStatic, const btVector3 &normal)
virtual btScalar solveSplitImpulse(const btContactSolverInfo &infoGlobal)=0
virtual btScalar solveConstraint()=0
virtual void setPenetrationScale(btScalar scale)=0
virtual void applySplitImpulse(const btVector3 &impulse)=0
btDeformableContactConstraint(const btDeformableContactConstraint &other)
virtual btVector3 getVb() const =0
virtual btVector3 getDv(const btSoftBody::Node *) const =0
btDeformableContactConstraint(const btVector3 &normal)
virtual void applyImpulse(const btVector3 &impulse)=0
virtual btVector3 getVa() const =0
virtual void applyImpulse(const btVector3 &impulse)
const btSoftBody::DeformableFaceNodeContact * m_contact
virtual btScalar solveSplitImpulse(const btContactSolverInfo &infoGlobal)
virtual btVector3 getDv(const btSoftBody::Node *) const
const btSoftBody::DeformableFaceNodeContact * getContact() const
virtual void applySplitImpulse(const btVector3 &impulse)
virtual void applySplitImpulse(const btVector3 &impulse)
const btSoftBody::DeformableFaceRigidContact * getContact() const
virtual btVector3 getDv(const btSoftBody::Node *) const
virtual void applyImpulse(const btVector3 &impulse)
virtual btScalar solveSplitImpulse(const btContactSolverInfo &infoGlobal)
virtual void applySplitImpulse(const btVector3 &impulse)
virtual void setPenetrationScale(btScalar scale)
virtual btVector3 getDv(const btSoftBody::Node *n) const
virtual void applyImpulse(const btVector3 &impulse)
const btSoftBody::DeformableNodeRigidAnchor * m_anchor
virtual void applySplitImpulse(const btVector3 &impulse)
virtual void applyImpulse(const btVector3 &impulse)
virtual btVector3 getDv(const btSoftBody::Node *) const
const btSoftBody::DeformableNodeRigidContact * getContact() const
virtual void setPenetrationScale(btScalar scale)
virtual btScalar solveSplitImpulse(const btContactSolverInfo &infoGlobal)
const btSoftBody::DeformableRigidContact * m_contact
virtual btVector3 getDv(const btSoftBody::Node *n) const
virtual void applyImpulse(const btVector3 &impulse)
btDeformableStaticConstraint(const btSoftBody::Node *node)
btDeformableStaticConstraint(const btDeformableStaticConstraint &other)
virtual btScalar solveSplitImpulse(const btContactSolverInfo &infoGlobal)
virtual void applySplitImpulse(const btVector3 &impulse)
virtual void setPenetrationScale(btScalar scale)
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82