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"
26#include <vector>
27
29{
30 int m_num_constraints; // Number of constraints
31 int m_num_nodes; // Number of nodes in these constraints
32 btScalar m_weights[3]; // weights of the nodes involved, same size as m_num_nodes
33 btVector3 m_dirs[3]; // Constraint directions, same size of m_num_constraints;
34 int m_indices[3]; // indices of the nodes involved, same size as m_num_nodes;
35};
36
38{
39public:
42
43 // all constraints involving face
45#ifndef USE_MGS
46 // map from node index to projection directions
48#else
50#endif
51
53
54 // map from node index to static constraint
56 // map from node index to node rigid constraint
58 // map from node index to face rigid constraint
60 // map from node index to deformable constraint
62 // map from node index to node anchor constraint
64
66
68 : m_softBodies(softBodies)
69 {
70 }
71
73 {
74 }
75
76 // apply the constraints to the rhs of the linear solve
77 virtual void project(TVStack& x);
78
79 // add friction force to the rhs of the linear solve
80 virtual void applyDynamicFriction(TVStack& f);
81
82 // update and solve the constraints
83 virtual btScalar update(btCollisionObject** deformableBodies, int numDeformableBodies, const btContactSolverInfo& infoGlobal);
84
85 // Add constraints to m_constraints. In addition, the constraints that each vertex own are recorded in m_constraintsDict.
86 virtual void setConstraints(const btContactSolverInfo& infoGlobal);
87
88 // Set up projections for each vertex by adding the projection direction to
89 virtual void setProjection();
90
91 virtual void reinitialize(bool nodeUpdated);
92
93 btScalar solveSplitImpulse(btCollisionObject** deformableBodies, int numDeformableBodies, const btContactSolverInfo& infoGlobal);
94
95 virtual void setLagrangeMultiplier();
96
97 void checkConstraints(const TVStack& x);
98};
99#endif /* btDeformableContactProjection_h */
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btCollisionObject can be used to manage collision detection objects.
virtual btScalar update(btCollisionObject **deformableBodies, int numDeformableBodies, const btContactSolverInfo &infoGlobal)
btAlignedObjectArray< LagrangeMultiplier > m_lagrangeMultipliers
virtual void setConstraints(const btContactSolverInfo &infoGlobal)
virtual void reinitialize(bool nodeUpdated)
btAlignedObjectArray< btSoftBody * > & m_softBodies
btAlignedObjectArray< btAlignedObjectArray< btDeformableFaceNodeContactConstraint > > m_deformableConstraints
btDeformableContactProjection(btAlignedObjectArray< btSoftBody * > &softBodies)
btScalar solveSplitImpulse(btCollisionObject **deformableBodies, int numDeformableBodies, const btContactSolverInfo &infoGlobal)
btAlignedObjectArray< btAlignedObjectArray< btDeformableNodeRigidContactConstraint > > m_nodeRigidConstraints
btAlignedObjectArray< btVector3 > TVStack
btHashMap< btHashInt, btAlignedObjectArray< btVector3 > > m_projectionsDict
btAlignedObjectArray< btAlignedObjectArray< btDeformableStaticConstraint > > m_staticConstraints
btAlignedObjectArray< btAlignedObjectArray< btDeformableFaceRigidContactConstraint > > m_faceRigidConstraints
btAlignedObjectArray< btAlignedObjectArray< btDeformableNodeAnchorConstraint > > m_nodeAnchorConstraints
btAlignedObjectArray< btDeformableContactConstraint * > m_allFaceConstraints
The btHashMap template class implements a generic and lightweight hashmap.
Definition: btHashMap.h:220
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82