Bullet Collision Detection & Physics Library
btMultiBodyInplaceSolverIslandCallback.h
Go to the documentation of this file.
1/*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2019 Google Inc. http://bulletphysics.org
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose,
7 including commercial applications, and to alter it and redistribute it freely,
8 subject to the following restrictions:
9 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.
10 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
11 3. This notice may not be removed or altered from any source distribution.
12 */
13
14#ifndef BT_MULTIBODY_INPLACE_SOLVER_ISLAND_CALLBACK_H
15#define BT_MULTIBODY_INPLACE_SOLVER_ISLAND_CALLBACK_H
16
21
23{
24 int islandId;
25
26 const btCollisionObject& rcolObj0 = lhs->getRigidBodyA();
27 const btCollisionObject& rcolObj1 = lhs->getRigidBodyB();
28 islandId = rcolObj0.getIslandTag() >= 0 ? rcolObj0.getIslandTag() : rcolObj1.getIslandTag();
29 return islandId;
30}
32{
33public:
35 {
39 return lIslandId0 < rIslandId0;
40 }
41};
42
44{
45 int islandId;
46
47 int islandTagA = lhs->getIslandIdA();
48 int islandTagB = lhs->getIslandIdB();
50 return islandId;
51}
52
54{
55public:
57 {
61 return lIslandId0 < rIslandId0;
62 }
63};
64
66{
67
72
77
83
85
89 m_solver(solver),
94 {
95 }
96
98 {
99 btAssert(0);
100 (void)other;
101 return *this;
102 }
103
105 {
109
113 m_numConstraints = numConstraints;
114
116 m_bodies.resize(0);
120 }
121
123 {
124 m_solver = solver;
125 }
126
127 virtual void processIsland(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifolds, int numManifolds, int islandId)
128 {
129 if (islandId < 0)
130 {
134 {
137 }
138 }
139 else
140 {
141 //also add all non-contact constraints/joints for this island
144
145 int numCurConstraints = 0;
147
148 int i;
149
150 //find the first constraint for this island
151
152 for (i = 0; i < m_numConstraints; i++)
153 {
155 {
157 break;
158 }
159 }
160 //count the number of constraints in this island
161 for (; i < m_numConstraints; i++)
162 {
164 {
166 }
167 }
168
169 for (i = 0; i < m_numMultiBodyConstraints; i++)
170 {
172 {
174 break;
175 }
176 }
177 //count the number of multi body constraints in this island
178 for (; i < m_numMultiBodyConstraints; i++)
179 {
181 {
183 }
184 }
185
186 //if (m_solverInfo->m_minimumSolverBatchSize<=1)
187 //{
188 // m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher);
189 //} else
190 {
191 for (i = 0; i < numBodies; i++)
192 {
194 if (!isSoftBodyType)
195 {
196 m_bodies.push_back(bodies[i]);
197 }
198 else
199 {
200 m_softBodies.push_back(bodies[i]);
201 }
202 }
203 for (i = 0; i < numManifolds; i++)
205 for (i = 0; i < numCurConstraints; i++)
207
208 for (i = 0; i < numCurMultiBodyConstraints; i++)
210
212 {
214 }
215 else
216 {
217 //printf("deferred\n");
218 }
219 }
220 }
221 }
222
223 virtual void processConstraints(int islandId=-1)
224 {
225 btCollisionObject** bodies = m_bodies.size() ? &m_bodies[0] : 0;
229
230 //printf("mb contacts = %d, mb constraints = %d\n", mbContacts, m_multiBodyConstraints.size());
231
234 {
237 }
238 m_bodies.resize(0);
243 }
244};
245
246
247#endif /*BT_MULTIBODY_INPLACE_SOLVER_ISLAND_CALLBACK_H */
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:27
int btGetConstraintIslandId2(const btTypedConstraint *lhs)
int btGetMultiBodyConstraintIslandId(const btMultiBodyConstraint *lhs)
#define SIMD_FORCE_INLINE
Definition btScalar.h:98
#define btAssert(x)
Definition btScalar.h:153
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
int size() const
return the number of elements in the array
void resize(int newsize, const T &fillData=T())
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0),...
void push_back(const T &_Val)
btCollisionObject can be used to manage collision detection objects.
int getInternalType() const
reserved for Bullet internal usage
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
virtual void solveMultiBodyGroup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifold, int numManifolds, btTypedConstraint **constraints, int numConstraints, btMultiBodyConstraint **multiBodyConstraints, int numMultiBodyConstraints, const btContactSolverInfo &info, btIDebugDraw *debugDrawer, btDispatcher *dispatcher)
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
bool operator()(const btTypedConstraint *lhs, const btTypedConstraint *rhs) const
bool operator()(const btMultiBodyConstraint *lhs, const btMultiBodyConstraint *rhs) const
TypedConstraint is the baseclass for Bullet constraints and vehicles.
btAlignedObjectArray< btTypedConstraint * > m_constraints
virtual void setup(btContactSolverInfo *solverInfo, btTypedConstraint **sortedConstraints, int numConstraints, btMultiBodyConstraint **sortedMultiBodyConstraints, int numMultiBodyConstraints, btIDebugDraw *debugDrawer)
btAlignedObjectArray< btMultiBodyConstraint * > m_multiBodyConstraints
virtual void processIsland(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifolds, int numManifolds, int islandId)
void setMultiBodyConstraintSolver(btMultiBodyConstraintSolver *solver)
btAlignedObjectArray< btPersistentManifold * > m_manifolds
MultiBodyInplaceSolverIslandCallback & operator=(const MultiBodyInplaceSolverIslandCallback &other)
btAlignedObjectArray< btCollisionObject * > m_bodies
btAlignedObjectArray< btSolverAnalyticsData > m_islandAnalyticsData
btAlignedObjectArray< btCollisionObject * > m_softBodies
MultiBodyInplaceSolverIslandCallback(btMultiBodyConstraintSolver *solver, btDispatcher *dispatcher)