Bullet Collision Detection & Physics Library: btMultiBodyDynamicsWorld.cpp Source File

Bullet Collision Detection & Physics Library

btMultiBodyDynamicsWorld.cpp
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#include "btMultiBodyDynamicsWorld.h"
17#include "btMultiBodyConstraintSolver.h"
18#include "btMultiBody.h"
19#include "btMultiBodyLinkCollider.h"
20#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
21#include "LinearMath/btQuickprof.h"
22#include "btMultiBodyConstraint.h"
23#include "LinearMath/btIDebugDraw.h"
24#include "LinearMath/btSerializer.h"
25
26 void btMultiBodyDynamicsWorld::addMultiBody(btMultiBody* body, int group, int mask)
27{
28 m_multiBodies.push_back(body);
29}
30
31 void btMultiBodyDynamicsWorld::removeMultiBody(btMultiBody* body)
32{
33 m_multiBodies.remove(body);
34}
35
36 void btMultiBodyDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
37{
38 btDiscreteDynamicsWorld::predictUnconstraintMotion(timeStep);
39 predictMultiBodyTransforms(timeStep);
40
41}
42 void btMultiBodyDynamicsWorld::calculateSimulationIslands()
43{
44 BT_PROFILE("calculateSimulationIslands");
45
46 getSimulationIslandManager()->updateActivationState(getCollisionWorld(), getCollisionWorld()->getDispatcher());
47
48 {
49 //merge islands based on speculative contact manifolds too
50 for (int i = 0; i < this->m_predictiveManifolds.size(); i++)
51 {
52 btPersistentManifold* manifold = m_predictiveManifolds[i];
53
54 const btCollisionObject* colObj0 = manifold->getBody0();
55 const btCollisionObject* colObj1 = manifold->getBody1();
56
57 if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
58 ((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
59 {
60 getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(), (colObj1)->getIslandTag());
61 }
62 }
63 }
64
65 {
66 int i;
67 int numConstraints = int(m_constraints.size());
68 for (i = 0; i < numConstraints; i++)
69 {
70 btTypedConstraint* constraint = m_constraints[i];
71 if (constraint->isEnabled())
72 {
73 const btRigidBody* colObj0 = &constraint->getRigidBodyA();
74 const btRigidBody* colObj1 = &constraint->getRigidBodyB();
75
76 if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
77 ((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
78 {
79 getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(), (colObj1)->getIslandTag());
80 }
81 }
82 }
83 }
84
85 //merge islands linked by Featherstone link colliders
86 for (int i = 0; i < m_multiBodies.size(); i++)
87 {
88 btMultiBody* body = m_multiBodies[i];
89 {
90 btMultiBodyLinkCollider* prev = body->getBaseCollider();
91
92 for (int b = 0; b < body->getNumLinks(); b++)
93 {
94 btMultiBodyLinkCollider* cur = body->getLink(b).m_collider;
95
96 if (((cur) && (!(cur)->isStaticOrKinematicObject())) &&
97 ((prev) && (!(prev)->isStaticOrKinematicObject())))
98 {
99 int tagPrev = prev->getIslandTag();
100 int tagCur = cur->getIslandTag();
101 getSimulationIslandManager()->getUnionFind().unite(tagPrev, tagCur);
102 }
103 if (cur && !cur->isStaticOrKinematicObject())
104 prev = cur;
105 }
106 }
107 }
108
109 //merge islands linked by multibody constraints
110 {
111 for (int i = 0; i < this->m_multiBodyConstraints.size(); i++)
112 {
113 btMultiBodyConstraint* c = m_multiBodyConstraints[i];
114 int tagA = c->getIslandIdA();
115 int tagB = c->getIslandIdB();
116 if (tagA >= 0 && tagB >= 0)
117 getSimulationIslandManager()->getUnionFind().unite(tagA, tagB);
118 }
119 }
120
121 //Store the island id in each body
122 getSimulationIslandManager()->storeIslandActivationState(getCollisionWorld());
123}
124
125 void btMultiBodyDynamicsWorld::updateActivationState(btScalar timeStep)
126{
127 BT_PROFILE("btMultiBodyDynamicsWorld::updateActivationState");
128
129 for (int i = 0; i < m_multiBodies.size(); i++)
130 {
131 btMultiBody* body = m_multiBodies[i];
132 if (body)
133 {
134 body->checkMotionAndSleepIfRequired(timeStep);
135 if (!body->isAwake())
136 {
137 btMultiBodyLinkCollider* col = body->getBaseCollider();
138 if (col && col->getActivationState() == ACTIVE_TAG)
139 {
140 if (body->hasFixedBase())
141 {
142 col->setActivationState(FIXED_BASE_MULTI_BODY);
143 } else
144 {
145 col->setActivationState(WANTS_DEACTIVATION);
146 }
147
148 col->setDeactivationTime(0.f);
149 }
150 for (int b = 0; b < body->getNumLinks(); b++)
151 {
152 btMultiBodyLinkCollider* col = body->getLink(b).m_collider;
153 if (col && col->getActivationState() == ACTIVE_TAG)
154 {
155 col->setActivationState(WANTS_DEACTIVATION);
156 col->setDeactivationTime(0.f);
157 }
158 }
159 }
160 else
161 {
162 btMultiBodyLinkCollider* col = body->getBaseCollider();
163 if (col && col->getActivationState() != DISABLE_DEACTIVATION)
164 col->setActivationState(ACTIVE_TAG);
165
166 for (int b = 0; b < body->getNumLinks(); b++)
167 {
168 btMultiBodyLinkCollider* col = body->getLink(b).m_collider;
169 if (col && col->getActivationState() != DISABLE_DEACTIVATION)
170 col->setActivationState(ACTIVE_TAG);
171 }
172 }
173 }
174 }
175
176 btDiscreteDynamicsWorld::updateActivationState(timeStep);
177}
178
179 void btMultiBodyDynamicsWorld::getAnalyticsData(btAlignedObjectArray<btSolverAnalyticsData>& islandAnalyticsData) const
180{
181 islandAnalyticsData = m_solverMultiBodyIslandCallback->m_islandAnalyticsData;
182}
183
184btMultiBodyDynamicsWorld::btMultiBodyDynamicsWorld(btDispatcher* dispatcher, btBroadphaseInterface* pairCache, btMultiBodyConstraintSolver* constraintSolver, btCollisionConfiguration* collisionConfiguration)
185 : btDiscreteDynamicsWorld(dispatcher, pairCache, constraintSolver, collisionConfiguration),
186 m_multiBodyConstraintSolver(constraintSolver)
187{
188 //split impulse is not yet supported for Featherstone hierarchies
189 // getSolverInfo().m_splitImpulse = false;
190 getSolverInfo().m_solverMode |= SOLVER_USE_2_FRICTION_DIRECTIONS;
191 m_solverMultiBodyIslandCallback = new MultiBodyInplaceSolverIslandCallback(constraintSolver, dispatcher);
192}
193
194btMultiBodyDynamicsWorld::~btMultiBodyDynamicsWorld()
195{
196 delete m_solverMultiBodyIslandCallback;
197}
198
199 void btMultiBodyDynamicsWorld::setMultiBodyConstraintSolver(btMultiBodyConstraintSolver* solver)
200{
201 m_multiBodyConstraintSolver = solver;
202 m_solverMultiBodyIslandCallback->setMultiBodyConstraintSolver(solver);
203 btDiscreteDynamicsWorld::setConstraintSolver(solver);
204}
205
206 void btMultiBodyDynamicsWorld::setConstraintSolver(btConstraintSolver* solver)
207{
208 if (solver->getSolverType() == BT_MULTIBODY_SOLVER)
209 {
210 m_multiBodyConstraintSolver = (btMultiBodyConstraintSolver*)solver;
211 }
212 btDiscreteDynamicsWorld::setConstraintSolver(solver);
213}
214
215 void btMultiBodyDynamicsWorld::forwardKinematics()
216{
217 for (int b = 0; b < m_multiBodies.size(); b++)
218 {
219 btMultiBody* bod = m_multiBodies[b];
220 bod->forwardKinematics(m_scratch_world_to_local, m_scratch_local_origin);
221 }
222}
223 void btMultiBodyDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo)
224{
225 solveExternalForces(solverInfo);
226 buildIslands();
227 solveInternalConstraints(solverInfo);
228}
229
230 void btMultiBodyDynamicsWorld::buildIslands()
231{
232 m_islandManager->buildAndProcessIslands(getCollisionWorld()->getDispatcher(), getCollisionWorld(), m_solverMultiBodyIslandCallback);
233}
234
235 void btMultiBodyDynamicsWorld::solveInternalConstraints(btContactSolverInfo& solverInfo)
236{
238 m_solverMultiBodyIslandCallback->processConstraints();
239 m_constraintSolver->allSolved(solverInfo, m_debugDrawer);
240 {
241 BT_PROFILE("btMultiBody stepVelocities");
242 for (int i = 0; i < this->m_multiBodies.size(); i++)
243 {
244 btMultiBody* bod = m_multiBodies[i];
245
246 bool isSleeping = false;
247
248 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
249 {
250 isSleeping = true;
251 }
252 for (int b = 0; b < bod->getNumLinks(); b++)
253 {
254 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
255 isSleeping = true;
256 }
257
258 if (!isSleeping)
259 {
260 //useless? they get resized in stepVelocities once again (AND DIFFERENTLY)
261 m_scratch_r.resize(bod->getNumLinks() + 1); //multidof? ("Y"s use it and it is used to store qdd)
262 m_scratch_v.resize(bod->getNumLinks() + 1);
263 m_scratch_m.resize(bod->getNumLinks() + 1);
264
265 if (bod->internalNeedsJointFeedback())
266 {
267 if (!bod->isUsingRK4Integration())
268 {
269 if (bod->internalNeedsJointFeedback())
270 {
271 bool isConstraintPass = true;
272 bod->computeAccelerationsArticulatedBodyAlgorithmMultiDof(solverInfo.m_timeStep, m_scratch_r, m_scratch_v, m_scratch_m, isConstraintPass,
273 getSolverInfo().m_jointFeedbackInWorldSpace,
274 getSolverInfo().m_jointFeedbackInJointFrame);
275 }
276 }
277 }
278 }
279 }
280 }
281 for (int i = 0; i < this->m_multiBodies.size(); i++)
282 {
283 btMultiBody* bod = m_multiBodies[i];
284 bod->processDeltaVeeMultiDof2();
285 }
286}
287
288 void btMultiBodyDynamicsWorld::solveExternalForces(btContactSolverInfo& solverInfo)
289{
290 forwardKinematics();
291
292 BT_PROFILE("solveConstraints");
293
294 clearMultiBodyConstraintForces();
295
296 m_sortedConstraints.resize(m_constraints.size());
297 int i;
298 for (i = 0; i < getNumConstraints(); i++)
299 {
300 m_sortedConstraints[i] = m_constraints[i];
301 }
302 m_sortedConstraints.quickSort(btSortConstraintOnIslandPredicate2());
303 btTypedConstraint** constraintsPtr = getNumConstraints() ? &m_sortedConstraints[0] : 0;
304
305 m_sortedMultiBodyConstraints.resize(m_multiBodyConstraints.size());
306 for (i = 0; i < m_multiBodyConstraints.size(); i++)
307 {
308 m_sortedMultiBodyConstraints[i] = m_multiBodyConstraints[i];
309 }
310 m_sortedMultiBodyConstraints.quickSort(btSortMultiBodyConstraintOnIslandPredicate());
311
312 btMultiBodyConstraint** sortedMultiBodyConstraints = m_sortedMultiBodyConstraints.size() ? &m_sortedMultiBodyConstraints[0] : 0;
313
314 m_solverMultiBodyIslandCallback->setup(&solverInfo, constraintsPtr, m_sortedConstraints.size(), sortedMultiBodyConstraints, m_sortedMultiBodyConstraints.size(), getDebugDrawer());
315 m_constraintSolver->prepareSolve(getCollisionWorld()->getNumCollisionObjects(), getCollisionWorld()->getDispatcher()->getNumManifolds());
316
317#ifndef BT_USE_VIRTUAL_CLEARFORCES_AND_GRAVITY
318 {
319 BT_PROFILE("btMultiBody addForce");
320 for (int i = 0; i < this->m_multiBodies.size(); i++)
321 {
322 btMultiBody* bod = m_multiBodies[i];
323
324 bool isSleeping = false;
325
326 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
327 {
328 isSleeping = true;
329 }
330 for (int b = 0; b < bod->getNumLinks(); b++)
331 {
332 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
333 isSleeping = true;
334 }
335
336 if (!isSleeping)
337 {
338 //useless? they get resized in stepVelocities once again (AND DIFFERENTLY)
339 m_scratch_r.resize(bod->getNumLinks() + 1); //multidof? ("Y"s use it and it is used to store qdd)
340 m_scratch_v.resize(bod->getNumLinks() + 1);
341 m_scratch_m.resize(bod->getNumLinks() + 1);
342
343 bod->addBaseForce(m_gravity * bod->getBaseMass());
344
345 for (int j = 0; j < bod->getNumLinks(); ++j)
346 {
347 bod->addLinkForce(j, m_gravity * bod->getLinkMass(j));
348 }
349 } //if (!isSleeping)
350 }
351 }
352#endif //BT_USE_VIRTUAL_CLEARFORCES_AND_GRAVITY
353
354 {
355 BT_PROFILE("btMultiBody stepVelocities");
356 for (int i = 0; i < this->m_multiBodies.size(); i++)
357 {
358 btMultiBody* bod = m_multiBodies[i];
359
360 bool isSleeping = false;
361
362 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
363 {
364 isSleeping = true;
365 }
366 for (int b = 0; b < bod->getNumLinks(); b++)
367 {
368 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
369 isSleeping = true;
370 }
371
372 if (!isSleeping)
373 {
374 //useless? they get resized in stepVelocities once again (AND DIFFERENTLY)
375 m_scratch_r.resize(bod->getNumLinks() + 1); //multidof? ("Y"s use it and it is used to store qdd)
376 m_scratch_v.resize(bod->getNumLinks() + 1);
377 m_scratch_m.resize(bod->getNumLinks() + 1);
378 bool doNotUpdatePos = false;
379 bool isConstraintPass = false;
380 {
381 if (!bod->isUsingRK4Integration())
382 {
383 bod->computeAccelerationsArticulatedBodyAlgorithmMultiDof(solverInfo.m_timeStep,
384 m_scratch_r, m_scratch_v, m_scratch_m,isConstraintPass,
385 getSolverInfo().m_jointFeedbackInWorldSpace,
386 getSolverInfo().m_jointFeedbackInJointFrame);
387 }
388 else
389 {
390 //
391 int numDofs = bod->getNumDofs() + 6;
392 int numPosVars = bod->getNumPosVars() + 7;
393 btAlignedObjectArray<btScalar> scratch_r2;
394 scratch_r2.resize(2 * numPosVars + 8 * numDofs);
395 //convenience
396 btScalar* pMem = &scratch_r2[0];
397 btScalar* scratch_q0 = pMem;
398 pMem += numPosVars;
399 btScalar* scratch_qx = pMem;
400 pMem += numPosVars;
401 btScalar* scratch_qd0 = pMem;
402 pMem += numDofs;
403 btScalar* scratch_qd1 = pMem;
404 pMem += numDofs;
405 btScalar* scratch_qd2 = pMem;
406 pMem += numDofs;
407 btScalar* scratch_qd3 = pMem;
408 pMem += numDofs;
409 btScalar* scratch_qdd0 = pMem;
410 pMem += numDofs;
411 btScalar* scratch_qdd1 = pMem;
412 pMem += numDofs;
413 btScalar* scratch_qdd2 = pMem;
414 pMem += numDofs;
415 btScalar* scratch_qdd3 = pMem;
416 pMem += numDofs;
417 btAssert((pMem - (2 * numPosVars + 8 * numDofs)) == &scratch_r2[0]);
418
420 //copy q0 to scratch_q0 and qd0 to scratch_qd0
421 scratch_q0[0] = bod->getWorldToBaseRot().x();
422 scratch_q0[1] = bod->getWorldToBaseRot().y();
423 scratch_q0[2] = bod->getWorldToBaseRot().z();
424 scratch_q0[3] = bod->getWorldToBaseRot().w();
425 scratch_q0[4] = bod->getBasePos().x();
426 scratch_q0[5] = bod->getBasePos().y();
427 scratch_q0[6] = bod->getBasePos().z();
428 //
429 for (int link = 0; link < bod->getNumLinks(); ++link)
430 {
431 for (int dof = 0; dof < bod->getLink(link).m_posVarCount; ++dof)
432 scratch_q0[7 + bod->getLink(link).m_cfgOffset + dof] = bod->getLink(link).m_jointPos[dof];
433 }
434 //
435 for (int dof = 0; dof < numDofs; ++dof)
436 scratch_qd0[dof] = bod->getVelocityVector()[dof];
438 struct
439 {
440 btMultiBody* bod;
441 btScalar *scratch_qx, *scratch_q0;
442
443 void operator()()
444 {
445 for (int dof = 0; dof < bod->getNumPosVars() + 7; ++dof)
446 scratch_qx[dof] = scratch_q0[dof];
447 }
448 } pResetQx = {bod, scratch_qx, scratch_q0};
449 //
450 struct
451 {
452 void operator()(btScalar dt, const btScalar* pDer, const btScalar* pCurVal, btScalar* pVal, int size)
453 {
454 for (int i = 0; i < size; ++i)
455 pVal[i] = pCurVal[i] + dt * pDer[i];
456 }
457
458 } pEulerIntegrate;
459 //
460 struct
461 {
462 void operator()(btMultiBody* pBody, const btScalar* pData)
463 {
464 btScalar* pVel = const_cast<btScalar*>(pBody->getVelocityVector());
465
466 for (int i = 0; i < pBody->getNumDofs() + 6; ++i)
467 pVel[i] = pData[i];
468 }
469 } pCopyToVelocityVector;
470 //
471 struct
472 {
473 void operator()(const btScalar* pSrc, btScalar* pDst, int start, int size)
474 {
475 for (int i = 0; i < size; ++i)
476 pDst[i] = pSrc[start + i];
477 }
478 } pCopy;
479 //
480
481 btScalar h = solverInfo.m_timeStep;
482#define output &m_scratch_r[bod->getNumDofs()]
483 //calc qdd0 from: q0 & qd0
484 bod->computeAccelerationsArticulatedBodyAlgorithmMultiDof(0., m_scratch_r, m_scratch_v, m_scratch_m,
485 isConstraintPass,getSolverInfo().m_jointFeedbackInWorldSpace,
486 getSolverInfo().m_jointFeedbackInJointFrame);
487 pCopy(output, scratch_qdd0, 0, numDofs);
488 //calc q1 = q0 + h/2 * qd0
489 pResetQx();
490 bod->stepPositionsMultiDof(btScalar(.5) * h, scratch_qx, scratch_qd0);
491 //calc qd1 = qd0 + h/2 * qdd0
492 pEulerIntegrate(btScalar(.5) * h, scratch_qdd0, scratch_qd0, scratch_qd1, numDofs);
493 //
494 //calc qdd1 from: q1 & qd1
495 pCopyToVelocityVector(bod, scratch_qd1);
496 bod->computeAccelerationsArticulatedBodyAlgorithmMultiDof(0., m_scratch_r, m_scratch_v, m_scratch_m,
497 isConstraintPass,getSolverInfo().m_jointFeedbackInWorldSpace,
498 getSolverInfo().m_jointFeedbackInJointFrame);
499 pCopy(output, scratch_qdd1, 0, numDofs);
500 //calc q2 = q0 + h/2 * qd1
501 pResetQx();
502 bod->stepPositionsMultiDof(btScalar(.5) * h, scratch_qx, scratch_qd1);
503 //calc qd2 = qd0 + h/2 * qdd1
504 pEulerIntegrate(btScalar(.5) * h, scratch_qdd1, scratch_qd0, scratch_qd2, numDofs);
505 //
506 //calc qdd2 from: q2 & qd2
507 pCopyToVelocityVector(bod, scratch_qd2);
508 bod->computeAccelerationsArticulatedBodyAlgorithmMultiDof(0., m_scratch_r, m_scratch_v, m_scratch_m,
509 isConstraintPass,getSolverInfo().m_jointFeedbackInWorldSpace,
510 getSolverInfo().m_jointFeedbackInJointFrame);
511 pCopy(output, scratch_qdd2, 0, numDofs);
512 //calc q3 = q0 + h * qd2
513 pResetQx();
514 bod->stepPositionsMultiDof(h, scratch_qx, scratch_qd2);
515 //calc qd3 = qd0 + h * qdd2
516 pEulerIntegrate(h, scratch_qdd2, scratch_qd0, scratch_qd3, numDofs);
517 //
518 //calc qdd3 from: q3 & qd3
519 pCopyToVelocityVector(bod, scratch_qd3);
520 bod->computeAccelerationsArticulatedBodyAlgorithmMultiDof(0., m_scratch_r, m_scratch_v, m_scratch_m,
521 isConstraintPass,getSolverInfo().m_jointFeedbackInWorldSpace,
522 getSolverInfo().m_jointFeedbackInJointFrame);
523 pCopy(output, scratch_qdd3, 0, numDofs);
524
525 //
526 //calc q = q0 + h/6(qd0 + 2*(qd1 + qd2) + qd3)
527 //calc qd = qd0 + h/6(qdd0 + 2*(qdd1 + qdd2) + qdd3)
528 btAlignedObjectArray<btScalar> delta_q;
529 delta_q.resize(numDofs);
530 btAlignedObjectArray<btScalar> delta_qd;
531 delta_qd.resize(numDofs);
532 for (int i = 0; i < numDofs; ++i)
533 {
534 delta_q[i] = h / btScalar(6.) * (scratch_qd0[i] + 2 * scratch_qd1[i] + 2 * scratch_qd2[i] + scratch_qd3[i]);
535 delta_qd[i] = h / btScalar(6.) * (scratch_qdd0[i] + 2 * scratch_qdd1[i] + 2 * scratch_qdd2[i] + scratch_qdd3[i]);
536 //delta_q[i] = h*scratch_qd0[i];
537 //delta_qd[i] = h*scratch_qdd0[i];
538 }
539 //
540 pCopyToVelocityVector(bod, scratch_qd0);
541 bod->applyDeltaVeeMultiDof(&delta_qd[0], 1);
542 //
543 if (!doNotUpdatePos)
544 {
545 btScalar* pRealBuf = const_cast<btScalar*>(bod->getVelocityVector());
546 pRealBuf += 6 + bod->getNumDofs() + bod->getNumDofs() * bod->getNumDofs();
547
548 for (int i = 0; i < numDofs; ++i)
549 pRealBuf[i] = delta_q[i];
550
551 //bod->stepPositionsMultiDof(1, 0, &delta_q[0]);
552 bod->setPosUpdated(true);
553 }
554
555 //ugly hack which resets the cached data to t0 (needed for constraint solver)
556 {
557 for (int link = 0; link < bod->getNumLinks(); ++link)
558 bod->getLink(link).updateCacheMultiDof();
559 bod->computeAccelerationsArticulatedBodyAlgorithmMultiDof(0, m_scratch_r, m_scratch_v, m_scratch_m,
560 isConstraintPass,getSolverInfo().m_jointFeedbackInWorldSpace,
561 getSolverInfo().m_jointFeedbackInJointFrame);
562 }
563 }
564 }
565
566#ifndef BT_USE_VIRTUAL_CLEARFORCES_AND_GRAVITY
567 bod->clearForcesAndTorques();
568#endif //BT_USE_VIRTUAL_CLEARFORCES_AND_GRAVITY
569 } //if (!isSleeping)
570 }
571 }
572}
573
574
575 void btMultiBodyDynamicsWorld::integrateTransforms(btScalar timeStep)
576{
577 btDiscreteDynamicsWorld::integrateTransforms(timeStep);
578 integrateMultiBodyTransforms(timeStep);
579}
580
581 void btMultiBodyDynamicsWorld::integrateMultiBodyTransforms(btScalar timeStep)
582{
583 BT_PROFILE("btMultiBody stepPositions");
584 //integrate and update the Featherstone hierarchies
585
586 for (int b = 0; b < m_multiBodies.size(); b++)
587 {
588 btMultiBody* bod = m_multiBodies[b];
589 bool isSleeping = false;
590 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
591 {
592 isSleeping = true;
593 }
594 for (int b = 0; b < bod->getNumLinks(); b++)
595 {
596 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
597 isSleeping = true;
598 }
599
600 if (!isSleeping)
601 {
602 bod->addSplitV();
603 int nLinks = bod->getNumLinks();
604
606 if (!bod->isPosUpdated())
607 bod->stepPositionsMultiDof(timeStep);
608 else
609 {
610 btScalar* pRealBuf = const_cast<btScalar*>(bod->getVelocityVector());
611 pRealBuf += 6 + bod->getNumDofs() + bod->getNumDofs() * bod->getNumDofs();
612
613 bod->stepPositionsMultiDof(1, 0, pRealBuf);
614 bod->setPosUpdated(false);
615 }
616
617
618 m_scratch_world_to_local.resize(nLinks + 1);
619 m_scratch_local_origin.resize(nLinks + 1);
620 bod->updateCollisionObjectWorldTransforms(m_scratch_world_to_local, m_scratch_local_origin);
621 bod->substractSplitV();
622 }
623 else
624 {
625 bod->clearVelocities();
626 }
627 }
628}
629
630 void btMultiBodyDynamicsWorld::predictMultiBodyTransforms(btScalar timeStep)
631{
632 BT_PROFILE("btMultiBody stepPositions");
633 //integrate and update the Featherstone hierarchies
634
635 for (int b = 0; b < m_multiBodies.size(); b++)
636 {
637 btMultiBody* bod = m_multiBodies[b];
638 bool isSleeping = false;
639 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
640 {
641 isSleeping = true;
642 }
643 for (int b = 0; b < bod->getNumLinks(); b++)
644 {
645 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
646 isSleeping = true;
647 }
648
649 if (!isSleeping)
650 {
651 int nLinks = bod->getNumLinks();
652 bod->predictPositionsMultiDof(timeStep);
653 m_scratch_world_to_local.resize(nLinks + 1);
654 m_scratch_local_origin.resize(nLinks + 1);
655 bod->updateCollisionObjectInterpolationWorldTransforms(m_scratch_world_to_local, m_scratch_local_origin);
656 }
657 else
658 {
659 bod->clearVelocities();
660 }
661 }
662}
663
664 void btMultiBodyDynamicsWorld::addMultiBodyConstraint(btMultiBodyConstraint* constraint)
665{
666 m_multiBodyConstraints.push_back(constraint);
667}
668
669 void btMultiBodyDynamicsWorld::removeMultiBodyConstraint(btMultiBodyConstraint* constraint)
670{
671 m_multiBodyConstraints.remove(constraint);
672}
673
674 void btMultiBodyDynamicsWorld::debugDrawMultiBodyConstraint(btMultiBodyConstraint* constraint)
675{
676 constraint->debugDraw(getDebugDrawer());
677}
678
679 void btMultiBodyDynamicsWorld::debugDrawWorld()
680{
681 BT_PROFILE("btMultiBodyDynamicsWorld debugDrawWorld");
682
683 btDiscreteDynamicsWorld::debugDrawWorld();
684
685 bool drawConstraints = false;
686 if (getDebugDrawer())
687 {
688 int mode = getDebugDrawer()->getDebugMode();
689 if (mode & (btIDebugDraw::DBG_DrawConstraints | btIDebugDraw::DBG_DrawConstraintLimits))
690 {
691 drawConstraints = true;
692 }
693
694 if (drawConstraints)
695 {
696 BT_PROFILE("btMultiBody debugDrawWorld");
697
698 for (int c = 0; c < m_multiBodyConstraints.size(); c++)
699 {
700 btMultiBodyConstraint* constraint = m_multiBodyConstraints[c];
701 debugDrawMultiBodyConstraint(constraint);
702 }
703
704 for (int b = 0; b < m_multiBodies.size(); b++)
705 {
706 btMultiBody* bod = m_multiBodies[b];
707 bod->forwardKinematics(m_scratch_world_to_local1, m_scratch_local_origin1);
708
709 if (mode & btIDebugDraw::DBG_DrawFrames)
710 {
711 getDebugDrawer()->drawTransform(bod->getBaseWorldTransform(), 0.1);
712 }
713
714 for (int m = 0; m < bod->getNumLinks(); m++)
715 {
716 const btTransform& tr = bod->getLink(m).m_cachedWorldTransform;
717 if (mode & btIDebugDraw::DBG_DrawFrames)
718 {
719 getDebugDrawer()->drawTransform(tr, 0.1);
720 }
721 //draw the joint axis
722 if (bod->getLink(m).m_jointType == btMultibodyLink::eRevolute)
723 {
724 btVector3 vec = quatRotate(tr.getRotation(), bod->getLink(m).m_axes[0].m_topVec) * 0.1;
725
726 btVector4 color(0, 0, 0, 1); //1,1,1);
727 btVector3 from = vec + tr.getOrigin() - quatRotate(tr.getRotation(), bod->getLink(m).m_dVector);
728 btVector3 to = tr.getOrigin() - quatRotate(tr.getRotation(), bod->getLink(m).m_dVector);
729 getDebugDrawer()->drawLine(from, to, color);
730 }
731 if (bod->getLink(m).m_jointType == btMultibodyLink::eFixed)
732 {
733 btVector3 vec = quatRotate(tr.getRotation(), bod->getLink(m).m_axes[0].m_bottomVec) * 0.1;
734
735 btVector4 color(0, 0, 0, 1); //1,1,1);
736 btVector3 from = vec + tr.getOrigin() - quatRotate(tr.getRotation(), bod->getLink(m).m_dVector);
737 btVector3 to = tr.getOrigin() - quatRotate(tr.getRotation(), bod->getLink(m).m_dVector);
738 getDebugDrawer()->drawLine(from, to, color);
739 }
740 if (bod->getLink(m).m_jointType == btMultibodyLink::ePrismatic)
741 {
742 btVector3 vec = quatRotate(tr.getRotation(), bod->getLink(m).m_axes[0].m_bottomVec) * 0.1;
743
744 btVector4 color(0, 0, 0, 1); //1,1,1);
745 btVector3 from = vec + tr.getOrigin() - quatRotate(tr.getRotation(), bod->getLink(m).m_dVector);
746 btVector3 to = tr.getOrigin() - quatRotate(tr.getRotation(), bod->getLink(m).m_dVector);
747 getDebugDrawer()->drawLine(from, to, color);
748 }
749 }
750 }
751 }
752 }
753}
754
755 void btMultiBodyDynamicsWorld::applyGravity()
756{
757 btDiscreteDynamicsWorld::applyGravity();
758#ifdef BT_USE_VIRTUAL_CLEARFORCES_AND_GRAVITY
759 BT_PROFILE("btMultiBody addGravity");
760 for (int i = 0; i < this->m_multiBodies.size(); i++)
761 {
762 btMultiBody* bod = m_multiBodies[i];
763
764 bool isSleeping = false;
765
766 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
767 {
768 isSleeping = true;
769 }
770 for (int b = 0; b < bod->getNumLinks(); b++)
771 {
772 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
773 isSleeping = true;
774 }
775
776 if (!isSleeping)
777 {
778 bod->addBaseForce(m_gravity * bod->getBaseMass());
779
780 for (int j = 0; j < bod->getNumLinks(); ++j)
781 {
782 bod->addLinkForce(j, m_gravity * bod->getLinkMass(j));
783 }
784 } //if (!isSleeping)
785 }
786#endif //BT_USE_VIRTUAL_CLEARFORCES_AND_GRAVITY
787}
788
789 void btMultiBodyDynamicsWorld::clearMultiBodyConstraintForces()
790{
791 for (int i = 0; i < this->m_multiBodies.size(); i++)
792 {
793 btMultiBody* bod = m_multiBodies[i];
794 bod->clearConstraintForces();
795 }
796}
797 void btMultiBodyDynamicsWorld::clearMultiBodyForces()
798{
799 {
800 // BT_PROFILE("clearMultiBodyForces");
801 for (int i = 0; i < this->m_multiBodies.size(); i++)
802 {
803 btMultiBody* bod = m_multiBodies[i];
804
805 bool isSleeping = false;
806
807 if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING)
808 {
809 isSleeping = true;
810 }
811 for (int b = 0; b < bod->getNumLinks(); b++)
812 {
813 if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState() == ISLAND_SLEEPING)
814 isSleeping = true;
815 }
816
817 if (!isSleeping)
818 {
819 btMultiBody* bod = m_multiBodies[i];
820 bod->clearForcesAndTorques();
821 }
822 }
823 }
824}
825 void btMultiBodyDynamicsWorld::clearForces()
826{
827 btDiscreteDynamicsWorld::clearForces();
828
829#ifdef BT_USE_VIRTUAL_CLEARFORCES_AND_GRAVITY
830 clearMultiBodyForces();
831#endif
832}
833
834 void btMultiBodyDynamicsWorld::serialize(btSerializer* serializer)
835{
836 serializer->startSerialization();
837
838 serializeDynamicsWorldInfo(serializer);
839
840 serializeMultiBodies(serializer);
841
842 serializeRigidBodies(serializer);
843
844 serializeCollisionObjects(serializer);
845
846 serializeContactManifolds(serializer);
847
848 serializer->finishSerialization();
849}
850
851 void btMultiBodyDynamicsWorld::serializeMultiBodies(btSerializer* serializer)
852{
853 int i;
854 //serialize all collision objects
855 for (i = 0; i < m_multiBodies.size(); i++)
856 {
857 btMultiBody* mb = m_multiBodies[i];
858 {
859 int len = mb->calculateSerializeBufferSize();
860 btChunk* chunk = serializer->allocate(len, 1);
861 const char* structType = mb->serialize(chunk->m_oldPtr, serializer);
862 serializer->finalizeChunk(chunk, structType, BT_MULTIBODY_CODE, mb);
863 }
864 }
865
866 //serialize all multibody links (collision objects)
867 for (i = 0; i < m_collisionObjects.size(); i++)
868 {
869 btCollisionObject* colObj = m_collisionObjects[i];
870 if (colObj->getInternalType() == btCollisionObject::CO_FEATHERSTONE_LINK)
871 {
872 int len = colObj->calculateSerializeBufferSize();
873 btChunk* chunk = serializer->allocate(len, 1);
874 const char* structType = colObj->serialize(chunk->m_oldPtr, serializer);
875 serializer->finalizeChunk(chunk, structType, BT_MB_LINKCOLLIDER_CODE, colObj);
876 }
877 }
878}
879
880 void btMultiBodyDynamicsWorld::saveKinematicState(btScalar timeStep)
881{
882 btDiscreteDynamicsWorld::saveKinematicState(timeStep);
883 for(int i = 0; i < m_multiBodies.size(); i++)
884 {
885 btMultiBody* body = m_multiBodies[i];
886 if(body->isBaseKinematic())
887 body->saveKinematicState(timeStep);
888 }
889}
890
891//
892//void btMultiBodyDynamicsWorld::setSplitIslands(bool split)
893//{
894// m_islandManager->setSplitIslands(split);
895//}
ACTIVE_TAG
#define ACTIVE_TAG
Definition: btCollisionObject.h:22
DISABLE_DEACTIVATION
#define DISABLE_DEACTIVATION
Definition: btCollisionObject.h:25
FIXED_BASE_MULTI_BODY
#define FIXED_BASE_MULTI_BODY
Definition: btCollisionObject.h:27
WANTS_DEACTIVATION
#define WANTS_DEACTIVATION
Definition: btCollisionObject.h:24
ISLAND_SLEEPING
#define ISLAND_SLEEPING
Definition: btCollisionObject.h:23
BT_MULTIBODY_SOLVER
@ BT_MULTIBODY_SOLVER
Definition: btConstraintSolver.h:37
SOLVER_USE_2_FRICTION_DIRECTIONS
@ SOLVER_USE_2_FRICTION_DIRECTIONS
Definition: btContactSolverInfo.h:26
size
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
btIDebugDraw.h
btMultiBodyConstraintSolver.h
btMultiBodyConstraint.h
output
#define output
btMultiBodyDynamicsWorld.h
btMultiBodyLinkCollider.h
btMultiBody.h
quatRotate
btVector3 quatRotate(const btQuaternion &rotation, const btVector3 &v)
Definition: btQuaternion.h:926
btQuickprof.h
BT_PROFILE
#define BT_PROFILE(name)
Definition: btQuickprof.h:198
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btAssert
#define btAssert(x)
Definition: btScalar.h:153
btSerializer.h
BT_MULTIBODY_CODE
#define BT_MULTIBODY_CODE
Definition: btSerializer.h:108
BT_MB_LINKCOLLIDER_CODE
#define BT_MB_LINKCOLLIDER_CODE
Definition: btSerializer.h:109
btSimulationIslandManager.h
btAlignedObjectArray< btSolverAnalyticsData >
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:142
btAlignedObjectArray::resize
void resize(int newsize, const T &fillData=T())
Definition: btAlignedObjectArray.h:203
btAlignedObjectArray::remove
void remove(const T &key)
Definition: btAlignedObjectArray.h:480
btAlignedObjectArray::quickSort
void quickSort(const L &CompareFunc)
Definition: btAlignedObjectArray.h:341
btAlignedObjectArray::push_back
void push_back(const T &_Val)
Definition: btAlignedObjectArray.h:257
btBroadphaseInterface
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs.
Definition: btBroadphaseInterface.h:50
btChunk
Definition: btSerializer.h:48
btChunk::m_oldPtr
void * m_oldPtr
Definition: btSerializer.h:52
btCollisionConfiguration
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size,...
Definition: btCollisionConfiguration.h:27
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:51
btCollisionObject::isStaticOrKinematicObject
bool isStaticOrKinematicObject() const
Definition: btCollisionObject.h:207
btCollisionObject::serialize
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btCollisionObject.cpp:81
btCollisionObject::CO_FEATHERSTONE_LINK
@ CO_FEATHERSTONE_LINK
Definition: btCollisionObject.h:155
btCollisionObject::getInternalType
int getInternalType() const
reserved for Bullet internal usage
Definition: btCollisionObject.h:374
btCollisionObject::setActivationState
void setActivationState(int newState) const
Definition: btCollisionObject.cpp:61
btCollisionObject::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btCollisionObject.h:685
btCollisionObject::getIslandTag
int getIslandTag() const
Definition: btCollisionObject.h:448
btCollisionObject::setDeactivationTime
void setDeactivationTime(btScalar time)
Definition: btCollisionObject.h:293
btCollisionObject::getActivationState
int getActivationState() const
Definition: btCollisionObject.h:289
btCollisionWorld::getDispatcher
btDispatcher * getDispatcher()
Definition: btCollisionWorld.h:132
btCollisionWorld::getDebugDrawer
virtual btIDebugDraw * getDebugDrawer()
Definition: btCollisionWorld.h:155
btCollisionWorld::m_collisionObjects
btAlignedObjectArray< btCollisionObject * > m_collisionObjects
Definition: btCollisionWorld.h:88
btCollisionWorld::getNumCollisionObjects
int getNumCollisionObjects() const
Definition: btCollisionWorld.h:427
btCollisionWorld::m_debugDrawer
btIDebugDraw * m_debugDrawer
Definition: btCollisionWorld.h:96
btCollisionWorld::serializeContactManifolds
void serializeContactManifolds(btSerializer *serializer)
Definition: btCollisionWorld.cpp:1595
btCollisionWorld::serializeCollisionObjects
void serializeCollisionObjects(btSerializer *serializer)
Definition: btCollisionWorld.cpp:1565
btConstraintSolver
Definition: btConstraintSolver.h:42
btConstraintSolver::getSolverType
virtual btConstraintSolverType getSolverType() const =0
btConstraintSolver::allSolved
virtual void allSolved(const btContactSolverInfo &, class btIDebugDraw *)
Definition: btConstraintSolver.h:51
btConstraintSolver::prepareSolve
virtual void prepareSolve(int, int)
Definition: btConstraintSolver.h:46
btDiscreteDynamicsWorld
btDiscreteDynamicsWorld provides discrete rigid body simulation those classes replace the obsolete Cc...
Definition: btDiscreteDynamicsWorld.h:38
btDiscreteDynamicsWorld::m_predictiveManifolds
btAlignedObjectArray< btPersistentManifold * > m_predictiveManifolds
Definition: btDiscreteDynamicsWorld.h:69
btDiscreteDynamicsWorld::integrateTransforms
virtual void integrateTransforms(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:1047
btDiscreteDynamicsWorld::serializeRigidBodies
void serializeRigidBodies(btSerializer *serializer)
Definition: btDiscreteDynamicsWorld.cpp:1379
btDiscreteDynamicsWorld::serializeDynamicsWorldInfo
void serializeDynamicsWorldInfo(btSerializer *serializer)
Definition: btDiscreteDynamicsWorld.cpp:1405
btDiscreteDynamicsWorld::m_sortedConstraints
btAlignedObjectArray< btTypedConstraint * > m_sortedConstraints
Definition: btDiscreteDynamicsWorld.h:40
btDiscreteDynamicsWorld::setConstraintSolver
virtual void setConstraintSolver(btConstraintSolver *solver)
Definition: btDiscreteDynamicsWorld.cpp:1350
btDiscreteDynamicsWorld::m_gravity
btVector3 m_gravity
Definition: btDiscreteDynamicsWorld.h:51
btDiscreteDynamicsWorld::saveKinematicState
virtual void saveKinematicState(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:249
btDiscreteDynamicsWorld::applyGravity
virtual void applyGravity()
apply gravity, call this once per timestep
Definition: btDiscreteDynamicsWorld.cpp:322
btDiscreteDynamicsWorld::m_islandManager
btSimulationIslandManager * m_islandManager
Definition: btDiscreteDynamicsWorld.h:45
btDiscreteDynamicsWorld::m_constraints
btAlignedObjectArray< btTypedConstraint * > m_constraints
Definition: btDiscreteDynamicsWorld.h:47
btDiscreteDynamicsWorld::getNumConstraints
virtual int getNumConstraints() const
Definition: btDiscreteDynamicsWorld.cpp:1366
btDiscreteDynamicsWorld::getSimulationIslandManager
btSimulationIslandManager * getSimulationIslandManager()
Definition: btDiscreteDynamicsWorld.h:125
btDiscreteDynamicsWorld::updateActivationState
virtual void updateActivationState(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:594
btDiscreteDynamicsWorld::m_constraintSolver
btConstraintSolver * m_constraintSolver
Definition: btDiscreteDynamicsWorld.h:43
btDiscreteDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btDiscreteDynamicsWorld.cpp:269
btDiscreteDynamicsWorld::getCollisionWorld
btCollisionWorld * getCollisionWorld()
Definition: btDiscreteDynamicsWorld.h:135
btDiscreteDynamicsWorld::clearForces
virtual void clearForces()
the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
Definition: btDiscreteDynamicsWorld.cpp:309
btDiscreteDynamicsWorld::predictUnconstraintMotion
virtual void predictUnconstraintMotion(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:1091
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
btDynamicsWorld::getSolverInfo
btContactSolverInfo & getSolverInfo()
Definition: btDynamicsWorld.h:140
btIDebugDraw::drawLine
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
btIDebugDraw::drawTransform
virtual void drawTransform(const btTransform &transform, btScalar orthoLen)
Definition: btIDebugDraw.h:163
btIDebugDraw::getDebugMode
virtual int getDebugMode() const =0
btIDebugDraw::DBG_DrawConstraints
@ DBG_DrawConstraints
Definition: btIDebugDraw.h:66
btIDebugDraw::DBG_DrawFrames
@ DBG_DrawFrames
Definition: btIDebugDraw.h:70
btIDebugDraw::DBG_DrawConstraintLimits
@ DBG_DrawConstraintLimits
Definition: btIDebugDraw.h:67
btMultiBodyConstraintSolver
Definition: btMultiBodyConstraintSolver.h:30
btMultiBodyConstraint
Definition: btMultiBodyConstraint.h:57
btMultiBodyConstraint::getIslandIdA
virtual int getIslandIdA() const =0
btMultiBodyConstraint::debugDraw
virtual void debugDraw(class btIDebugDraw *drawer)=0
btMultiBodyConstraint::getIslandIdB
virtual int getIslandIdB() const =0
btMultiBodyDynamicsWorld::m_multiBodyConstraints
btAlignedObjectArray< btMultiBodyConstraint * > m_multiBodyConstraints
Definition: btMultiBodyDynamicsWorld.h:35
btMultiBodyDynamicsWorld::clearForces
virtual void clearForces()
the forces on each rigidbody is accumulating together with gravity. clear this after each timestep.
Definition: btMultiBodyDynamicsWorld.cpp:825
btMultiBodyDynamicsWorld::solveInternalConstraints
virtual void solveInternalConstraints(btContactSolverInfo &solverInfo)
Definition: btMultiBodyDynamicsWorld.cpp:235
btMultiBodyDynamicsWorld::updateActivationState
virtual void updateActivationState(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:125
btMultiBodyDynamicsWorld::forwardKinematics
void forwardKinematics()
Definition: btMultiBodyDynamicsWorld.cpp:215
btMultiBodyDynamicsWorld::m_scratch_world_to_local
btAlignedObjectArray< btQuaternion > m_scratch_world_to_local
Definition: btMultiBodyDynamicsWorld.h:41
btMultiBodyDynamicsWorld::m_scratch_world_to_local1
btAlignedObjectArray< btQuaternion > m_scratch_world_to_local1
Definition: btMultiBodyDynamicsWorld.h:43
btMultiBodyDynamicsWorld::m_scratch_m
btAlignedObjectArray< btMatrix3x3 > m_scratch_m
Definition: btMultiBodyDynamicsWorld.h:47
btMultiBodyDynamicsWorld::m_solverMultiBodyIslandCallback
MultiBodyInplaceSolverIslandCallback * m_solverMultiBodyIslandCallback
Definition: btMultiBodyDynamicsWorld.h:38
btMultiBodyDynamicsWorld::serialize
virtual void serialize(btSerializer *serializer)
Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (see B...
Definition: btMultiBodyDynamicsWorld.cpp:834
btMultiBodyDynamicsWorld::~btMultiBodyDynamicsWorld
virtual ~btMultiBodyDynamicsWorld()
Definition: btMultiBodyDynamicsWorld.cpp:194
btMultiBodyDynamicsWorld::m_scratch_local_origin1
btAlignedObjectArray< btVector3 > m_scratch_local_origin1
Definition: btMultiBodyDynamicsWorld.h:44
btMultiBodyDynamicsWorld::serializeMultiBodies
virtual void serializeMultiBodies(btSerializer *serializer)
Definition: btMultiBodyDynamicsWorld.cpp:851
btMultiBodyDynamicsWorld::addMultiBodyConstraint
virtual void addMultiBodyConstraint(btMultiBodyConstraint *constraint)
Definition: btMultiBodyDynamicsWorld.cpp:664
btMultiBodyDynamicsWorld::m_scratch_v
btAlignedObjectArray< btVector3 > m_scratch_v
Definition: btMultiBodyDynamicsWorld.h:46
btMultiBodyDynamicsWorld::predictUnconstraintMotion
virtual void predictUnconstraintMotion(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:36
btMultiBodyDynamicsWorld::buildIslands
void buildIslands()
Definition: btMultiBodyDynamicsWorld.cpp:230
btMultiBodyDynamicsWorld::calculateSimulationIslands
virtual void calculateSimulationIslands()
Definition: btMultiBodyDynamicsWorld.cpp:42
btMultiBodyDynamicsWorld::removeMultiBodyConstraint
virtual void removeMultiBodyConstraint(btMultiBodyConstraint *constraint)
Definition: btMultiBodyDynamicsWorld.cpp:669
btMultiBodyDynamicsWorld::predictMultiBodyTransforms
void predictMultiBodyTransforms(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:630
btMultiBodyDynamicsWorld::integrateTransforms
virtual void integrateTransforms(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:575
btMultiBodyDynamicsWorld::m_multiBodyConstraintSolver
btMultiBodyConstraintSolver * m_multiBodyConstraintSolver
Definition: btMultiBodyDynamicsWorld.h:37
btMultiBodyDynamicsWorld::m_multiBodies
btAlignedObjectArray< btMultiBody * > m_multiBodies
Definition: btMultiBodyDynamicsWorld.h:34
btMultiBodyDynamicsWorld::getAnalyticsData
virtual void getAnalyticsData(btAlignedObjectArray< struct btSolverAnalyticsData > &m_islandAnalyticsData) const
Definition: btMultiBodyDynamicsWorld.cpp:179
btMultiBodyDynamicsWorld::solveConstraints
virtual void solveConstraints(btContactSolverInfo &solverInfo)
Definition: btMultiBodyDynamicsWorld.cpp:223
btMultiBodyDynamicsWorld::integrateMultiBodyTransforms
void integrateMultiBodyTransforms(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:581
btMultiBodyDynamicsWorld::debugDrawMultiBodyConstraint
virtual void debugDrawMultiBodyConstraint(btMultiBodyConstraint *constraint)
Definition: btMultiBodyDynamicsWorld.cpp:674
btMultiBodyDynamicsWorld::solveExternalForces
virtual void solveExternalForces(btContactSolverInfo &solverInfo)
Definition: btMultiBodyDynamicsWorld.cpp:288
btMultiBodyDynamicsWorld::setConstraintSolver
virtual void setConstraintSolver(btConstraintSolver *solver)
Definition: btMultiBodyDynamicsWorld.cpp:206
btMultiBodyDynamicsWorld::m_scratch_local_origin
btAlignedObjectArray< btVector3 > m_scratch_local_origin
Definition: btMultiBodyDynamicsWorld.h:42
btMultiBodyDynamicsWorld::clearMultiBodyForces
virtual void clearMultiBodyForces()
Definition: btMultiBodyDynamicsWorld.cpp:797
btMultiBodyDynamicsWorld::m_scratch_r
btAlignedObjectArray< btScalar > m_scratch_r
Definition: btMultiBodyDynamicsWorld.h:45
btMultiBodyDynamicsWorld::removeMultiBody
virtual void removeMultiBody(btMultiBody *body)
Definition: btMultiBodyDynamicsWorld.cpp:31
btMultiBodyDynamicsWorld::m_sortedMultiBodyConstraints
btAlignedObjectArray< btMultiBodyConstraint * > m_sortedMultiBodyConstraints
Definition: btMultiBodyDynamicsWorld.h:36
btMultiBodyDynamicsWorld::addMultiBody
virtual void addMultiBody(btMultiBody *body, int group=btBroadphaseProxy::DefaultFilter, int mask=btBroadphaseProxy::AllFilter)
Definition: btMultiBodyDynamicsWorld.cpp:26
btMultiBodyDynamicsWorld::btMultiBodyDynamicsWorld
btMultiBodyDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btMultiBodyConstraintSolver *constraintSolver, btCollisionConfiguration *collisionConfiguration)
Definition: btMultiBodyDynamicsWorld.cpp:184
btMultiBodyDynamicsWorld::clearMultiBodyConstraintForces
virtual void clearMultiBodyConstraintForces()
Definition: btMultiBodyDynamicsWorld.cpp:789
btMultiBodyDynamicsWorld::saveKinematicState
virtual void saveKinematicState(btScalar timeStep)
Definition: btMultiBodyDynamicsWorld.cpp:880
btMultiBodyDynamicsWorld::applyGravity
virtual void applyGravity()
apply gravity, call this once per timestep
Definition: btMultiBodyDynamicsWorld.cpp:755
btMultiBodyDynamicsWorld::setMultiBodyConstraintSolver
virtual void setMultiBodyConstraintSolver(btMultiBodyConstraintSolver *solver)
Definition: btMultiBodyDynamicsWorld.cpp:199
btMultiBodyDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btMultiBodyDynamicsWorld.cpp:679
btMultiBodyLinkCollider
Definition: btMultiBodyLinkCollider.h:33
btMultiBody
Definition: btMultiBody.h:51
btMultiBody::updateCollisionObjectInterpolationWorldTransforms
void updateCollisionObjectInterpolationWorldTransforms(btAlignedObjectArray< btQuaternion > &world_to_local, btAlignedObjectArray< btVector3 > &local_origin)
Definition: btMultiBody.cpp:2225
btMultiBody::isAwake
bool isAwake() const
Definition: btMultiBody.h:548
btMultiBody::getBasePos
const btVector3 & getBasePos() const
Definition: btMultiBody.h:185
btMultiBody::serialize
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btMultiBody.cpp:2290
btMultiBody::predictPositionsMultiDof
void predictPositionsMultiDof(btScalar dt)
Definition: btMultiBody.cpp:1594
btMultiBody::clearVelocities
void clearVelocities()
Definition: btMultiBody.cpp:617
btMultiBody::computeAccelerationsArticulatedBodyAlgorithmMultiDof
void computeAccelerationsArticulatedBodyAlgorithmMultiDof(btScalar dt, btAlignedObjectArray< btScalar > &scratch_r, btAlignedObjectArray< btVector3 > &scratch_v, btAlignedObjectArray< btMatrix3x3 > &scratch_m, bool isConstraintPass, bool jointFeedbackInWorldSpace, bool jointFeedbackInJointFrame)
Definition: btMultiBody.cpp:728
btMultiBody::getNumLinks
int getNumLinks() const
Definition: btMultiBody.h:166
btMultiBody::stepPositionsMultiDof
void stepPositionsMultiDof(btScalar dt, btScalar *pq=0, btScalar *pqd=0)
Definition: btMultiBody.cpp:1786
btMultiBody::getLink
const btMultibodyLink & getLink(int index) const
Definition: btMultiBody.h:114
btMultiBody::checkMotionAndSleepIfRequired
void checkMotionAndSleepIfRequired(btScalar timestep)
Definition: btMultiBody.cpp:2091
btMultiBody::isBaseKinematic
bool isBaseKinematic() const
Definition: btMultiBody.cpp:690
btMultiBody::getLinkMass
btScalar getLinkMass(int i) const
Definition: btMultiBody.cpp:368
btMultiBody::getNumDofs
int getNumDofs() const
Definition: btMultiBody.h:167
btMultiBody::addLinkForce
void addLinkForce(int i, const btVector3 &f)
Definition: btMultiBody.cpp:624
btMultiBody::addSplitV
void addSplitV()
Definition: btMultiBody.h:442
btMultiBody::updateCollisionObjectWorldTransforms
void updateCollisionObjectWorldTransforms(btAlignedObjectArray< btQuaternion > &world_to_local, btAlignedObjectArray< btVector3 > &local_origin)
Definition: btMultiBody.cpp:2172
btMultiBody::hasFixedBase
bool hasFixedBase() const
Definition: btMultiBody.cpp:680
btMultiBody::processDeltaVeeMultiDof2
void processDeltaVeeMultiDof2()
Definition: btMultiBody.h:455
btMultiBody::clearConstraintForces
void clearConstraintForces()
Definition: btMultiBody.cpp:593
btMultiBody::setPosUpdated
void setPosUpdated(bool updated)
Definition: btMultiBody.h:651
btMultiBody::isUsingRK4Integration
bool isUsingRK4Integration() const
Definition: btMultiBody.h:643
btMultiBody::getBaseCollider
const btMultiBodyLinkCollider * getBaseCollider() const
Definition: btMultiBody.h:128
btMultiBody::internalNeedsJointFeedback
bool internalNeedsJointFeedback() const
Definition: btMultiBody.h:657
btMultiBody::getBaseWorldTransform
btTransform getBaseWorldTransform() const
Definition: btMultiBody.h:228
btMultiBody::getBaseMass
btScalar getBaseMass() const
Definition: btMultiBody.h:169
btMultiBody::getNumPosVars
int getNumPosVars() const
Definition: btMultiBody.h:168
btMultiBody::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btMultiBody.cpp:2283
btMultiBody::substractSplitV
void substractSplitV()
Definition: btMultiBody.h:446
btMultiBody::isPosUpdated
bool isPosUpdated() const
Definition: btMultiBody.h:647
btMultiBody::getWorldToBaseRot
const btQuaternion & getWorldToBaseRot() const
Definition: btMultiBody.h:193
btMultiBody::forwardKinematics
void forwardKinematics(btAlignedObjectArray< btQuaternion > &world_to_local, btAlignedObjectArray< btVector3 > &local_origin)
Definition: btMultiBody.cpp:2129
btMultiBody::applyDeltaVeeMultiDof
void applyDeltaVeeMultiDof(const btScalar *delta_vee, btScalar multiplier)
Definition: btMultiBody.h:465
btMultiBody::addBaseForce
void addBaseForce(const btVector3 &f)
Definition: btMultiBody.h:355
btMultiBody::saveKinematicState
void saveKinematicState(btScalar timeStep)
Definition: btMultiBody.cpp:2385
btMultiBody::getVelocityVector
const btScalar * getVelocityVector() const
Definition: btMultiBody.h:302
btMultiBody::clearForcesAndTorques
void clearForcesAndTorques()
Definition: btMultiBody.cpp:604
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition: btPersistentManifold.h:65
btPersistentManifold::getBody0
const btCollisionObject * getBody0() const
Definition: btPersistentManifold.h:105
btPersistentManifold::getBody1
const btCollisionObject * getBody1() const
Definition: btPersistentManifold.h:106
btQuadWord::w
const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
btQuadWord::z
const btScalar & z() const
Return the z value.
Definition: btQuadWord.h:117
btQuadWord::y
const btScalar & y() const
Return the y value.
Definition: btQuadWord.h:115
btQuadWord::x
const btScalar & x() const
Return the x value.
Definition: btQuadWord.h:113
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:60
btSerializer
Definition: btSerializer.h:66
btSerializer::allocate
virtual btChunk * allocate(size_t size, int numElements)=0
btSerializer::finishSerialization
virtual void finishSerialization()=0
btSerializer::startSerialization
virtual void startSerialization()=0
btSerializer::finalizeChunk
virtual void finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)=0
btSimulationIslandManager::storeIslandActivationState
virtual void storeIslandActivationState(btCollisionWorld *world)
Definition: btSimulationIslandManager.cpp:141
btSimulationIslandManager::updateActivationState
virtual void updateActivationState(btCollisionWorld *colWorld, btDispatcher *dispatcher)
Definition: btSimulationIslandManager.cpp:119
btSimulationIslandManager::buildAndProcessIslands
void buildAndProcessIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, IslandCallback *callback)
Definition: btSimulationIslandManager.cpp:343
btSimulationIslandManager::getUnionFind
btUnionFind & getUnionFind()
Definition: btSimulationIslandManager.h:45
btSortConstraintOnIslandPredicate2
Definition: btMultiBodyInplaceSolverIslandCallback.h:32
btSortMultiBodyConstraintOnIslandPredicate
Definition: btMultiBodyInplaceSolverIslandCallback.h:54
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
btTransform::getRotation
btQuaternion getRotation() const
Return a quaternion representing the rotation.
Definition: btTransform.h:119
btTransform::getOrigin
btVector3 & getOrigin()
Return the origin vector translation.
Definition: btTransform.h:114
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:76
btTypedConstraint::isEnabled
bool isEnabled() const
Definition: btTypedConstraint.h:201
btTypedConstraint::getRigidBodyA
const btRigidBody & getRigidBodyA() const
Definition: btTypedConstraint.h:214
btTypedConstraint::getRigidBodyB
const btRigidBody & getRigidBodyB() const
Definition: btTypedConstraint.h:218
btUnionFind::unite
void unite(int p, int q)
Definition: btUnionFind.h:76
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
btVector3::z
const btScalar & z() const
Return the z value.
Definition: btVector3.h:579
btVector3::x
const btScalar & x() const
Return the x value.
Definition: btVector3.h:575
btVector3::y
const btScalar & y() const
Return the y value.
Definition: btVector3.h:577
btVector4
Definition: btVector3.h:1074
MultiBodyInplaceSolverIslandCallback
Definition: btMultiBodyInplaceSolverIslandCallback.h:66
MultiBodyInplaceSolverIslandCallback::processConstraints
virtual void processConstraints(int islandId=-1)
Definition: btMultiBodyInplaceSolverIslandCallback.h:223
MultiBodyInplaceSolverIslandCallback::setup
virtual void setup(btContactSolverInfo *solverInfo, btTypedConstraint **sortedConstraints, int numConstraints, btMultiBodyConstraint **sortedMultiBodyConstraints, int numMultiBodyConstraints, btIDebugDraw *debugDrawer)
Definition: btMultiBodyInplaceSolverIslandCallback.h:104
MultiBodyInplaceSolverIslandCallback::setMultiBodyConstraintSolver
void setMultiBodyConstraintSolver(btMultiBodyConstraintSolver *solver)
Definition: btMultiBodyInplaceSolverIslandCallback.h:122
MultiBodyInplaceSolverIslandCallback::m_islandAnalyticsData
btAlignedObjectArray< btSolverAnalyticsData > m_islandAnalyticsData
Definition: btMultiBodyInplaceSolverIslandCallback.h:84
btContactSolverInfoData::m_jointFeedbackInJointFrame
bool m_jointFeedbackInJointFrame
Definition: btContactSolverInfo.h:70
btContactSolverInfoData::m_jointFeedbackInWorldSpace
bool m_jointFeedbackInWorldSpace
Definition: btContactSolverInfo.h:69
btContactSolverInfoData::m_solverMode
int m_solverMode
Definition: btContactSolverInfo.h:62
btContactSolverInfoData::m_timeStep
btScalar m_timeStep
Definition: btContactSolverInfo.h:42
btContactSolverInfo
Definition: btContactSolverInfo.h:76
btMultibodyLink::m_collider
class btMultiBodyLinkCollider * m_collider
Definition: btMultiBodyLink.h:132
btMultibodyLink::m_jointType
eFeatherstoneJointType m_jointType
Definition: btMultiBodyLink.h:137
btMultibodyLink::ePrismatic
@ ePrismatic
Definition: btMultiBodyLink.h:73
btMultibodyLink::eRevolute
@ eRevolute
Definition: btMultiBodyLink.h:72
btMultibodyLink::eFixed
@ eFixed
Definition: btMultiBodyLink.h:76
btMultibodyLink::m_cachedWorldTransform
btTransform m_cachedWorldTransform
Definition: btMultiBodyLink.h:141
btMultibodyLink::updateCacheMultiDof
void updateCacheMultiDof(btScalar *pq=0)
Definition: btMultiBodyLink.h:196
btMultibodyLink::m_jointPos
btScalar m_jointPos[7]
Definition: btMultiBodyLink.h:125
btMultibodyLink::m_dVector
btVector3 m_dVector
Definition: btMultiBodyLink.h:58
btMultibodyLink::m_cfgOffset
int m_cfgOffset
Definition: btMultiBodyLink.h:110
btMultibodyLink::m_axes
btSpatialMotionVector m_axes[6]
Definition: btMultiBodyLink.h:93
btSpatialMotionVector::m_bottomVec
btVector3 m_bottomVec
Definition: btSpatialAlgebra.h:96
btSpatialMotionVector::m_topVec
btVector3 m_topVec
Definition: btSpatialAlgebra.h:96