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

Bullet Collision Detection & Physics Library

btDeformableContactProjection.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_CONTACT_PROJECTION_H
17 #define BT_CONTACT_PROJECTION_H
18 #include "btCGProjection.h"
19 #include "btSoftBody.h"
20 #include "BulletDynamics/Featherstone/btMultiBodyLinkCollider.h"
21 #include "BulletDynamics/Featherstone/btMultiBodyConstraint.h"
22 #include "btDeformableContactConstraint.h"
23 #include "LinearMath/btHashMap.h"
24 #include <vector>
25 class btDeformableContactProjection
26 {
27 public:
28 typedef btAlignedObjectArray<btVector3> TVStack;
29 btAlignedObjectArray<btSoftBody *>& m_softBodies;
30
31 // // map from node index to static constraint
32 // btHashMap<btHashInt, btDeformableStaticConstraint> m_staticConstraints;
33 // // map from node index to node rigid constraint
34 // btHashMap<btHashInt, btAlignedObjectArray<btDeformableNodeRigidContactConstraint> > m_nodeRigidConstraints;
35 // // map from node index to face rigid constraint
36 // btHashMap<btHashInt, btAlignedObjectArray<btDeformableFaceRigidContactConstraint*> > m_faceRigidConstraints;
37 // // map from node index to deformable constraint
38 // btHashMap<btHashInt, btAlignedObjectArray<btDeformableFaceNodeContactConstraint*> > m_deformableConstraints;
39 // // map from node index to node anchor constraint
40 // btHashMap<btHashInt, btDeformableNodeAnchorConstraint> m_nodeAnchorConstraints;
41
42 // all constraints involving face
43 btAlignedObjectArray<btDeformableContactConstraint*> m_allFaceConstraints;
44
45 // map from node index to projection directions
46 btHashMap<btHashInt, btAlignedObjectArray<btVector3> > m_projectionsDict;
47
48 // map from node index to static constraint
49 btAlignedObjectArray<btAlignedObjectArray<btDeformableStaticConstraint> > m_staticConstraints;
50 // map from node index to node rigid constraint
51 btAlignedObjectArray<btAlignedObjectArray<btDeformableNodeRigidContactConstraint> > m_nodeRigidConstraints;
52 // map from node index to face rigid constraint
53 btAlignedObjectArray<btAlignedObjectArray<btDeformableFaceRigidContactConstraint> > m_faceRigidConstraints;
54 // map from node index to deformable constraint
55 btAlignedObjectArray<btAlignedObjectArray<btDeformableFaceNodeContactConstraint> > m_deformableConstraints;
56 // map from node index to node anchor constraint
57 btAlignedObjectArray<btAlignedObjectArray<btDeformableNodeAnchorConstraint> > m_nodeAnchorConstraints;
58
59 btDeformableContactProjection(btAlignedObjectArray<btSoftBody *>& softBodies)
60 : m_softBodies(softBodies)
61 {
62 }
63
64 virtual ~btDeformableContactProjection()
65 {
66 }
67
68 // apply the constraints to the rhs of the linear solve
69 virtual void project(TVStack& x);
70
71 // add friction force to the rhs of the linear solve
72 virtual void applyDynamicFriction(TVStack& f);
73
74 // update and solve the constraints
75 virtual btScalar update(btCollisionObject** deformableBodies,int numDeformableBodies);
76
77 // solve the position error using split impulse
78 virtual btScalar solveSplitImpulse(const btContactSolverInfo& infoGlobal);
79
80 // Add constraints to m_constraints. In addition, the constraints that each vertex own are recorded in m_constraintsDict.
81 virtual void setConstraints();
82
83 // Set up projections for each vertex by adding the projection direction to
84 virtual void setProjection();
85
86 virtual void reinitialize(bool nodeUpdated);
87
88 virtual void splitImpulseSetup(const btContactSolverInfo& infoGlobal);
89 };
90 #endif /* btDeformableContactProjection_h */
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:50
btDeformableContactProjection::m_staticConstraints
btAlignedObjectArray< btAlignedObjectArray< btDeformableStaticConstraint > > m_staticConstraints
Definition: btDeformableContactProjection.h:49
btDeformableContactProjection::reinitialize
virtual void reinitialize(bool nodeUpdated)
Definition: btDeformableContactProjection.cpp:485
btContactSolverInfo
Definition: btContactSolverInfo.h:73
btDeformableContactProjection::setConstraints
virtual void setConstraints()
Definition: btDeformableContactProjection.cpp:111
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btDeformableContactProjection
Definition: btDeformableContactProjection.h:26
btDeformableContactProjection::update
virtual btScalar update(btCollisionObject **deformableBodies, int numDeformableBodies)
Definition: btDeformableContactProjection.cpp:20
btDeformableContactProjection::applyDynamicFriction
virtual void applyDynamicFriction(TVStack &f)
Definition: btDeformableContactProjection.cpp:434
btDeformableContactProjection::setProjection
virtual void setProjection()
Definition: btDeformableContactProjection.cpp:244
btDeformableContactProjection::m_faceRigidConstraints
btAlignedObjectArray< btAlignedObjectArray< btDeformableFaceRigidContactConstraint > > m_faceRigidConstraints
Definition: btDeformableContactProjection.h:53
btDeformableContactProjection::~btDeformableContactProjection
virtual ~btDeformableContactProjection()
Definition: btDeformableContactProjection.h:64
btDeformableContactProjection::TVStack
btAlignedObjectArray< btVector3 > TVStack
Definition: btDeformableContactProjection.h:28
btHashMap
The btHashMap template class implements a generic and lightweight hashmap.
Definition: btHashMap.h:220
btDeformableContactProjection::m_projectionsDict
btHashMap< btHashInt, btAlignedObjectArray< btVector3 > > m_projectionsDict
Definition: btDeformableContactProjection.h:46
btDeformableContactProjection::m_nodeRigidConstraints
btAlignedObjectArray< btAlignedObjectArray< btDeformableNodeRigidContactConstraint > > m_nodeRigidConstraints
Definition: btDeformableContactProjection.h:51
btMultiBodyLinkCollider.h
btDeformableContactConstraint.h
btDeformableContactProjection::solveSplitImpulse
virtual btScalar solveSplitImpulse(const btContactSolverInfo &infoGlobal)
Definition: btDeformableContactProjection.cpp:80
btDeformableContactProjection::project
virtual void project(TVStack &x)
Definition: btDeformableContactProjection.cpp:206
btDeformableContactProjection::splitImpulseSetup
virtual void splitImpulseSetup(const btContactSolverInfo &infoGlobal)
Definition: btDeformableContactProjection.cpp:61
btAlignedObjectArray< btVector3 >
btHashMap.h
btCGProjection.h
btDeformableContactProjection::m_nodeAnchorConstraints
btAlignedObjectArray< btAlignedObjectArray< btDeformableNodeAnchorConstraint > > m_nodeAnchorConstraints
Definition: btDeformableContactProjection.h:57
btDeformableContactProjection::btDeformableContactProjection
btDeformableContactProjection(btAlignedObjectArray< btSoftBody * > &softBodies)
Definition: btDeformableContactProjection.h:59
btDeformableContactProjection::m_allFaceConstraints
btAlignedObjectArray< btDeformableContactConstraint * > m_allFaceConstraints
Definition: btDeformableContactProjection.h:43
btMultiBodyConstraint.h
btDeformableContactProjection::m_softBodies
btAlignedObjectArray< btSoftBody * > & m_softBodies
Definition: btDeformableContactProjection.h:29
btSoftBody.h
btDeformableContactProjection::m_deformableConstraints
btAlignedObjectArray< btAlignedObjectArray< btDeformableFaceNodeContactConstraint > > m_deformableConstraints
Definition: btDeformableContactProjection.h:55