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

Bullet Collision Detection & Physics Library

btDiscreteDynamicsWorld.cpp
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10
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
17 #include "btDiscreteDynamicsWorld.h"
18
19 //collision detection
20 #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
21 #include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
22 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
23 #include "BulletCollision/CollisionShapes/btCollisionShape.h"
24 #include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
25 #include "LinearMath/btTransformUtil.h"
26 #include "LinearMath/btQuickprof.h"
27
28 //rigidbody & constraints
29 #include "BulletDynamics/Dynamics/btRigidBody.h"
30 #include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
31 #include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
32 #include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
33 #include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h"
34 #include "BulletDynamics/ConstraintSolver/btHingeConstraint.h"
35 #include "BulletDynamics/ConstraintSolver/btConeTwistConstraint.h"
36 #include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"
37 #include "BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.h"
38 #include "BulletDynamics/ConstraintSolver/btSliderConstraint.h"
39 #include "BulletDynamics/ConstraintSolver/btContactConstraint.h"
40
41
42 #include "LinearMath/btIDebugDraw.h"
43 #include "BulletCollision/CollisionShapes/btSphereShape.h"
44
45
46 #include "BulletDynamics/Dynamics/btActionInterface.h"
47 #include "LinearMath/btQuickprof.h"
48 #include "LinearMath/btMotionState.h"
49
50 #include "LinearMath/btSerializer.h"
51
52 #if 0
53 btAlignedObjectArray<btVector3> debugContacts;
54 btAlignedObjectArray<btVector3> debugNormals;
55 int startHit=2;
56 int firstHit=startHit;
57 #endif
58
59 SIMD_FORCE_INLINE int btGetConstraintIslandId(const btTypedConstraint* lhs)
60 {
61 int islandId;
62
63 const btCollisionObject& rcolObj0 = lhs->getRigidBodyA();
64 const btCollisionObject& rcolObj1 = lhs->getRigidBodyB();
65 islandId= rcolObj0.getIslandTag()>=0?rcolObj0.getIslandTag():rcolObj1.getIslandTag();
66 return islandId;
67
68 }
69
70
71 class btSortConstraintOnIslandPredicate
72 {
73 public:
74
75 bool operator() ( const btTypedConstraint* lhs, const btTypedConstraint* rhs ) const
76 {
77 int rIslandId0,lIslandId0;
78 rIslandId0 = btGetConstraintIslandId(rhs);
79 lIslandId0 = btGetConstraintIslandId(lhs);
80 return lIslandId0 < rIslandId0;
81 }
82 };
83
84 struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCallback
85 {
86 btContactSolverInfo* m_solverInfo;
87 btConstraintSolver* m_solver;
88 btTypedConstraint** m_sortedConstraints;
89 int m_numConstraints;
90 btIDebugDraw* m_debugDrawer;
91 btDispatcher* m_dispatcher;
92
93 btAlignedObjectArray<btCollisionObject*> m_bodies;
94 btAlignedObjectArray<btPersistentManifold*> m_manifolds;
95 btAlignedObjectArray<btTypedConstraint*> m_constraints;
96
97
98 InplaceSolverIslandCallback(
99 btConstraintSolver* solver,
100 btStackAlloc* stackAlloc,
101 btDispatcher* dispatcher)
102 :m_solverInfo(NULL),
103 m_solver(solver),
104 m_sortedConstraints(NULL),
105 m_numConstraints(0),
106 m_debugDrawer(NULL),
107 m_dispatcher(dispatcher)
108 {
109
110 }
111
112 InplaceSolverIslandCallback& operator=(InplaceSolverIslandCallback& other)
113 {
114 btAssert(0);
115 (void)other;
116 return *this;
117 }
118
119 SIMD_FORCE_INLINE void setup ( btContactSolverInfo* solverInfo, btTypedConstraint** sortedConstraints, int numConstraints, btIDebugDraw* debugDrawer)
120 {
121 btAssert(solverInfo);
122 m_solverInfo = solverInfo;
123 m_sortedConstraints = sortedConstraints;
124 m_numConstraints = numConstraints;
125 m_debugDrawer = debugDrawer;
126 m_bodies.resize (0);
127 m_manifolds.resize (0);
128 m_constraints.resize (0);
129 }
130
131
132 virtual void processIsland(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifolds,int numManifolds, int islandId)
133 {
134 if (islandId<0)
135 {
137 m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,&m_sortedConstraints[0],m_numConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher);
138 } else
139 {
140 //also add all non-contact constraints/joints for this island
141 btTypedConstraint** startConstraint = 0;
142 int numCurConstraints = 0;
143 int i;
144
145 //find the first constraint for this island
146 for (i=0;i<m_numConstraints;i++)
147 {
148 if (btGetConstraintIslandId(m_sortedConstraints[i]) == islandId)
149 {
150 startConstraint = &m_sortedConstraints[i];
151 break;
152 }
153 }
154 //count the number of constraints in this island
155 for (;i<m_numConstraints;i++)
156 {
157 if (btGetConstraintIslandId(m_sortedConstraints[i]) == islandId)
158 {
159 numCurConstraints++;
160 }
161 }
162
163 if (m_solverInfo->m_minimumSolverBatchSize<=1)
164 {
165 m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher);
166 } else
167 {
168
169 for (i=0;i<numBodies;i++)
170 m_bodies.push_back(bodies[i]);
171 for (i=0;i<numManifolds;i++)
172 m_manifolds.push_back(manifolds[i]);
173 for (i=0;i<numCurConstraints;i++)
174 m_constraints.push_back(startConstraint[i]);
175 if ((m_constraints.size()+m_manifolds.size())>m_solverInfo->m_minimumSolverBatchSize)
176 {
177 processConstraints();
178 } else
179 {
180 //printf("deferred\n");
181 }
182 }
183 }
184 }
185 void processConstraints()
186 {
187
188 btCollisionObject** bodies = m_bodies.size()? &m_bodies[0]:0;
189 btPersistentManifold** manifold = m_manifolds.size()?&m_manifolds[0]:0;
190 btTypedConstraint** constraints = m_constraints.size()?&m_constraints[0]:0;
191
192 m_solver->solveGroup( bodies,m_bodies.size(),manifold, m_manifolds.size(),constraints, m_constraints.size() ,*m_solverInfo,m_debugDrawer,m_dispatcher);
193 m_bodies.resize(0);
194 m_manifolds.resize(0);
195 m_constraints.resize(0);
196
197 }
198
199 };
200
201
202
203 btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver, btCollisionConfiguration* collisionConfiguration)
204 :btDynamicsWorld(dispatcher,pairCache,collisionConfiguration),
205 m_sortedConstraints (),
206 m_solverIslandCallback ( NULL ),
207 m_constraintSolver(constraintSolver),
208 m_gravity(0,-10,0),
209 m_localTime(0),
210 m_fixedTimeStep(0),
211 m_synchronizeAllMotionStates(false),
212 m_applySpeculativeContactRestitution(false),
213 m_profileTimings(0),
214 m_latencyMotionStateInterpolation(true)
215
216 {
217 if (!m_constraintSolver)
218 {
219 void* mem = btAlignedAlloc(sizeof(btSequentialImpulseConstraintSolver),16);
220 m_constraintSolver = new (mem) btSequentialImpulseConstraintSolver;
221 m_ownsConstraintSolver = true;
222 } else
223 {
224 m_ownsConstraintSolver = false;
225 }
226
227 {
228 void* mem = btAlignedAlloc(sizeof(btSimulationIslandManager),16);
229 m_islandManager = new (mem) btSimulationIslandManager();
230 }
231
232 m_ownsIslandManager = true;
233
234 {
235 void* mem = btAlignedAlloc(sizeof(InplaceSolverIslandCallback),16);
236 m_solverIslandCallback = new (mem) InplaceSolverIslandCallback (m_constraintSolver, 0, dispatcher);
237 }
238 }
239
240
241 btDiscreteDynamicsWorld::~btDiscreteDynamicsWorld()
242 {
243 //only delete it when we created it
244 if (m_ownsIslandManager)
245 {
246 m_islandManager->~btSimulationIslandManager();
247 btAlignedFree( m_islandManager);
248 }
249 if (m_solverIslandCallback)
250 {
251 m_solverIslandCallback->~InplaceSolverIslandCallback();
252 btAlignedFree(m_solverIslandCallback);
253 }
254 if (m_ownsConstraintSolver)
255 {
256
257 m_constraintSolver->~btConstraintSolver();
258 btAlignedFree(m_constraintSolver);
259 }
260 }
261
262 void btDiscreteDynamicsWorld::saveKinematicState(btScalar timeStep)
263 {
267 for (int i=0;i<m_collisionObjects.size();i++)
268 {
269 btCollisionObject* colObj = m_collisionObjects[i];
270 btRigidBody* body = btRigidBody::upcast(colObj);
271 if (body && body->getActivationState() != ISLAND_SLEEPING)
272 {
273 if (body->isKinematicObject())
274 {
275 //to calculate velocities next frame
276 body->saveKinematicState(timeStep);
277 }
278 }
279 }
280
281 }
282
283 void btDiscreteDynamicsWorld::debugDrawWorld()
284 {
285 BT_PROFILE("debugDrawWorld");
286
287 btCollisionWorld::debugDrawWorld();
288
289 bool drawConstraints = false;
290 if (getDebugDrawer())
291 {
292 int mode = getDebugDrawer()->getDebugMode();
293 if(mode & (btIDebugDraw::DBG_DrawConstraints | btIDebugDraw::DBG_DrawConstraintLimits))
294 {
295 drawConstraints = true;
296 }
297 }
298 if(drawConstraints)
299 {
300 for(int i = getNumConstraints()-1; i>=0 ;i--)
301 {
302 btTypedConstraint* constraint = getConstraint(i);
303 debugDrawConstraint(constraint);
304 }
305 }
306
307
308
309 if (getDebugDrawer() && (getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb | btIDebugDraw::DBG_DrawNormals)))
310 {
311 int i;
312
313 if (getDebugDrawer() && getDebugDrawer()->getDebugMode())
314 {
315 for (i=0;i<m_actions.size();i++)
316 {
317 m_actions[i]->debugDraw(m_debugDrawer);
318 }
319 }
320 }
321 if (getDebugDrawer())
322 getDebugDrawer()->flushLines();
323
324 }
325
326 void btDiscreteDynamicsWorld::clearForces()
327 {
329 for ( int i=0;i<m_nonStaticRigidBodies.size();i++)
330 {
331 btRigidBody* body = m_nonStaticRigidBodies[i];
332 //need to check if next line is ok
333 //it might break backward compatibility (people applying forces on sleeping objects get never cleared and accumulate on wake-up
334 body->clearForces();
335 }
336 }
337
339 void btDiscreteDynamicsWorld::applyGravity()
340 {
342 for ( int i=0;i<m_nonStaticRigidBodies.size();i++)
343 {
344 btRigidBody* body = m_nonStaticRigidBodies[i];
345 if (body->isActive())
346 {
347 body->applyGravity();
348 }
349 }
350 }
351
352
353 void btDiscreteDynamicsWorld::synchronizeSingleMotionState(btRigidBody* body)
354 {
355 btAssert(body);
356
357 if (body->getMotionState() && !body->isStaticOrKinematicObject())
358 {
359 //we need to call the update at least once, even for sleeping objects
360 //otherwise the 'graphics' transform never updates properly
362 //if (body->getActivationState() != ISLAND_SLEEPING)
363 {
364 btTransform interpolatedTransform;
365 btTransformUtil::integrateTransform(body->getInterpolationWorldTransform(),
366 body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),
367 (m_latencyMotionStateInterpolation && m_fixedTimeStep) ? m_localTime - m_fixedTimeStep : m_localTime*body->getHitFraction(),
368 interpolatedTransform);
369 body->getMotionState()->setWorldTransform(interpolatedTransform);
370 }
371 }
372 }
373
374
375 void btDiscreteDynamicsWorld::synchronizeMotionStates()
376 {
377 // BT_PROFILE("synchronizeMotionStates");
378 if (m_synchronizeAllMotionStates)
379 {
380 //iterate over all collision objects
381 for ( int i=0;i<m_collisionObjects.size();i++)
382 {
383 btCollisionObject* colObj = m_collisionObjects[i];
384 btRigidBody* body = btRigidBody::upcast(colObj);
385 if (body)
386 synchronizeSingleMotionState(body);
387 }
388 } else
389 {
390 //iterate over all active rigid bodies
391 for ( int i=0;i<m_nonStaticRigidBodies.size();i++)
392 {
393 btRigidBody* body = m_nonStaticRigidBodies[i];
394 if (body->isActive())
395 synchronizeSingleMotionState(body);
396 }
397 }
398 }
399
400
401 int btDiscreteDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, btScalar fixedTimeStep)
402 {
403 startProfiling(timeStep);
404
405
406 int numSimulationSubSteps = 0;
407
408 if (maxSubSteps)
409 {
410 //fixed timestep with interpolation
411 m_fixedTimeStep = fixedTimeStep;
412 m_localTime += timeStep;
413 if (m_localTime >= fixedTimeStep)
414 {
415 numSimulationSubSteps = int( m_localTime / fixedTimeStep);
416 m_localTime -= numSimulationSubSteps * fixedTimeStep;
417 }
418 } else
419 {
420 //variable timestep
421 fixedTimeStep = timeStep;
422 m_localTime = m_latencyMotionStateInterpolation ? 0 : timeStep;
423 m_fixedTimeStep = 0;
424 if (btFuzzyZero(timeStep))
425 {
426 numSimulationSubSteps = 0;
427 maxSubSteps = 0;
428 } else
429 {
430 numSimulationSubSteps = 1;
431 maxSubSteps = 1;
432 }
433 }
434
435 //process some debugging flags
436 if (getDebugDrawer())
437 {
438 btIDebugDraw* debugDrawer = getDebugDrawer ();
439 gDisableDeactivation = (debugDrawer->getDebugMode() & btIDebugDraw::DBG_NoDeactivation) != 0;
440 }
441 if (numSimulationSubSteps)
442 {
443
444 //clamp the number of substeps, to prevent simulation grinding spiralling down to a halt
445 int clampedSimulationSteps = (numSimulationSubSteps > maxSubSteps)? maxSubSteps : numSimulationSubSteps;
446
447 saveKinematicState(fixedTimeStep*clampedSimulationSteps);
448
449 applyGravity();
450
451
452
453 for (int i=0;i<clampedSimulationSteps;i++)
454 {
455 internalSingleStepSimulation(fixedTimeStep);
456 synchronizeMotionStates();
457 }
458
459 } else
460 {
461 synchronizeMotionStates();
462 }
463
464 clearForces();
465
466 #ifndef BT_NO_PROFILE
467 CProfileManager::Increment_Frame_Counter();
468 #endif //BT_NO_PROFILE
469
470 return numSimulationSubSteps;
471 }
472
473 void btDiscreteDynamicsWorld::internalSingleStepSimulation(btScalar timeStep)
474 {
475
476 BT_PROFILE("internalSingleStepSimulation");
477
478 if(0 != m_internalPreTickCallback) {
479 (*m_internalPreTickCallback)(this, timeStep);
480 }
481
483 predictUnconstraintMotion(timeStep);
484
485 btDispatcherInfo& dispatchInfo = getDispatchInfo();
486
487 dispatchInfo.m_timeStep = timeStep;
488 dispatchInfo.m_stepCount = 0;
489 dispatchInfo.m_debugDraw = getDebugDrawer();
490
491
492 createPredictiveContacts(timeStep);
493
495 performDiscreteCollisionDetection();
496
497 calculateSimulationIslands();
498
499
500 getSolverInfo().m_timeStep = timeStep;
501
502
503
505 solveConstraints(getSolverInfo());
506
508
510
511 integrateTransforms(timeStep);
512
514 updateActions(timeStep);
515
516 updateActivationState( timeStep );
517
518 if(0 != m_internalTickCallback) {
519 (*m_internalTickCallback)(this, timeStep);
520 }
521 }
522
523 void btDiscreteDynamicsWorld::setGravity(const btVector3& gravity)
524 {
525 m_gravity = gravity;
526 for ( int i=0;i<m_nonStaticRigidBodies.size();i++)
527 {
528 btRigidBody* body = m_nonStaticRigidBodies[i];
529 if (body->isActive() && !(body->getFlags() &BT_DISABLE_WORLD_GRAVITY))
530 {
531 body->setGravity(gravity);
532 }
533 }
534 }
535
536 btVector3 btDiscreteDynamicsWorld::getGravity () const
537 {
538 return m_gravity;
539 }
540
541 void btDiscreteDynamicsWorld::addCollisionObject(btCollisionObject* collisionObject, int collisionFilterGroup, int collisionFilterMask)
542 {
543 btCollisionWorld::addCollisionObject(collisionObject,collisionFilterGroup,collisionFilterMask);
544 }
545
546 void btDiscreteDynamicsWorld::removeCollisionObject(btCollisionObject* collisionObject)
547 {
548 btRigidBody* body = btRigidBody::upcast(collisionObject);
549 if (body)
550 removeRigidBody(body);
551 else
552 btCollisionWorld::removeCollisionObject(collisionObject);
553 }
554
555 void btDiscreteDynamicsWorld::removeRigidBody(btRigidBody* body)
556 {
557 m_nonStaticRigidBodies.remove(body);
558 btCollisionWorld::removeCollisionObject(body);
559 }
560
561
562 void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body)
563 {
564 if (!body->isStaticOrKinematicObject() && !(body->getFlags() &BT_DISABLE_WORLD_GRAVITY))
565 {
566 body->setGravity(m_gravity);
567 }
568
569 if (body->getCollisionShape())
570 {
571 if (!body->isStaticObject())
572 {
573 m_nonStaticRigidBodies.push_back(body);
574 } else
575 {
576 body->setActivationState(ISLAND_SLEEPING);
577 }
578
579 bool isDynamic = !(body->isStaticObject() || body->isKinematicObject());
580 int collisionFilterGroup = isDynamic? int(btBroadphaseProxy::DefaultFilter) : int(btBroadphaseProxy::StaticFilter);
581 int collisionFilterMask = isDynamic? int(btBroadphaseProxy::AllFilter) : int(btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
582
583 addCollisionObject(body,collisionFilterGroup,collisionFilterMask);
584 }
585 }
586
587 void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body, int group, int mask)
588 {
589 if (!body->isStaticOrKinematicObject() && !(body->getFlags() &BT_DISABLE_WORLD_GRAVITY))
590 {
591 body->setGravity(m_gravity);
592 }
593
594 if (body->getCollisionShape())
595 {
596 if (!body->isStaticObject())
597 {
598 m_nonStaticRigidBodies.push_back(body);
599 }
600 else
601 {
602 body->setActivationState(ISLAND_SLEEPING);
603 }
604 addCollisionObject(body,group,mask);
605 }
606 }
607
608
609 void btDiscreteDynamicsWorld::updateActions(btScalar timeStep)
610 {
611 BT_PROFILE("updateActions");
612
613 for ( int i=0;i<m_actions.size();i++)
614 {
615 m_actions[i]->updateAction( this, timeStep);
616 }
617 }
618
619
620 void btDiscreteDynamicsWorld::updateActivationState(btScalar timeStep)
621 {
622 BT_PROFILE("updateActivationState");
623
624 for ( int i=0;i<m_nonStaticRigidBodies.size();i++)
625 {
626 btRigidBody* body = m_nonStaticRigidBodies[i];
627 if (body)
628 {
629 body->updateDeactivation(timeStep);
630
631 if (body->wantsSleeping())
632 {
633 if (body->isStaticOrKinematicObject())
634 {
635 body->setActivationState(ISLAND_SLEEPING);
636 } else
637 {
638 if (body->getActivationState() == ACTIVE_TAG)
639 body->setActivationState( WANTS_DEACTIVATION );
640 if (body->getActivationState() == ISLAND_SLEEPING)
641 {
642 body->setAngularVelocity(btVector3(0,0,0));
643 body->setLinearVelocity(btVector3(0,0,0));
644 }
645
646 }
647 } else
648 {
649 if (body->getActivationState() != DISABLE_DEACTIVATION)
650 body->setActivationState( ACTIVE_TAG );
651 }
652 }
653 }
654 }
655
656 void btDiscreteDynamicsWorld::addConstraint(btTypedConstraint* constraint,bool disableCollisionsBetweenLinkedBodies)
657 {
658 m_constraints.push_back(constraint);
659 //Make sure the two bodies of a type constraint are different (possibly add this to the btTypedConstraint constructor?)
660 btAssert(&constraint->getRigidBodyA()!=&constraint->getRigidBodyB());
661
662 if (disableCollisionsBetweenLinkedBodies)
663 {
664 constraint->getRigidBodyA().addConstraintRef(constraint);
665 constraint->getRigidBodyB().addConstraintRef(constraint);
666 }
667 }
668
669 void btDiscreteDynamicsWorld::removeConstraint(btTypedConstraint* constraint)
670 {
671 m_constraints.remove(constraint);
672 constraint->getRigidBodyA().removeConstraintRef(constraint);
673 constraint->getRigidBodyB().removeConstraintRef(constraint);
674 }
675
676 void btDiscreteDynamicsWorld::addAction(btActionInterface* action)
677 {
678 m_actions.push_back(action);
679 }
680
681 void btDiscreteDynamicsWorld::removeAction(btActionInterface* action)
682 {
683 m_actions.remove(action);
684 }
685
686
687 void btDiscreteDynamicsWorld::addVehicle(btActionInterface* vehicle)
688 {
689 addAction(vehicle);
690 }
691
692 void btDiscreteDynamicsWorld::removeVehicle(btActionInterface* vehicle)
693 {
694 removeAction(vehicle);
695 }
696
697 void btDiscreteDynamicsWorld::addCharacter(btActionInterface* character)
698 {
699 addAction(character);
700 }
701
702 void btDiscreteDynamicsWorld::removeCharacter(btActionInterface* character)
703 {
704 removeAction(character);
705 }
706
707
708
709
710 void btDiscreteDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo)
711 {
712 BT_PROFILE("solveConstraints");
713
714 m_sortedConstraints.resize( m_constraints.size());
715 int i;
716 for (i=0;i<getNumConstraints();i++)
717 {
718 m_sortedConstraints[i] = m_constraints[i];
719 }
720
721 // btAssert(0);
722
723
724
725 m_sortedConstraints.quickSort(btSortConstraintOnIslandPredicate());
726
727 btTypedConstraint** constraintsPtr = getNumConstraints() ? &m_sortedConstraints[0] : 0;
728
729 m_solverIslandCallback->setup(&solverInfo,constraintsPtr,m_sortedConstraints.size(),getDebugDrawer());
730 m_constraintSolver->prepareSolve(getCollisionWorld()->getNumCollisionObjects(), getCollisionWorld()->getDispatcher()->getNumManifolds());
731
733 m_islandManager->buildAndProcessIslands(getCollisionWorld()->getDispatcher(),getCollisionWorld(),m_solverIslandCallback);
734
735 m_solverIslandCallback->processConstraints();
736
737 m_constraintSolver->allSolved(solverInfo, m_debugDrawer);
738 }
739
740
741 void btDiscreteDynamicsWorld::calculateSimulationIslands()
742 {
743 BT_PROFILE("calculateSimulationIslands");
744
745 getSimulationIslandManager()->updateActivationState(getCollisionWorld(),getCollisionWorld()->getDispatcher());
746
747 {
748 //merge islands based on speculative contact manifolds too
749 for (int i=0;i<this->m_predictiveManifolds.size();i++)
750 {
751 btPersistentManifold* manifold = m_predictiveManifolds[i];
752
753 const btCollisionObject* colObj0 = manifold->getBody0();
754 const btCollisionObject* colObj1 = manifold->getBody1();
755
756 if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
757 ((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
758 {
759 getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag());
760 }
761 }
762 }
763
764 {
765 int i;
766 int numConstraints = int(m_constraints.size());
767 for (i=0;i< numConstraints ; i++ )
768 {
769 btTypedConstraint* constraint = m_constraints[i];
770 if (constraint->isEnabled())
771 {
772 const btRigidBody* colObj0 = &constraint->getRigidBodyA();
773 const btRigidBody* colObj1 = &constraint->getRigidBodyB();
774
775 if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
776 ((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
777 {
778 getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag());
779 }
780 }
781 }
782 }
783
784 //Store the island id in each body
785 getSimulationIslandManager()->storeIslandActivationState(getCollisionWorld());
786
787
788 }
789
790
791
792
793 class btClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback
794 {
795 public:
796
797 btCollisionObject* m_me;
798 btScalar m_allowedPenetration;
799 btOverlappingPairCache* m_pairCache;
800 btDispatcher* m_dispatcher;
801
802 public:
803 btClosestNotMeConvexResultCallback (btCollisionObject* me,const btVector3& fromA,const btVector3& toA,btOverlappingPairCache* pairCache,btDispatcher* dispatcher) :
804 btCollisionWorld::ClosestConvexResultCallback(fromA,toA),
805 m_me(me),
806 m_allowedPenetration(0.0f),
807 m_pairCache(pairCache),
808 m_dispatcher(dispatcher)
809 {
810 }
811
812 virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult,bool normalInWorldSpace)
813 {
814 if (convexResult.m_hitCollisionObject == m_me)
815 return 1.0f;
816
817 //ignore result if there is no contact response
818 if(!convexResult.m_hitCollisionObject->hasContactResponse())
819 return 1.0f;
820
821 btVector3 linVelA,linVelB;
822 linVelA = m_convexToWorld-m_convexFromWorld;
823 linVelB = btVector3(0,0,0);//toB.getOrigin()-fromB.getOrigin();
824
825 btVector3 relativeVelocity = (linVelA-linVelB);
826 //don't report time of impact for motion away from the contact normal (or causes minor penetration)
827 if (convexResult.m_hitNormalLocal.dot(relativeVelocity)>=-m_allowedPenetration)
828 return 1.f;
829
830 return ClosestConvexResultCallback::addSingleResult (convexResult, normalInWorldSpace);
831 }
832
833 virtual bool needsCollision(btBroadphaseProxy* proxy0) const
834 {
835 //don't collide with itself
836 if (proxy0->m_clientObject == m_me)
837 return false;
838
840 if (!ClosestConvexResultCallback::needsCollision(proxy0))
841 return false;
842
843 btCollisionObject* otherObj = (btCollisionObject*) proxy0->m_clientObject;
844
845 //call needsResponse, see http://code.google.com/p/bullet/issues/detail?id=179
846 if (m_dispatcher->needsResponse(m_me,otherObj))
847 {
848 #if 0
849 btAlignedObjectArray<btPersistentManifold*> manifoldArray;
851 btBroadphasePair* collisionPair = m_pairCache->findPair(m_me->getBroadphaseHandle(),proxy0);
852 if (collisionPair)
853 {
854 if (collisionPair->m_algorithm)
855 {
856 manifoldArray.resize(0);
857 collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);
858 for (int j=0;j<manifoldArray.size();j++)
859 {
860 btPersistentManifold* manifold = manifoldArray[j];
861 if (manifold->getNumContacts()>0)
862 return false;
863 }
864 }
865 }
866 #endif
867 return true;
868 }
869
870 return false;
871 }
872
873
874 };
875
877 int gNumClampedCcdMotions=0;
878
879
880 void btDiscreteDynamicsWorld::createPredictiveContactsInternal( btRigidBody** bodies, int numBodies, btScalar timeStep)
881 {
882 btTransform predictedTrans;
883 for ( int i=0;i<numBodies;i++)
884 {
885 btRigidBody* body = bodies[i];
886 body->setHitFraction(1.f);
887
888 if (body->isActive() && (!body->isStaticOrKinematicObject()))
889 {
890
891 body->predictIntegratedTransform(timeStep, predictedTrans);
892
893 btScalar squareMotion = (predictedTrans.getOrigin()-body->getWorldTransform().getOrigin()).length2();
894
895 if (getDispatchInfo().m_useContinuous && body->getCcdSquareMotionThreshold() && body->getCcdSquareMotionThreshold() < squareMotion)
896 {
897 BT_PROFILE("predictive convexSweepTest");
898 if (body->getCollisionShape()->isConvex())
899 {
900 gNumClampedCcdMotions++;
901 #ifdef PREDICTIVE_CONTACT_USE_STATIC_ONLY
902 class StaticOnlyCallback : public btClosestNotMeConvexResultCallback
903 {
904 public:
905
906 StaticOnlyCallback (btCollisionObject* me,const btVector3& fromA,const btVector3& toA,btOverlappingPairCache* pairCache,btDispatcher* dispatcher) :
907 btClosestNotMeConvexResultCallback(me,fromA,toA,pairCache,dispatcher)
908 {
909 }
910
911 virtual bool needsCollision(btBroadphaseProxy* proxy0) const
912 {
913 btCollisionObject* otherObj = (btCollisionObject*) proxy0->m_clientObject;
914 if (!otherObj->isStaticOrKinematicObject())
915 return false;
916 return btClosestNotMeConvexResultCallback::needsCollision(proxy0);
917 }
918 };
919
920 StaticOnlyCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache(),getDispatcher());
921 #else
922 btClosestNotMeConvexResultCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache(),getDispatcher());
923 #endif
924 //btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
925 btSphereShape tmpSphere(body->getCcdSweptSphereRadius());//btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
926 sweepResults.m_allowedPenetration=getDispatchInfo().m_allowedCcdPenetration;
927
928 sweepResults.m_collisionFilterGroup = body->getBroadphaseProxy()->m_collisionFilterGroup;
929 sweepResults.m_collisionFilterMask = body->getBroadphaseProxy()->m_collisionFilterMask;
930 btTransform modifiedPredictedTrans = predictedTrans;
931 modifiedPredictedTrans.setBasis(body->getWorldTransform().getBasis());
932
933 convexSweepTest(&tmpSphere,body->getWorldTransform(),modifiedPredictedTrans,sweepResults);
934 if (sweepResults.hasHit() && (sweepResults.m_closestHitFraction < 1.f))
935 {
936
937 btVector3 distVec = (predictedTrans.getOrigin()-body->getWorldTransform().getOrigin())*sweepResults.m_closestHitFraction;
938 btScalar distance = distVec.dot(-sweepResults.m_hitNormalWorld);
939
940
941 btPersistentManifold* manifold = m_dispatcher1->getNewManifold(body,sweepResults.m_hitCollisionObject);
942 btMutexLock( &m_predictiveManifoldsMutex );
943 m_predictiveManifolds.push_back(manifold);
944 btMutexUnlock( &m_predictiveManifoldsMutex );
945
946 btVector3 worldPointB = body->getWorldTransform().getOrigin()+distVec;
947 btVector3 localPointB = sweepResults.m_hitCollisionObject->getWorldTransform().inverse()*worldPointB;
948
949 btManifoldPoint newPoint(btVector3(0,0,0), localPointB,sweepResults.m_hitNormalWorld,distance);
950
951 bool isPredictive = true;
952 int index = manifold->addManifoldPoint(newPoint, isPredictive);
953 btManifoldPoint& pt = manifold->getContactPoint(index);
954 pt.m_combinedRestitution = 0;
955 pt.m_combinedFriction = btManifoldResult::calculateCombinedFriction(body,sweepResults.m_hitCollisionObject);
956 pt.m_positionWorldOnA = body->getWorldTransform().getOrigin();
957 pt.m_positionWorldOnB = worldPointB;
958
959 }
960 }
961 }
962 }
963 }
964 }
965
966 void btDiscreteDynamicsWorld::releasePredictiveContacts()
967 {
968 BT_PROFILE( "release predictive contact manifolds" );
969
970 for ( int i = 0; i < m_predictiveManifolds.size(); i++ )
971 {
972 btPersistentManifold* manifold = m_predictiveManifolds[ i ];
973 this->m_dispatcher1->releaseManifold( manifold );
974 }
975 m_predictiveManifolds.clear();
976 }
977
978 void btDiscreteDynamicsWorld::createPredictiveContacts(btScalar timeStep)
979 {
980 BT_PROFILE("createPredictiveContacts");
981 releasePredictiveContacts();
982 if (m_nonStaticRigidBodies.size() > 0)
983 {
984 createPredictiveContactsInternal( &m_nonStaticRigidBodies[ 0 ], m_nonStaticRigidBodies.size(), timeStep );
985 }
986 }
987
988 void btDiscreteDynamicsWorld::integrateTransformsInternal( btRigidBody** bodies, int numBodies, btScalar timeStep )
989 {
990 btTransform predictedTrans;
991 for (int i=0;i<numBodies;i++)
992 {
993 btRigidBody* body = bodies[i];
994 body->setHitFraction(1.f);
995
996 if (body->isActive() && (!body->isStaticOrKinematicObject()))
997 {
998
999 body->predictIntegratedTransform(timeStep, predictedTrans);
1000
1001 btScalar squareMotion = (predictedTrans.getOrigin()-body->getWorldTransform().getOrigin()).length2();
1002
1003
1004
1005 if (getDispatchInfo().m_useContinuous && body->getCcdSquareMotionThreshold() && body->getCcdSquareMotionThreshold() < squareMotion)
1006 {
1007 BT_PROFILE("CCD motion clamping");
1008 if (body->getCollisionShape()->isConvex())
1009 {
1010 gNumClampedCcdMotions++;
1011 #ifdef USE_STATIC_ONLY
1012 class StaticOnlyCallback : public btClosestNotMeConvexResultCallback
1013 {
1014 public:
1015
1016 StaticOnlyCallback (btCollisionObject* me,const btVector3& fromA,const btVector3& toA,btOverlappingPairCache* pairCache,btDispatcher* dispatcher) :
1017 btClosestNotMeConvexResultCallback(me,fromA,toA,pairCache,dispatcher)
1018 {
1019 }
1020
1021 virtual bool needsCollision(btBroadphaseProxy* proxy0) const
1022 {
1023 btCollisionObject* otherObj = (btCollisionObject*) proxy0->m_clientObject;
1024 if (!otherObj->isStaticOrKinematicObject())
1025 return false;
1026 return btClosestNotMeConvexResultCallback::needsCollision(proxy0);
1027 }
1028 };
1029
1030 StaticOnlyCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache(),getDispatcher());
1031 #else
1032 btClosestNotMeConvexResultCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache(),getDispatcher());
1033 #endif
1034 //btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
1035 btSphereShape tmpSphere(body->getCcdSweptSphereRadius());//btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
1036 sweepResults.m_allowedPenetration=getDispatchInfo().m_allowedCcdPenetration;
1037
1038 sweepResults.m_collisionFilterGroup = body->getBroadphaseProxy()->m_collisionFilterGroup;
1039 sweepResults.m_collisionFilterMask = body->getBroadphaseProxy()->m_collisionFilterMask;
1040 btTransform modifiedPredictedTrans = predictedTrans;
1041 modifiedPredictedTrans.setBasis(body->getWorldTransform().getBasis());
1042
1043 convexSweepTest(&tmpSphere,body->getWorldTransform(),modifiedPredictedTrans,sweepResults);
1044 if (sweepResults.hasHit() && (sweepResults.m_closestHitFraction < 1.f))
1045 {
1046
1047 //printf("clamped integration to hit fraction = %f\n",fraction);
1048 body->setHitFraction(sweepResults.m_closestHitFraction);
1049 body->predictIntegratedTransform(timeStep*body->getHitFraction(), predictedTrans);
1050 body->setHitFraction(0.f);
1051 body->proceedToTransform( predictedTrans);
1052
1053 #if 0
1054 btVector3 linVel = body->getLinearVelocity();
1055
1056 btScalar maxSpeed = body->getCcdMotionThreshold()/getSolverInfo().m_timeStep;
1057 btScalar maxSpeedSqr = maxSpeed*maxSpeed;
1058 if (linVel.length2()>maxSpeedSqr)
1059 {
1060 linVel.normalize();
1061 linVel*= maxSpeed;
1062 body->setLinearVelocity(linVel);
1063 btScalar ms2 = body->getLinearVelocity().length2();
1064 body->predictIntegratedTransform(timeStep, predictedTrans);
1065
1066 btScalar sm2 = (predictedTrans.getOrigin()-body->getWorldTransform().getOrigin()).length2();
1067 btScalar smt = body->getCcdSquareMotionThreshold();
1068 printf("sm2=%f\n",sm2);
1069 }
1070 #else
1071
1072 //don't apply the collision response right now, it will happen next frame
1073 //if you really need to, you can uncomment next 3 lines. Note that is uses zero restitution.
1074 //btScalar appliedImpulse = 0.f;
1075 //btScalar depth = 0.f;
1076 //appliedImpulse = resolveSingleCollision(body,(btCollisionObject*)sweepResults.m_hitCollisionObject,sweepResults.m_hitPointWorld,sweepResults.m_hitNormalWorld,getSolverInfo(), depth);
1077
1078
1079 #endif
1080
1081 continue;
1082 }
1083 }
1084 }
1085
1086
1087 body->proceedToTransform( predictedTrans);
1088
1089 }
1090
1091 }
1092
1093 }
1094
1095 void btDiscreteDynamicsWorld::integrateTransforms(btScalar timeStep)
1096 {
1097 BT_PROFILE("integrateTransforms");
1098 if (m_nonStaticRigidBodies.size() > 0)
1099 {
1100 integrateTransformsInternal(&m_nonStaticRigidBodies[0], m_nonStaticRigidBodies.size(), timeStep);
1101 }
1102
1104 if (m_applySpeculativeContactRestitution)
1105 {
1106 BT_PROFILE("apply speculative contact restitution");
1107 for (int i=0;i<m_predictiveManifolds.size();i++)
1108 {
1109 btPersistentManifold* manifold = m_predictiveManifolds[i];
1110 btRigidBody* body0 = btRigidBody::upcast((btCollisionObject*)manifold->getBody0());
1111 btRigidBody* body1 = btRigidBody::upcast((btCollisionObject*)manifold->getBody1());
1112
1113 for (int p=0;p<manifold->getNumContacts();p++)
1114 {
1115 const btManifoldPoint& pt = manifold->getContactPoint(p);
1116 btScalar combinedRestitution = btManifoldResult::calculateCombinedRestitution(body0, body1);
1117
1118 if (combinedRestitution>0 && pt.m_appliedImpulse != 0.f)
1119 //if (pt.getDistance()>0 && combinedRestitution>0 && pt.m_appliedImpulse != 0.f)
1120 {
1121 btVector3 imp = -pt.m_normalWorldOnB * pt.m_appliedImpulse* combinedRestitution;
1122
1123 const btVector3& pos1 = pt.getPositionWorldOnA();
1124 const btVector3& pos2 = pt.getPositionWorldOnB();
1125
1126 btVector3 rel_pos0 = pos1 - body0->getWorldTransform().getOrigin();
1127 btVector3 rel_pos1 = pos2 - body1->getWorldTransform().getOrigin();
1128
1129 if (body0)
1130 body0->applyImpulse(imp,rel_pos0);
1131 if (body1)
1132 body1->applyImpulse(-imp,rel_pos1);
1133 }
1134 }
1135 }
1136 }
1137 }
1138
1139
1140
1141
1142
1143 void btDiscreteDynamicsWorld::predictUnconstraintMotion(btScalar timeStep)
1144 {
1145 BT_PROFILE("predictUnconstraintMotion");
1146 for ( int i=0;i<m_nonStaticRigidBodies.size();i++)
1147 {
1148 btRigidBody* body = m_nonStaticRigidBodies[i];
1149 if (!body->isStaticOrKinematicObject())
1150 {
1151 //don't integrate/update velocities here, it happens in the constraint solver
1152
1153 body->applyDamping(timeStep);
1154
1155 body->predictIntegratedTransform(timeStep,body->getInterpolationWorldTransform());
1156 }
1157 }
1158 }
1159
1160
1161 void btDiscreteDynamicsWorld::startProfiling(btScalar timeStep)
1162 {
1163 (void)timeStep;
1164
1165 #ifndef BT_NO_PROFILE
1166 CProfileManager::Reset();
1167 #endif //BT_NO_PROFILE
1168
1169 }
1170
1171
1172
1173
1174
1175
1176 void btDiscreteDynamicsWorld::debugDrawConstraint(btTypedConstraint* constraint)
1177 {
1178 bool drawFrames = (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawConstraints) != 0;
1179 bool drawLimits = (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawConstraintLimits) != 0;
1180 btScalar dbgDrawSize = constraint->getDbgDrawSize();
1181 if(dbgDrawSize <= btScalar(0.f))
1182 {
1183 return;
1184 }
1185
1186 switch(constraint->getConstraintType())
1187 {
1188 case POINT2POINT_CONSTRAINT_TYPE:
1189 {
1190 btPoint2PointConstraint* p2pC = (btPoint2PointConstraint*)constraint;
1191 btTransform tr;
1192 tr.setIdentity();
1193 btVector3 pivot = p2pC->getPivotInA();
1194 pivot = p2pC->getRigidBodyA().getCenterOfMassTransform() * pivot;
1195 tr.setOrigin(pivot);
1196 getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1197 // that ideally should draw the same frame
1198 pivot = p2pC->getPivotInB();
1199 pivot = p2pC->getRigidBodyB().getCenterOfMassTransform() * pivot;
1200 tr.setOrigin(pivot);
1201 if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1202 }
1203 break;
1204 case HINGE_CONSTRAINT_TYPE:
1205 {
1206 btHingeConstraint* pHinge = (btHingeConstraint*)constraint;
1207 btTransform tr = pHinge->getRigidBodyA().getCenterOfMassTransform() * pHinge->getAFrame();
1208 if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1209 tr = pHinge->getRigidBodyB().getCenterOfMassTransform() * pHinge->getBFrame();
1210 if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1211 btScalar minAng = pHinge->getLowerLimit();
1212 btScalar maxAng = pHinge->getUpperLimit();
1213 if(minAng == maxAng)
1214 {
1215 break;
1216 }
1217 bool drawSect = true;
1218 if(!pHinge->hasLimit())
1219 {
1220 minAng = btScalar(0.f);
1221 maxAng = SIMD_2_PI;
1222 drawSect = false;
1223 }
1224 if(drawLimits)
1225 {
1226 btVector3& center = tr.getOrigin();
1227 btVector3 normal = tr.getBasis().getColumn(2);
1228 btVector3 axis = tr.getBasis().getColumn(0);
1229 getDebugDrawer()->drawArc(center, normal, axis, dbgDrawSize, dbgDrawSize, minAng, maxAng, btVector3(0,0,0), drawSect);
1230 }
1231 }
1232 break;
1233 case CONETWIST_CONSTRAINT_TYPE:
1234 {
1235 btConeTwistConstraint* pCT = (btConeTwistConstraint*)constraint;
1236 btTransform tr = pCT->getRigidBodyA().getCenterOfMassTransform() * pCT->getAFrame();
1237 if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1238 tr = pCT->getRigidBodyB().getCenterOfMassTransform() * pCT->getBFrame();
1239 if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1240 if(drawLimits)
1241 {
1242 //const btScalar length = btScalar(5);
1243 const btScalar length = dbgDrawSize;
1244 static int nSegments = 8*4;
1245 btScalar fAngleInRadians = btScalar(2.*3.1415926) * (btScalar)(nSegments-1)/btScalar(nSegments);
1246 btVector3 pPrev = pCT->GetPointForAngle(fAngleInRadians, length);
1247 pPrev = tr * pPrev;
1248 for (int i=0; i<nSegments; i++)
1249 {
1250 fAngleInRadians = btScalar(2.*3.1415926) * (btScalar)i/btScalar(nSegments);
1251 btVector3 pCur = pCT->GetPointForAngle(fAngleInRadians, length);
1252 pCur = tr * pCur;
1253 getDebugDrawer()->drawLine(pPrev, pCur, btVector3(0,0,0));
1254
1255 if (i%(nSegments/8) == 0)
1256 getDebugDrawer()->drawLine(tr.getOrigin(), pCur, btVector3(0,0,0));
1257
1258 pPrev = pCur;
1259 }
1260 btScalar tws = pCT->getTwistSpan();
1261 btScalar twa = pCT->getTwistAngle();
1262 bool useFrameB = (pCT->getRigidBodyB().getInvMass() > btScalar(0.f));
1263 if(useFrameB)
1264 {
1265 tr = pCT->getRigidBodyB().getCenterOfMassTransform() * pCT->getBFrame();
1266 }
1267 else
1268 {
1269 tr = pCT->getRigidBodyA().getCenterOfMassTransform() * pCT->getAFrame();
1270 }
1271 btVector3 pivot = tr.getOrigin();
1272 btVector3 normal = tr.getBasis().getColumn(0);
1273 btVector3 axis1 = tr.getBasis().getColumn(1);
1274 getDebugDrawer()->drawArc(pivot, normal, axis1, dbgDrawSize, dbgDrawSize, -twa-tws, -twa+tws, btVector3(0,0,0), true);
1275
1276 }
1277 }
1278 break;
1279 case D6_SPRING_CONSTRAINT_TYPE:
1280 case D6_CONSTRAINT_TYPE:
1281 {
1282 btGeneric6DofConstraint* p6DOF = (btGeneric6DofConstraint*)constraint;
1283 btTransform tr = p6DOF->getCalculatedTransformA();
1284 if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1285 tr = p6DOF->getCalculatedTransformB();
1286 if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1287 if(drawLimits)
1288 {
1289 tr = p6DOF->getCalculatedTransformA();
1290 const btVector3& center = p6DOF->getCalculatedTransformB().getOrigin();
1291 btVector3 up = tr.getBasis().getColumn(2);
1292 btVector3 axis = tr.getBasis().getColumn(0);
1293 btScalar minTh = p6DOF->getRotationalLimitMotor(1)->m_loLimit;
1294 btScalar maxTh = p6DOF->getRotationalLimitMotor(1)->m_hiLimit;
1295 btScalar minPs = p6DOF->getRotationalLimitMotor(2)->m_loLimit;
1296 btScalar maxPs = p6DOF->getRotationalLimitMotor(2)->m_hiLimit;
1297 getDebugDrawer()->drawSpherePatch(center, up, axis, dbgDrawSize * btScalar(.9f), minTh, maxTh, minPs, maxPs, btVector3(0,0,0));
1298 axis = tr.getBasis().getColumn(1);
1299 btScalar ay = p6DOF->getAngle(1);
1300 btScalar az = p6DOF->getAngle(2);
1301 btScalar cy = btCos(ay);
1302 btScalar sy = btSin(ay);
1303 btScalar cz = btCos(az);
1304 btScalar sz = btSin(az);
1305 btVector3 ref;
1306 ref[0] = cy*cz*axis[0] + cy*sz*axis[1] - sy*axis[2];
1307 ref[1] = -sz*axis[0] + cz*axis[1];
1308 ref[2] = cz*sy*axis[0] + sz*sy*axis[1] + cy*axis[2];
1309 tr = p6DOF->getCalculatedTransformB();
1310 btVector3 normal = -tr.getBasis().getColumn(0);
1311 btScalar minFi = p6DOF->getRotationalLimitMotor(0)->m_loLimit;
1312 btScalar maxFi = p6DOF->getRotationalLimitMotor(0)->m_hiLimit;
1313 if(minFi > maxFi)
1314 {
1315 getDebugDrawer()->drawArc(center, normal, ref, dbgDrawSize, dbgDrawSize, -SIMD_PI, SIMD_PI, btVector3(0,0,0), false);
1316 }
1317 else if(minFi < maxFi)
1318 {
1319 getDebugDrawer()->drawArc(center, normal, ref, dbgDrawSize, dbgDrawSize, minFi, maxFi, btVector3(0,0,0), true);
1320 }
1321 tr = p6DOF->getCalculatedTransformA();
1322 btVector3 bbMin = p6DOF->getTranslationalLimitMotor()->m_lowerLimit;
1323 btVector3 bbMax = p6DOF->getTranslationalLimitMotor()->m_upperLimit;
1324 getDebugDrawer()->drawBox(bbMin, bbMax, tr, btVector3(0,0,0));
1325 }
1326 }
1327 break;
1329 case D6_SPRING_2_CONSTRAINT_TYPE:
1330 {
1331 {
1332 btGeneric6DofSpring2Constraint* p6DOF = (btGeneric6DofSpring2Constraint*)constraint;
1333 btTransform tr = p6DOF->getCalculatedTransformA();
1334 if (drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1335 tr = p6DOF->getCalculatedTransformB();
1336 if (drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1337 if (drawLimits)
1338 {
1339 tr = p6DOF->getCalculatedTransformA();
1340 const btVector3& center = p6DOF->getCalculatedTransformB().getOrigin();
1341 btVector3 up = tr.getBasis().getColumn(2);
1342 btVector3 axis = tr.getBasis().getColumn(0);
1343 btScalar minTh = p6DOF->getRotationalLimitMotor(1)->m_loLimit;
1344 btScalar maxTh = p6DOF->getRotationalLimitMotor(1)->m_hiLimit;
1345 btScalar minPs = p6DOF->getRotationalLimitMotor(2)->m_loLimit;
1346 btScalar maxPs = p6DOF->getRotationalLimitMotor(2)->m_hiLimit;
1347 getDebugDrawer()->drawSpherePatch(center, up, axis, dbgDrawSize * btScalar(.9f), minTh, maxTh, minPs, maxPs, btVector3(0, 0, 0));
1348 axis = tr.getBasis().getColumn(1);
1349 btScalar ay = p6DOF->getAngle(1);
1350 btScalar az = p6DOF->getAngle(2);
1351 btScalar cy = btCos(ay);
1352 btScalar sy = btSin(ay);
1353 btScalar cz = btCos(az);
1354 btScalar sz = btSin(az);
1355 btVector3 ref;
1356 ref[0] = cy*cz*axis[0] + cy*sz*axis[1] - sy*axis[2];
1357 ref[1] = -sz*axis[0] + cz*axis[1];
1358 ref[2] = cz*sy*axis[0] + sz*sy*axis[1] + cy*axis[2];
1359 tr = p6DOF->getCalculatedTransformB();
1360 btVector3 normal = -tr.getBasis().getColumn(0);
1361 btScalar minFi = p6DOF->getRotationalLimitMotor(0)->m_loLimit;
1362 btScalar maxFi = p6DOF->getRotationalLimitMotor(0)->m_hiLimit;
1363 if (minFi > maxFi)
1364 {
1365 getDebugDrawer()->drawArc(center, normal, ref, dbgDrawSize, dbgDrawSize, -SIMD_PI, SIMD_PI, btVector3(0, 0, 0), false);
1366 }
1367 else if (minFi < maxFi)
1368 {
1369 getDebugDrawer()->drawArc(center, normal, ref, dbgDrawSize, dbgDrawSize, minFi, maxFi, btVector3(0, 0, 0), true);
1370 }
1371 tr = p6DOF->getCalculatedTransformA();
1372 btVector3 bbMin = p6DOF->getTranslationalLimitMotor()->m_lowerLimit;
1373 btVector3 bbMax = p6DOF->getTranslationalLimitMotor()->m_upperLimit;
1374 getDebugDrawer()->drawBox(bbMin, bbMax, tr, btVector3(0, 0, 0));
1375 }
1376 }
1377 break;
1378 }
1379 case SLIDER_CONSTRAINT_TYPE:
1380 {
1381 btSliderConstraint* pSlider = (btSliderConstraint*)constraint;
1382 btTransform tr = pSlider->getCalculatedTransformA();
1383 if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1384 tr = pSlider->getCalculatedTransformB();
1385 if(drawFrames) getDebugDrawer()->drawTransform(tr, dbgDrawSize);
1386 if(drawLimits)
1387 {
1388 btTransform tr = pSlider->getUseLinearReferenceFrameA() ? pSlider->getCalculatedTransformA() : pSlider->getCalculatedTransformB();
1389 btVector3 li_min = tr * btVector3(pSlider->getLowerLinLimit(), 0.f, 0.f);
1390 btVector3 li_max = tr * btVector3(pSlider->getUpperLinLimit(), 0.f, 0.f);
1391 getDebugDrawer()->drawLine(li_min, li_max, btVector3(0, 0, 0));
1392 btVector3 normal = tr.getBasis().getColumn(0);
1393 btVector3 axis = tr.getBasis().getColumn(1);
1394 btScalar a_min = pSlider->getLowerAngLimit();
1395 btScalar a_max = pSlider->getUpperAngLimit();
1396 const btVector3& center = pSlider->getCalculatedTransformB().getOrigin();
1397 getDebugDrawer()->drawArc(center, normal, axis, dbgDrawSize, dbgDrawSize, a_min, a_max, btVector3(0,0,0), true);
1398 }
1399 }
1400 break;
1401 default :
1402 break;
1403 }
1404 return;
1405 }
1406
1407
1408
1409
1410
1411 void btDiscreteDynamicsWorld::setConstraintSolver(btConstraintSolver* solver)
1412 {
1413 if (m_ownsConstraintSolver)
1414 {
1415 btAlignedFree( m_constraintSolver);
1416 }
1417 m_ownsConstraintSolver = false;
1418 m_constraintSolver = solver;
1419 m_solverIslandCallback->m_solver = solver;
1420 }
1421
1422 btConstraintSolver* btDiscreteDynamicsWorld::getConstraintSolver()
1423 {
1424 return m_constraintSolver;
1425 }
1426
1427
1428 int btDiscreteDynamicsWorld::getNumConstraints() const
1429 {
1430 return int(m_constraints.size());
1431 }
1432 btTypedConstraint* btDiscreteDynamicsWorld::getConstraint(int index)
1433 {
1434 return m_constraints[index];
1435 }
1436 const btTypedConstraint* btDiscreteDynamicsWorld::getConstraint(int index) const
1437 {
1438 return m_constraints[index];
1439 }
1440
1441
1442
1443 void btDiscreteDynamicsWorld::serializeRigidBodies(btSerializer* serializer)
1444 {
1445 int i;
1446 //serialize all collision objects
1447 for (i=0;i<m_collisionObjects.size();i++)
1448 {
1449 btCollisionObject* colObj = m_collisionObjects[i];
1450 if (colObj->getInternalType() & btCollisionObject::CO_RIGID_BODY)
1451 {
1452 int len = colObj->calculateSerializeBufferSize();
1453 btChunk* chunk = serializer->allocate(len,1);
1454 const char* structType = colObj->serialize(chunk->m_oldPtr, serializer);
1455 serializer->finalizeChunk(chunk,structType,BT_RIGIDBODY_CODE,colObj);
1456 }
1457 }
1458
1459 for (i=0;i<m_constraints.size();i++)
1460 {
1461 btTypedConstraint* constraint = m_constraints[i];
1462 int size = constraint->calculateSerializeBufferSize();
1463 btChunk* chunk = serializer->allocate(size,1);
1464 const char* structType = constraint->serialize(chunk->m_oldPtr,serializer);
1465 serializer->finalizeChunk(chunk,structType,BT_CONSTRAINT_CODE,constraint);
1466 }
1467 }
1468
1469
1470
1471
1472 void btDiscreteDynamicsWorld::serializeDynamicsWorldInfo(btSerializer* serializer)
1473 {
1474 #ifdef BT_USE_DOUBLE_PRECISION
1475 int len = sizeof(btDynamicsWorldDoubleData);
1476 btChunk* chunk = serializer->allocate(len,1);
1477 btDynamicsWorldDoubleData* worldInfo = (btDynamicsWorldDoubleData*)chunk->m_oldPtr;
1478 #else//BT_USE_DOUBLE_PRECISION
1479 int len = sizeof(btDynamicsWorldFloatData);
1480 btChunk* chunk = serializer->allocate(len,1);
1481 btDynamicsWorldFloatData* worldInfo = (btDynamicsWorldFloatData*)chunk->m_oldPtr;
1482 #endif//BT_USE_DOUBLE_PRECISION
1483
1484 memset(worldInfo ,0x00,len);
1485
1486 m_gravity.serialize(worldInfo->m_gravity);
1487 worldInfo->m_solverInfo.m_tau = getSolverInfo().m_tau;
1488 worldInfo->m_solverInfo.m_damping = getSolverInfo().m_damping;
1489 worldInfo->m_solverInfo.m_friction = getSolverInfo().m_friction;
1490 worldInfo->m_solverInfo.m_timeStep = getSolverInfo().m_timeStep;
1491
1492 worldInfo->m_solverInfo.m_restitution = getSolverInfo().m_restitution;
1493 worldInfo->m_solverInfo.m_maxErrorReduction = getSolverInfo().m_maxErrorReduction;
1494 worldInfo->m_solverInfo.m_sor = getSolverInfo().m_sor;
1495 worldInfo->m_solverInfo.m_erp = getSolverInfo().m_erp;
1496
1497 worldInfo->m_solverInfo.m_erp2 = getSolverInfo().m_erp2;
1498 worldInfo->m_solverInfo.m_globalCfm = getSolverInfo().m_globalCfm;
1499 worldInfo->m_solverInfo.m_splitImpulsePenetrationThreshold = getSolverInfo().m_splitImpulsePenetrationThreshold;
1500 worldInfo->m_solverInfo.m_splitImpulseTurnErp = getSolverInfo().m_splitImpulseTurnErp;
1501
1502 worldInfo->m_solverInfo.m_linearSlop = getSolverInfo().m_linearSlop;
1503 worldInfo->m_solverInfo.m_warmstartingFactor = getSolverInfo().m_warmstartingFactor;
1504 worldInfo->m_solverInfo.m_maxGyroscopicForce = getSolverInfo().m_maxGyroscopicForce;
1505 worldInfo->m_solverInfo.m_singleAxisRollingFrictionThreshold = getSolverInfo().m_singleAxisRollingFrictionThreshold;
1506
1507 worldInfo->m_solverInfo.m_numIterations = getSolverInfo().m_numIterations;
1508 worldInfo->m_solverInfo.m_solverMode = getSolverInfo().m_solverMode;
1509 worldInfo->m_solverInfo.m_restingContactRestitutionThreshold = getSolverInfo().m_restingContactRestitutionThreshold;
1510 worldInfo->m_solverInfo.m_minimumSolverBatchSize = getSolverInfo().m_minimumSolverBatchSize;
1511
1512 worldInfo->m_solverInfo.m_splitImpulse = getSolverInfo().m_splitImpulse;
1513
1514 // Fill padding with zeros to appease msan.
1515 memset(worldInfo->m_solverInfo.m_padding, 0, sizeof(worldInfo->m_solverInfo.m_padding));
1516
1517 #ifdef BT_USE_DOUBLE_PRECISION
1518 const char* structType = "btDynamicsWorldDoubleData";
1519 #else//BT_USE_DOUBLE_PRECISION
1520 const char* structType = "btDynamicsWorldFloatData";
1521 #endif//BT_USE_DOUBLE_PRECISION
1522 serializer->finalizeChunk(chunk,structType,BT_DYNAMICSWORLD_CODE,worldInfo);
1523 }
1524
1525 void btDiscreteDynamicsWorld::serialize(btSerializer* serializer)
1526 {
1527
1528 serializer->startSerialization();
1529
1530 serializeDynamicsWorldInfo(serializer);
1531
1532 serializeCollisionObjects(serializer);
1533
1534 serializeRigidBodies(serializer);
1535
1536 serializer->finishSerialization();
1537 }
1538
btTransform::setOrigin
void setOrigin(const btVector3 &origin)
Set the translational element.
Definition: btTransform.h:150
btDiscreteDynamicsWorld::setConstraintSolver
virtual void setConstraintSolver(btConstraintSolver *solver)
Definition: btDiscreteDynamicsWorld.cpp:1411
btDiscreteDynamicsWorld::internalSingleStepSimulation
virtual void internalSingleStepSimulation(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:473
btSerializer::finishSerialization
virtual void finishSerialization()=0
btRigidBody::upcast
static const btRigidBody * upcast(const btCollisionObject *colObj)
to keep collision detection and dynamics separate we don&#39;t store a rigidbody pointer but a rigidbody ...
Definition: btRigidBody.h:203
btDiscreteDynamicsWorld::serializeDynamicsWorldInfo
void serializeDynamicsWorldInfo(btSerializer *serializer)
Definition: btDiscreteDynamicsWorld.cpp:1472
btConeTwistConstraint::getRigidBodyA
const btRigidBody & getRigidBodyA() const
Definition: btConeTwistConstraint.h:160
btDiscreteDynamicsWorld::startProfiling
void startProfiling(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:1161
InplaceSolverIslandCallback::m_solverInfo
btContactSolverInfo * m_solverInfo
Definition: btDiscreteDynamicsWorld.cpp:86
btClosestNotMeConvexResultCallback
Definition: btDiscreteDynamicsWorld.cpp:793
ACTIVE_TAG
#define ACTIVE_TAG
Definition: btCollisionObject.h:22
btDispatcher::releaseManifold
virtual void releaseManifold(btPersistentManifold *manifold)=0
btDiscreteDynamicsWorld::clearForces
virtual void clearForces()
the forces on each rigidbody is accumulating together with gravity. clear this after each timestep...
Definition: btDiscreteDynamicsWorld.cpp:326
btContactSolverInfoData::m_splitImpulseTurnErp
btScalar m_splitImpulseTurnErp
Definition: btContactSolverInfo.h:55
btCollisionWorld::serializeCollisionObjects
void serializeCollisionObjects(btSerializer *serializer)
Definition: btCollisionWorld.cpp:1609
length
btScalar length(const btQuaternion &q)
Return the length of a quaternion.
Definition: btQuaternion.h:886
btIDebugDraw::DBG_DrawAabb
Definition: btIDebugDraw.h:60
btClosestNotMeConvexResultCallback::m_pairCache
btOverlappingPairCache * m_pairCache
Definition: btDiscreteDynamicsWorld.cpp:799
btTransformUtil.h
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition: btPersistentManifold.h:63
btContactSolverInfoData::m_friction
btScalar m_friction
Definition: btContactSolverInfo.h:41
btCollisionObject::getInterpolationAngularVelocity
const btVector3 & getInterpolationAngularVelocity() const
Definition: btCollisionObject.h:438
InplaceSolverIslandCallback::setup
void setup(btContactSolverInfo *solverInfo, btTypedConstraint **sortedConstraints, int numConstraints, btIDebugDraw *debugDrawer)
Definition: btDiscreteDynamicsWorld.cpp:119
btAlignedObjectArray::push_back
void push_back(const T &_Val)
Definition: btAlignedObjectArray.h:274
btHingeConstraint::getUpperLimit
btScalar getUpperLimit() const
Definition: btHingeConstraint.h:267
BT_DISABLE_WORLD_GRAVITY
Definition: btRigidBody.h:43
btDiscreteDynamicsWorld::addAction
virtual void addAction(btActionInterface *)
Definition: btDiscreteDynamicsWorld.cpp:676
btContactSolverInfoData::m_tau
btScalar m_tau
Definition: btContactSolverInfo.h:39
btDiscreteDynamicsWorld::m_localTime
btScalar m_localTime
Definition: btDiscreteDynamicsWorld.h:56
btDiscreteDynamicsWorld::solveConstraints
virtual void solveConstraints(btContactSolverInfo &solverInfo)
Definition: btDiscreteDynamicsWorld.cpp:710
btPoint2PointConstraint
point to point constraint between two rigidbodies each with a pivotpoint that descibes the &#39;ballsocke...
Definition: btPoint2PointConstraint.h:54
btSortConstraintOnIslandPredicate::operator()
bool operator()(const btTypedConstraint *lhs, const btTypedConstraint *rhs) const
Definition: btDiscreteDynamicsWorld.cpp:75
btChunk
Definition: btSerializer.h:51
btRigidBody::applyGravity
void applyGravity()
Definition: btRigidBody.cpp:218
btDiscreteDynamicsWorld::addConstraint
virtual void addConstraint(btTypedConstraint *constraint, bool disableCollisionsBetweenLinkedBodies=false)
Definition: btDiscreteDynamicsWorld.cpp:656
btDiscreteDynamicsWorld::removeVehicle
virtual void removeVehicle(btActionInterface *vehicle)
obsolete, use removeAction instead
Definition: btDiscreteDynamicsWorld.cpp:692
btContactSolverInfoData::m_erp
btScalar m_erp
Definition: btContactSolverInfo.h:47
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:80
btHingeConstraint::getRigidBodyB
const btRigidBody & getRigidBodyB() const
Definition: btHingeConstraint.h:136
btGetConstraintIslandId
int btGetConstraintIslandId(const btTypedConstraint *lhs)
Definition: btDiscreteDynamicsWorld.cpp:59
InplaceSolverIslandCallback::m_debugDrawer
btIDebugDraw * m_debugDrawer
Definition: btDiscreteDynamicsWorld.cpp:90
btManifoldPoint::getPositionWorldOnA
const btVector3 & getPositionWorldOnA() const
Definition: btManifoldPoint.h:155
btPoint2PointConstraint::getPivotInA
const btVector3 & getPivotInA() const
Definition: btPoint2PointConstraint.h:104
btHingeConstraint::hasLimit
bool hasLimit() const
Definition: btHingeConstraint.h:250
btRotationalLimitMotor2::m_loLimit
btScalar m_loLimit
Definition: btGeneric6DofSpring2Constraint.h:75
BT_CONSTRAINT_CODE
#define BT_CONSTRAINT_CODE
Definition: btSerializer.h:121
btHingeConstraint::getBFrame
const btTransform & getBFrame() const
Definition: btHingeConstraint.h:286
btDiscreteDynamicsWorld::m_islandManager
btSimulationIslandManager * m_islandManager
Definition: btDiscreteDynamicsWorld.h:47
btSliderConstraint::getCalculatedTransformA
const btTransform & getCalculatedTransformA() const
Definition: btSliderConstraint.h:186
btHingeConstraint::getLowerLimit
btScalar getLowerLimit() const
Definition: btHingeConstraint.h:258
btContactSolverInfoFloatData::m_restingContactRestitutionThreshold
int m_restingContactRestitutionThreshold
Definition: btContactSolverInfo.h:158
btSliderConstraint::getCalculatedTransformB
const btTransform & getCalculatedTransformB() const
Definition: btSliderConstraint.h:187
btDiscreteDynamicsWorld::m_nonStaticRigidBodies
btAlignedObjectArray< btRigidBody * > m_nonStaticRigidBodies
Definition: btDiscreteDynamicsWorld.h:51
InplaceSolverIslandCallback
Definition: btDiscreteDynamicsWorld.cpp:84
btCollisionShape::isConvex
bool isConvex() const
Definition: btCollisionShape.h:73
btAlignedObjectArray< btVector3 >
btRigidBody::predictIntegratedTransform
void predictIntegratedTransform(btScalar step, btTransform &predictedTransform)
continuous collision detection needs prediction
Definition: btRigidBody.cpp:106
btDiscreteDynamicsWorld::addRigidBody
virtual void addRigidBody(btRigidBody *body)
Definition: btDiscreteDynamicsWorld.cpp:562
btSin
btScalar btSin(btScalar x)
Definition: btScalar.h:477
btDynamicsWorldDoubleData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btDynamicsWorld.h:157
btPoint2PointConstraint::getPivotInB
const btVector3 & getPivotInB() const
Definition: btPoint2PointConstraint.h:109
btRotationalLimitMotor::m_loLimit
btScalar m_loLimit
limit_parameters
Definition: btGeneric6DofConstraint.h:53
btContactSolverInfoFloatData::m_restitution
float m_restitution
Definition: btContactSolverInfo.h:141
btCollisionWorld::addCollisionObject
virtual void addCollisionObject(btCollisionObject *collisionObject, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
Definition: btCollisionWorld.cpp:111
btDiscreteDynamicsWorld::setGravity
virtual void setGravity(const btVector3 &gravity)
Definition: btDiscreteDynamicsWorld.cpp:523
btDiscreteDynamicsWorld::addCollisionObject
virtual void addCollisionObject(btCollisionObject *collisionObject, int collisionFilterGroup=btBroadphaseProxy::StaticFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter)
Definition: btDiscreteDynamicsWorld.cpp:541
btRigidBody::getCenterOfMassTransform
const btTransform & getCenterOfMassTransform() const
Definition: btRigidBody.h:359
btDiscreteDynamicsWorld::m_sortedConstraints
btAlignedObjectArray< btTypedConstraint * > m_sortedConstraints
Definition: btDiscreteDynamicsWorld.h:42
btManifoldPoint::m_combinedRestitution
btScalar m_combinedRestitution
Definition: btManifoldPoint.h:106
btDiscreteDynamicsWorld::removeCharacter
virtual void removeCharacter(btActionInterface *character)
obsolete, use removeAction instead
Definition: btDiscreteDynamicsWorld.cpp:702
btVector3::length2
btScalar length2() const
Return the length of the vector squared.
Definition: btVector3.h:257
btTransform::setBasis
void setBasis(const btMatrix3x3 &basis)
Set the rotational element by btMatrix3x3.
Definition: btTransform.h:159
btIDebugDraw::drawLine
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
btIDebugDraw::DBG_DrawConstraintLimits
Definition: btIDebugDraw.h:71
btConeTwistConstraint::getRigidBodyB
const btRigidBody & getRigidBodyB() const
Definition: btConeTwistConstraint.h:164
btSerializer::startSerialization
virtual void startSerialization()=0
btGeneric6DofConstraint::getTranslationalLimitMotor
btTranslationalLimitMotor * getTranslationalLimitMotor()
Retrieves the limit informacion.
Definition: btGeneric6DofConstraint.h:506
btDiscreteDynamicsWorld::integrateTransformsInternal
void integrateTransformsInternal(btRigidBody **bodies, int numBodies, btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:988
btRigidBody::wantsSleeping
bool wantsSleeping()
Definition: btRigidBody.h:438
btGeneric6DofConstraint
btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis locatio...
Definition: btGeneric6DofConstraint.h:279
btIDebugDraw::DBG_NoDeactivation
Definition: btIDebugDraw.h:63
btContactSolverInfoData::m_splitImpulse
int m_splitImpulse
Definition: btContactSolverInfo.h:53
gDisableDeactivation
bool gDisableDeactivation
Definition: btRigidBody.cpp:26
btIDebugDraw::drawBox
virtual void drawBox(const btVector3 &bbMin, const btVector3 &bbMax, const btVector3 &color)
Definition: btIDebugDraw.h:306
btContactSolverInfoFloatData::m_minimumSolverBatchSize
int m_minimumSolverBatchSize
Definition: btContactSolverInfo.h:159
btTypedConstraint::getRigidBodyA
const btRigidBody & getRigidBodyA() const
Definition: btTypedConstraint.h:222
btSimulationIslandManager
SimulationIslandManager creates and handles simulation islands, using btUnionFind.
Definition: btSimulationIslandManager.h:31
btPersistentManifold::getNumContacts
int getNumContacts() const
Definition: btPersistentManifold.h:117
size
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
btContactSolverInfoFloatData::m_padding
char m_padding[4]
Definition: btContactSolverInfo.h:162
btManifoldPoint::m_appliedImpulse
btScalar m_appliedImpulse
Definition: btManifoldPoint.h:118
btTransform::setIdentity
void setIdentity()
Set this transformation to the identity.
Definition: btTransform.h:172
btDynamicsWorld::m_internalTickCallback
btInternalTickCallback m_internalTickCallback
Definition: btDynamicsWorld.h:46
btAssert
#define btAssert(x)
Definition: btScalar.h:131
btDynamicsWorld
The btDynamicsWorld is the interface class for several dynamics implementation, basic, discrete, parallel, and continuous etc.
Definition: btDynamicsWorld.h:42
btDiscreteDynamicsWorld::releasePredictiveContacts
void releasePredictiveContacts()
Definition: btDiscreteDynamicsWorld.cpp:966
btSequentialImpulseConstraintSolver.h
btCollisionConfiguration
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
Definition: btCollisionConfiguration.h:26
btSimulationIslandManager::buildAndProcessIslands
void buildAndProcessIslands(btDispatcher *dispatcher, btCollisionWorld *collisionWorld, IslandCallback *callback)
Definition: btSimulationIslandManager.cpp:354
btDiscreteDynamicsWorld::getGravity
virtual btVector3 getGravity() const
Definition: btDiscreteDynamicsWorld.cpp:536
btDiscreteDynamicsWorld::m_actions
btAlignedObjectArray< btActionInterface * > m_actions
Definition: btDiscreteDynamicsWorld.h:65
InplaceSolverIslandCallback::processIsland
virtual void processIsland(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifolds, int numManifolds, int islandId)
Definition: btDiscreteDynamicsWorld.cpp:132
btCollisionObject::setHitFraction
void setHitFraction(btScalar hitFraction)
Definition: btCollisionObject.h:479
btActionInterface.h
btContactConstraint.h
BT_DYNAMICSWORLD_CODE
#define BT_DYNAMICSWORLD_CODE
Definition: btSerializer.h:129
btCollisionObject::isKinematicObject
bool isKinematicObject() const
Definition: btCollisionObject.h:202
btConstraintSolver::solveGroup
virtual btScalar solveGroup(btCollisionObject **bodies, int numBodies, btPersistentManifold **manifold, int numManifolds, btTypedConstraint **constraints, int numConstraints, const btContactSolverInfo &info, class btIDebugDraw *debugDrawer, btDispatcher *dispatcher)=0
solve a group of constraints
btContactSolverInfoData::m_singleAxisRollingFrictionThreshold
btScalar m_singleAxisRollingFrictionThreshold
Definition: btContactSolverInfo.h:63
btDiscreteDynamicsWorld::getSimulationIslandManager
btSimulationIslandManager * getSimulationIslandManager()
Definition: btDiscreteDynamicsWorld.h:128
btSliderConstraint::getLowerLinLimit
btScalar getLowerLinLimit()
Definition: btSliderConstraint.h:192
btDiscreteDynamicsWorld::removeCollisionObject
virtual void removeCollisionObject(btCollisionObject *collisionObject)
removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise ca...
Definition: btDiscreteDynamicsWorld.cpp:546
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:81
btDiscreteDynamicsWorld::removeAction
virtual void removeAction(btActionInterface *)
Definition: btDiscreteDynamicsWorld.cpp:681
btDiscreteDynamicsWorld::m_ownsConstraintSolver
bool m_ownsConstraintSolver
Definition: btDiscreteDynamicsWorld.h:61
btSphereShape
The btSphereShape implements an implicit sphere, centered around a local origin with radius...
Definition: btSphereShape.h:22
btIDebugDraw::drawArc
virtual void drawArc(const btVector3 &center, const btVector3 &normal, const btVector3 &axis, btScalar radiusA, btScalar radiusB, btScalar minAngle, btScalar maxAngle, const btVector3 &color, bool drawSect, btScalar stepDegrees=btScalar(10.f))
Definition: btIDebugDraw.h:174
btActionInterface
Basic interface to allow actions such as vehicles and characters to be updated inside a btDynamicsWor...
Definition: btActionInterface.h:26
btTranslationalLimitMotor::m_upperLimit
btVector3 m_upperLimit
the constraint upper limits
Definition: btGeneric6DofConstraint.h:144
btContactSolverInfoFloatData::m_linearSlop
float m_linearSlop
Definition: btContactSolverInfo.h:151
btManifoldPoint
ManifoldContactPoint collects and maintains persistent contactpoints.
Definition: btManifoldPoint.h:49
btCollisionObject::getActivationState
int getActivationState() const
Definition: btCollisionObject.h:282
btCollisionWorld::m_dispatcher1
btDispatcher * m_dispatcher1
Definition: btCollisionWorld.h:96
btDispatcherInfo::m_debugDraw
class btIDebugDraw * m_debugDraw
Definition: btDispatcher.h:58
btCollisionWorld::ClosestConvexResultCallback::addSingleResult
virtual btScalar addSingleResult(LocalConvexResult &convexResult, bool normalInWorldSpace)
Definition: btCollisionWorld.h:390
btSimulationIslandManager::updateActivationState
virtual void updateActivationState(btCollisionWorld *colWorld, btDispatcher *dispatcher)
Definition: btSimulationIslandManager.cpp:127
btTypedConstraint::getRigidBodyB
const btRigidBody & getRigidBodyB() const
Definition: btTypedConstraint.h:226
btSimulationIslandManager::IslandCallback
Definition: btSimulationIslandManager.h:58
btRigidBody.h
btContactSolverInfoFloatData::m_erp
float m_erp
Definition: btContactSolverInfo.h:144
btGeneric6DofSpring2Constraint::getCalculatedTransformA
const btTransform & getCalculatedTransformA() const
Definition: btGeneric6DofSpring2Constraint.h:343
btConeTwistConstraint::getAFrame
const btTransform & getAFrame() const
Definition: btConeTwistConstraint.h:253
ISLAND_SLEEPING
#define ISLAND_SLEEPING
Definition: btCollisionObject.h:23
btCollisionObject::isStaticOrKinematicObject
bool isStaticOrKinematicObject() const
Definition: btCollisionObject.h:207
btConeTwistConstraint::GetPointForAngle
btVector3 GetPointForAngle(btScalar fAngleInRadians, btScalar fLength) const
Definition: btConeTwistConstraint.cpp:893
btHingeConstraint
hinge constraint between two rigidbodies each with a pivotpoint that descibes the axis location in lo...
Definition: btHingeConstraint.h:51
btGeneric6DofSpring2Constraint
Definition: btGeneric6DofSpring2Constraint.h:277
btDynamicsWorldFloatData::m_gravity
btVector3FloatData m_gravity
Definition: btDynamicsWorld.h:167
btClosestNotMeConvexResultCallback::m_me
btCollisionObject * m_me
Definition: btDiscreteDynamicsWorld.cpp:797
btContactSolverInfoData::m_globalCfm
btScalar m_globalCfm
Definition: btContactSolverInfo.h:49
btConeTwistConstraint::getTwistAngle
btScalar getTwistAngle() const
Definition: btConeTwistConstraint.h:298
btStackAlloc
The StackAlloc class provides some fast stack-based memory allocator (LIFO last-in first-out) ...
Definition: btStackAlloc.h:34
InplaceSolverIslandCallback::m_numConstraints
int m_numConstraints
Definition: btDiscreteDynamicsWorld.cpp:89
btSerializer
Definition: btSerializer.h:68
btVector3::normalize
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
Definition: btVector3.h:309
btCollisionWorld::getNumCollisionObjects
int getNumCollisionObjects() const
Definition: btCollisionWorld.h:440
btRigidBody::getCollisionShape
const btCollisionShape * getCollisionShape() const
Definition: btRigidBody.h:254
btCollisionObject::getInterpolationLinearVelocity
const btVector3 & getInterpolationLinearVelocity() const
Definition: btCollisionObject.h:433
btGeneric6DofConstraint::getCalculatedTransformA
const btTransform & getCalculatedTransformA() const
Gets the global transform of the offset for body A.
Definition: btGeneric6DofConstraint.h:378
btCollisionWorld::ConvexResultCallback::needsCollision
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
Definition: btCollisionWorld.h:364
btAlignedObjectArray::clear
void clear()
clear the array, deallocated memory. Generally it is better to use array.resize(0), to reduce performance overhead of run-time memory (de)allocations.
Definition: btAlignedObjectArray.h:190
btPersistentManifold::getContactPoint
const btManifoldPoint & getContactPoint(int index) const
Definition: btPersistentManifold.h:125
btClosestNotMeConvexResultCallback::m_dispatcher
btDispatcher * m_dispatcher
Definition: btDiscreteDynamicsWorld.cpp:800
btOverlappingPairCache
The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
Definition: btOverlappingPairCache.h:60
btDynamicsWorldFloatData::m_solverInfo
btContactSolverInfoFloatData m_solverInfo
Definition: btDynamicsWorld.h:166
btRigidBody::updateDeactivation
void updateDeactivation(btScalar timeStep)
Definition: btRigidBody.h:421
btTypedConstraint.h
btCollisionWorld::LocalConvexResult::m_hitCollisionObject
const btCollisionObject * m_hitCollisionObject
Definition: btCollisionWorld.h:332
btIDebugDraw::drawSpherePatch
virtual void drawSpherePatch(const btVector3 &center, const btVector3 &up, const btVector3 &axis, btScalar radius, btScalar minTh, btScalar maxTh, btScalar minPs, btScalar maxPs, const btVector3 &color, btScalar stepDegrees=btScalar(10.f), bool drawCenter=true)
Definition: btIDebugDraw.h:199
btMatrix3x3::getColumn
btVector3 getColumn(int i) const
Get a column of the matrix as a vector.
Definition: btMatrix3x3.h:134
btBroadphaseProxy::m_collisionFilterMask
int m_collisionFilterMask
Definition: btBroadphaseProxy.h:105
D6_SPRING_2_CONSTRAINT_TYPE
Definition: btTypedConstraint.h:47
btBroadphaseInterface::getOverlappingPairCache
virtual btOverlappingPairCache * getOverlappingPairCache()=0
btDiscreteDynamicsWorld::getCollisionWorld
btCollisionWorld * getCollisionWorld()
Definition: btDiscreteDynamicsWorld.h:138
btContactSolverInfoFloatData::m_maxGyroscopicForce
float m_maxGyroscopicForce
Definition: btContactSolverInfo.h:153
btPoint2PointConstraint.h
btIDebugDraw::DBG_DrawNormals
Definition: btIDebugDraw.h:73
SIMD_PI
#define SIMD_PI
Definition: btScalar.h:504
btCollisionObject::getWorldTransform
btTransform & getWorldTransform()
Definition: btCollisionObject.h:372
btManifoldPoint::m_normalWorldOnB
btVector3 m_normalWorldOnB
Definition: btManifoldPoint.h:100
btContactSolverInfoFloatData::m_splitImpulseTurnErp
float m_splitImpulseTurnErp
Definition: btContactSolverInfo.h:149
btBroadphaseProxy::StaticFilter
Definition: btBroadphaseProxy.h:94
btContactSolverInfoData::m_damping
btScalar m_damping
Definition: btContactSolverInfo.h:40
SIMD_2_PI
#define SIMD_2_PI
Definition: btScalar.h:505
btSliderConstraint::getUpperAngLimit
btScalar getUpperAngLimit()
Definition: btSliderConstraint.h:198
btManifoldPoint::m_positionWorldOnB
btVector3 m_positionWorldOnB
Definition: btManifoldPoint.h:97
btGeneric6DofSpring2Constraint::getTranslationalLimitMotor
btTranslationalLimitMotor2 * getTranslationalLimitMotor()
Definition: btGeneric6DofSpring2Constraint.h:336
btIDebugDraw::DBG_DrawWireframe
Definition: btIDebugDraw.h:59
btDynamicsWorld::m_internalPreTickCallback
btInternalTickCallback m_internalPreTickCallback
Definition: btDynamicsWorld.h:47
InplaceSolverIslandCallback::processConstraints
void processConstraints()
Definition: btDiscreteDynamicsWorld.cpp:185
btTransform::getOrigin
btVector3 & getOrigin()
Return the origin vector translation.
Definition: btTransform.h:117
btCollisionObject::getBroadphaseHandle
btBroadphaseProxy * getBroadphaseHandle()
Definition: btCollisionObject.h:389
btDiscreteDynamicsWorld::serialize
virtual void serialize(btSerializer *serializer)
Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (see B...
Definition: btDiscreteDynamicsWorld.cpp:1525
btRigidBody::getLinearVelocity
const btVector3 & getLinearVelocity() const
Definition: btRigidBody.h:362
btSimpleBroadphase.h
btCollisionWorld::m_debugDrawer
btIDebugDraw * m_debugDrawer
Definition: btCollisionWorld.h:102
btGeneric6DofConstraint::getCalculatedTransformB
const btTransform & getCalculatedTransformB() const
Gets the global transform of the offset for body B.
Definition: btGeneric6DofConstraint.h:387
InplaceSolverIslandCallback::m_bodies
btAlignedObjectArray< btCollisionObject * > m_bodies
Definition: btDiscreteDynamicsWorld.cpp:93
btCollisionWorld::getDebugDrawer
virtual btIDebugDraw * getDebugDrawer()
Definition: btCollisionWorld.h:162
btCollisionObject::getCcdSquareMotionThreshold
btScalar getCcdSquareMotionThreshold() const
Definition: btCollisionObject.h:512
btContactSolverInfoFloatData::m_solverMode
int m_solverMode
Definition: btContactSolverInfo.h:157
btDiscreteDynamicsWorld::m_gravity
btVector3 m_gravity
Definition: btDiscreteDynamicsWorld.h:53
btManifoldPoint::getPositionWorldOnB
const btVector3 & getPositionWorldOnB() const
Definition: btManifoldPoint.h:160
InplaceSolverIslandCallback::m_solver
btConstraintSolver * m_solver
Definition: btDiscreteDynamicsWorld.cpp:87
btDiscreteDynamicsWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btDiscreteDynamicsWorld.cpp:283
btPersistentManifold::getBody0
const btCollisionObject * getBody0() const
Definition: btPersistentManifold.h:102
btCollisionWorld::LocalConvexResult::m_hitNormalLocal
btVector3 m_hitNormalLocal
Definition: btCollisionWorld.h:334
btContactSolverInfoFloatData::m_maxErrorReduction
float m_maxErrorReduction
Definition: btContactSolverInfo.h:142
btTypedConstraint::isEnabled
bool isEnabled() const
Definition: btTypedConstraint.h:207
btOverlappingPairCache::findPair
virtual btBroadphasePair * findPair(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)=0
btRigidBody::addConstraintRef
void addConstraintRef(btTypedConstraint *c)
Definition: btRigidBody.cpp:433
btCollisionObject::isStaticObject
bool isStaticObject() const
Definition: btCollisionObject.h:198
btContactSolverInfoFloatData::m_globalCfm
float m_globalCfm
Definition: btContactSolverInfo.h:147
btRigidBody::getInvMass
btScalar getInvMass() const
Definition: btRigidBody.h:273
btRigidBody::getBroadphaseProxy
const btBroadphaseProxy * getBroadphaseProxy() const
Definition: btRigidBody.h:460
btVector3::dot
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition: btVector3.h:235
btCollisionObject::CO_RIGID_BODY
Definition: btCollisionObject.h:149
btDiscreteDynamicsWorld::predictUnconstraintMotion
virtual void predictUnconstraintMotion(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:1143
btTranslationalLimitMotor2::m_lowerLimit
btVector3 m_lowerLimit
Definition: btGeneric6DofSpring2Constraint.h:171
btGeneric6DofSpring2Constraint::getCalculatedTransformB
const btTransform & getCalculatedTransformB() const
Definition: btGeneric6DofSpring2Constraint.h:345
InplaceSolverIslandCallback::m_dispatcher
btDispatcher * m_dispatcher
Definition: btDiscreteDynamicsWorld.cpp:91
btAlignedFree
#define btAlignedFree(ptr)
Definition: btAlignedAllocator.h:48
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:49
btBroadphaseProxy::m_clientObject
void * m_clientObject
Definition: btBroadphaseProxy.h:103
btContactSolverInfoData::m_restitution
btScalar m_restitution
Definition: btContactSolverInfo.h:43
btDiscreteDynamicsWorld::saveKinematicState
virtual void saveKinematicState(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:262
btDiscreteDynamicsWorld::~btDiscreteDynamicsWorld
virtual ~btDiscreteDynamicsWorld()
Definition: btDiscreteDynamicsWorld.cpp:241
btTransform::getBasis
btMatrix3x3 & getBasis()
Return the basis matrix for the rotation.
Definition: btTransform.h:112
btRotationalLimitMotor2::m_hiLimit
btScalar m_hiLimit
Definition: btGeneric6DofSpring2Constraint.h:76
btCollisionObject::hasContactResponse
bool hasContactResponse() const
Definition: btCollisionObject.h:212
btCollisionWorld::LocalConvexResult
Definition: btCollisionWorld.h:316
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:29
btRigidBody::setLinearVelocity
void setLinearVelocity(const btVector3 &lin_vel)
Definition: btRigidBody.h:370
btContactSolverInfoFloatData::m_tau
float m_tau
Definition: btContactSolverInfo.h:136
btConeTwistConstraint.h
btCollisionObject::getInterpolationWorldTransform
const btTransform & getInterpolationWorldTransform() const
Definition: btCollisionObject.h:405
btIDebugDraw::flushLines
virtual void flushLines()
Definition: btIDebugDraw.h:476
btDiscreteDynamicsWorld::m_predictiveManifolds
btAlignedObjectArray< btPersistentManifold * > m_predictiveManifolds
Definition: btDiscreteDynamicsWorld.h:71
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:62
btManifoldPoint::m_positionWorldOnA
btVector3 m_positionWorldOnA
m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity ...
Definition: btManifoldPoint.h:99
btCollisionWorld::removeCollisionObject
virtual void removeCollisionObject(btCollisionObject *collisionObject)
Definition: btCollisionWorld.cpp:237
D6_SPRING_CONSTRAINT_TYPE
Definition: btTypedConstraint.h:44
btTranslationalLimitMotor::m_lowerLimit
btVector3 m_lowerLimit
the constraint lower limits
Definition: btGeneric6DofConstraint.h:143
btBroadphaseProxy::m_collisionFilterGroup
int m_collisionFilterGroup
Definition: btBroadphaseProxy.h:104
btRigidBody::getFlags
int getFlags() const
Definition: btRigidBody.h:533
btRigidBody::clearForces
void clearForces()
Definition: btRigidBody.h:346
btDispatcher::getNewManifold
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)=0
CProfileManager::Reset
static void Reset(void)
Definition: btQuickprof.cpp:589
btCollisionObject::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btCollisionObject.h:672
btGeneric6DofSpring2Constraint::getRotationalLimitMotor
btRotationalLimitMotor2 * getRotationalLimitMotor(int index)
Definition: btGeneric6DofSpring2Constraint.h:335
btBroadphaseInterface
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
Definition: btBroadphaseInterface.h:55
btHingeConstraint.h
SLIDER_CONSTRAINT_TYPE
Definition: btTypedConstraint.h:42
btRigidBody::proceedToTransform
void proceedToTransform(const btTransform &newTrans)
Definition: btRigidBody.cpp:227
btContactSolverInfoFloatData::m_damping
float m_damping
Definition: btContactSolverInfo.h:137
btContactSolverInfoData::m_erp2
btScalar m_erp2
Definition: btContactSolverInfo.h:48
btCollisionWorld::getDispatcher
btDispatcher * getDispatcher()
Definition: btCollisionWorld.h:138
btDiscreteDynamicsWorld::m_fixedTimeStep
btScalar m_fixedTimeStep
Definition: btDiscreteDynamicsWorld.h:57
btDiscreteDynamicsWorld::getConstraintSolver
virtual btConstraintSolver * getConstraintSolver()
Definition: btDiscreteDynamicsWorld.cpp:1422
btClosestNotMeConvexResultCallback::addSingleResult
virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult &convexResult, bool normalInWorldSpace)
Definition: btDiscreteDynamicsWorld.cpp:812
gNumClampedCcdMotions
int gNumClampedCcdMotions
internal debugging variable. this value shouldn&#39;t be too high
Definition: btDiscreteDynamicsWorld.cpp:877
btSliderConstraint::getUpperLinLimit
btScalar getUpperLinLimit()
Definition: btSliderConstraint.h:194
InplaceSolverIslandCallback::m_manifolds
btAlignedObjectArray< btPersistentManifold * > m_manifolds
Definition: btDiscreteDynamicsWorld.cpp:94
btBroadphaseProxy
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
Definition: btBroadphaseProxy.h:85
btDiscreteDynamicsWorld::stepSimulation
virtual int stepSimulation(btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))
if maxSubSteps > 0, it will interpolate motion between fixedTimeStep&#39;s
Definition: btDiscreteDynamicsWorld.cpp:401
btDiscreteDynamicsWorld::createPredictiveContacts
virtual void createPredictiveContacts(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:978
btBroadphasePair::m_algorithm
btCollisionAlgorithm * m_algorithm
Definition: btBroadphaseProxy.h:228
btContactSolverInfoData::m_numIterations
int m_numIterations
Definition: btContactSolverInfo.h:44
btDiscreteDynamicsWorld::applyGravity
virtual void applyGravity()
apply gravity, call this once per timestep
Definition: btDiscreteDynamicsWorld.cpp:339
btContactSolverInfoFloatData::m_erp2
float m_erp2
Definition: btContactSolverInfo.h:146
btSequentialImpulseConstraintSolver
The btSequentialImpulseConstraintSolver is a fast SIMD implementation of the Projected Gauss Seidel (...
Definition: btSequentialImpulseConstraintSolver.h:33
InplaceSolverIslandCallback::InplaceSolverIslandCallback
InplaceSolverIslandCallback(btConstraintSolver *solver, btStackAlloc *stackAlloc, btDispatcher *dispatcher)
Definition: btDiscreteDynamicsWorld.cpp:98
btManifoldResult::calculateCombinedFriction
static btScalar calculateCombinedFriction(const btCollisionObject *body0, const btCollisionObject *body1)
User can override this material combiner by implementing gContactAddedCallback and setting body0->m_c...
Definition: btManifoldResult.cpp:53
btCollisionShape.h
btDispatcherInfo::m_stepCount
int m_stepCount
Definition: btDispatcher.h:54
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
btHingeConstraint::getAFrame
const btTransform & getAFrame() const
Definition: btHingeConstraint.h:285
btContactSolverInfoFloatData::m_numIterations
int m_numIterations
Definition: btContactSolverInfo.h:156
btCollisionAlgorithm::getAllContactManifolds
virtual void getAllContactManifolds(btManifoldArray &manifoldArray)=0
btTransformUtil::integrateTransform
static void integrateTransform(const btTransform &curTrans, const btVector3 &linvel, const btVector3 &angvel, btScalar timeStep, btTransform &predictedTransform)
Definition: btTransformUtil.h:43
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:155
btDiscreteDynamicsWorld::debugDrawConstraint
virtual void debugDrawConstraint(btTypedConstraint *constraint)
Definition: btDiscreteDynamicsWorld.cpp:1176
btContactSolverInfoFloatData::m_singleAxisRollingFrictionThreshold
float m_singleAxisRollingFrictionThreshold
Definition: btContactSolverInfo.h:154
BT_PROFILE
#define BT_PROFILE(name)
Definition: btQuickprof.h:215
btSliderConstraint::getUseLinearReferenceFrameA
bool getUseLinearReferenceFrameA()
Definition: btSliderConstraint.h:200
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
btMotionState.h
btConeTwistConstraint
btConeTwistConstraint can be used to simulate ragdoll joints (upper arm, leg etc) ...
Definition: btConeTwistConstraint.h:62
btDiscreteDynamicsWorld::calculateSimulationIslands
virtual void calculateSimulationIslands()
Definition: btDiscreteDynamicsWorld.cpp:741
btVector3::serialize
void serialize(struct btVector3Data &dataOut) const
Definition: btVector3.h:1351
btCollisionObject::getCcdMotionThreshold
btScalar getCcdMotionThreshold() const
Definition: btCollisionObject.h:507
btDiscreteDynamicsWorld::removeConstraint
virtual void removeConstraint(btTypedConstraint *constraint)
Definition: btDiscreteDynamicsWorld.cpp:669
btSerializer::finalizeChunk
virtual void finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)=0
CProfileManager::Increment_Frame_Counter
static void Increment_Frame_Counter(void)
Definition: btQuickprof.cpp:605
btContactSolverInfo
Definition: btContactSolverInfo.h:69
btContactSolverInfoFloatData::m_timeStep
float m_timeStep
Definition: btContactSolverInfo.h:139
btRotationalLimitMotor::m_hiLimit
btScalar m_hiLimit
joint limit
Definition: btGeneric6DofConstraint.h:54
btCollisionWorld
CollisionWorld is interface and container for the collision detection.
Definition: btCollisionWorld.h:88
btConstraintSolver::allSolved
virtual void allSolved(const btContactSolverInfo &, class btIDebugDraw *)
Definition: btConstraintSolver.h:52
btDiscreteDynamicsWorld::updateActions
void updateActions(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:609
btRigidBody::applyDamping
void applyDamping(btScalar timeStep)
applyDamping damps the velocity, using the given m_linearDamping and m_angularDamping ...
Definition: btRigidBody.cpp:161
btDiscreteDynamicsWorld::getConstraint
virtual btTypedConstraint * getConstraint(int index)
Definition: btDiscreteDynamicsWorld.cpp:1432
btContactSolverInfoData::m_minimumSolverBatchSize
int m_minimumSolverBatchSize
Definition: btContactSolverInfo.h:61
btCollisionWorld::convexSweepTest
void convexSweepTest(const btConvexShape *castShape, const btTransform &from, const btTransform &to, ConvexResultCallback &resultCallback, btScalar allowedCcdPenetration=btScalar(0.)) const
convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultC...
Definition: btCollisionWorld.cpp:1086
btCollisionObject::getIslandTag
int getIslandTag() const
Definition: btCollisionObject.h:443
btContactSolverInfoFloatData::m_sor
float m_sor
Definition: btContactSolverInfo.h:143
btGeneric6DofSpring2Constraint::getAngle
btScalar getAngle(int axis_index) const
Definition: btGeneric6DofSpring2Constraint.h:357
btCollisionWorld::getDispatchInfo
btDispatcherInfo & getDispatchInfo()
Definition: btCollisionWorld.h:503
btContactSolverInfoFloatData::m_splitImpulsePenetrationThreshold
float m_splitImpulsePenetrationThreshold
Definition: btContactSolverInfo.h:148
btIDebugDraw.h
btCollisionDispatcher.h
btSortConstraintOnIslandPredicate
Definition: btDiscreteDynamicsWorld.cpp:71
btTypedConstraint::serialize
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btTypedConstraint.cpp:110
btDiscreteDynamicsWorld::m_latencyMotionStateInterpolation
bool m_latencyMotionStateInterpolation
Definition: btDiscreteDynamicsWorld.h:69
btCollisionObject::getHitFraction
btScalar getHitFraction() const
Definition: btCollisionObject.h:474
btConstraintSolver::prepareSolve
virtual void prepareSolve(int, int)
Definition: btConstraintSolver.h:47
WANTS_DEACTIVATION
#define WANTS_DEACTIVATION
Definition: btCollisionObject.h:24
btAlignedObjectArray::remove
void remove(const T &key)
Definition: btAlignedObjectArray.h:505
btDispatcherInfo::m_allowedCcdPenetration
btScalar m_allowedCcdPenetration
Definition: btDispatcher.h:62
btIDebugDraw::drawTransform
virtual void drawTransform(const btTransform &transform, btScalar orthoLen)
Definition: btIDebugDraw.h:166
btContactSolverInfoData::m_restingContactRestitutionThreshold
int m_restingContactRestitutionThreshold
Definition: btContactSolverInfo.h:60
CONETWIST_CONSTRAINT_TYPE
Definition: btTypedConstraint.h:40
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:78
btDiscreteDynamicsWorld::synchronizeSingleMotionState
void synchronizeSingleMotionState(btRigidBody *body)
this can be useful to synchronize a single rigid body -> graphics object
Definition: btDiscreteDynamicsWorld.cpp:353
btRigidBody::saveKinematicState
void saveKinematicState(btScalar step)
Definition: btRigidBody.cpp:111
btAlignedObjectArray::resize
void resize(int newsize, const T &fillData=T())
Definition: btAlignedObjectArray.h:218
btQuickprof.h
btFuzzyZero
bool btFuzzyZero(btScalar x)
Definition: btScalar.h:550
btDiscreteDynamicsWorld::m_synchronizeAllMotionStates
bool m_synchronizeAllMotionStates
Definition: btDiscreteDynamicsWorld.h:62
btDiscreteDynamicsWorld::integrateTransforms
virtual void integrateTransforms(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:1095
btGeneric6DofSpring2Constraint.h
btPersistentManifold::getBody1
const btCollisionObject * getBody1() const
Definition: btPersistentManifold.h:103
btGeneric6DofConstraint::getRotationalLimitMotor
btRotationalLimitMotor * getRotationalLimitMotor(int index)
Retrieves the angular limit informacion.
Definition: btGeneric6DofConstraint.h:500
btCollisionObject::getInternalType
int getInternalType() const
reserved for Bullet internal usage
Definition: btCollisionObject.h:367
btSliderConstraint.h
btMutexUnlock
void btMutexUnlock(btSpinMutex *mutex)
Definition: btThreads.h:78
btRigidBody::setAngularVelocity
void setAngularVelocity(const btVector3 &ang_vel)
Definition: btRigidBody.h:376
btIDebugDraw::getDebugMode
virtual int getDebugMode() const =0
btClosestNotMeConvexResultCallback::btClosestNotMeConvexResultCallback
btClosestNotMeConvexResultCallback(btCollisionObject *me, const btVector3 &fromA, const btVector3 &toA, btOverlappingPairCache *pairCache, btDispatcher *dispatcher)
Definition: btDiscreteDynamicsWorld.cpp:803
btCollisionWorld::m_collisionObjects
btAlignedObjectArray< btCollisionObject * > m_collisionObjects
Definition: btCollisionWorld.h:94
btIDebugDraw::DBG_DrawConstraints
Definition: btIDebugDraw.h:70
btDiscreteDynamicsWorld::synchronizeMotionStates
virtual void synchronizeMotionStates()
Definition: btDiscreteDynamicsWorld.cpp:375
btDiscreteDynamicsWorld::btDiscreteDynamicsWorld
btDiscreteDynamicsWorld(btDispatcher *dispatcher, btBroadphaseInterface *pairCache, btConstraintSolver *constraintSolver, btCollisionConfiguration *collisionConfiguration)
this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete thos...
Definition: btDiscreteDynamicsWorld.cpp:203
btDispatcherInfo::m_useContinuous
bool m_useContinuous
Definition: btDispatcher.h:57
BT_RIGIDBODY_CODE
#define BT_RIGIDBODY_CODE
Definition: btSerializer.h:120
btContactSolverInfoData::m_splitImpulsePenetrationThreshold
btScalar m_splitImpulsePenetrationThreshold
Definition: btContactSolverInfo.h:54
btSimulationIslandManager::storeIslandActivationState
virtual void storeIslandActivationState(btCollisionWorld *world)
Definition: btSimulationIslandManager.cpp:152
btDispatcher::needsResponse
virtual bool needsResponse(const btCollisionObject *body0, const btCollisionObject *body1)=0
DISABLE_DEACTIVATION
#define DISABLE_DEACTIVATION
Definition: btCollisionObject.h:25
btContactSolverInfoData::m_maxErrorReduction
btScalar m_maxErrorReduction
Definition: btContactSolverInfo.h:45
btCollisionWorld::performDiscreteCollisionDetection
virtual void performDiscreteCollisionDetection()
Definition: btCollisionWorld.cpp:216
btBroadphaseProxy::DefaultFilter
Definition: btBroadphaseProxy.h:93
btManifoldPoint::m_combinedFriction
btScalar m_combinedFriction
Definition: btManifoldPoint.h:103
btMutexLock
void btMutexLock(btSpinMutex *mutex)
Definition: btThreads.h:71
btContactSolverInfoFloatData::m_warmstartingFactor
float m_warmstartingFactor
Definition: btContactSolverInfo.h:152
btSimulationIslandManager::getUnionFind
btUnionFind & getUnionFind()
Definition: btSimulationIslandManager.h:48
btDiscreteDynamicsWorld::m_solverIslandCallback
InplaceSolverIslandCallback * m_solverIslandCallback
Definition: btDiscreteDynamicsWorld.h:43
btSliderConstraint
Definition: btSliderConstraint.h:71
btDiscreteDynamicsWorld::addCharacter
virtual void addCharacter(btActionInterface *character)
obsolete, use addAction instead
Definition: btDiscreteDynamicsWorld.cpp:697
btAlignedAlloc
#define btAlignedAlloc(size, alignment)
Definition: btAlignedAllocator.h:47
btTypedConstraint::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btTypedConstraint.h:440
btDiscreteDynamicsWorld::m_predictiveManifoldsMutex
btSpinMutex m_predictiveManifoldsMutex
Definition: btDiscreteDynamicsWorld.h:72
btContactSolverInfoData::m_linearSlop
btScalar m_linearSlop
Definition: btContactSolverInfo.h:56
btDiscreteDynamicsWorld::m_applySpeculativeContactRestitution
bool m_applySpeculativeContactRestitution
Definition: btDiscreteDynamicsWorld.h:63
btBroadphaseProxy::AllFilter
Definition: btBroadphaseProxy.h:99
btDynamicsWorldFloatData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btDynamicsWorld.h:164
btContactSolverInfoFloatData::m_splitImpulse
int m_splitImpulse
Definition: btContactSolverInfo.h:161
btDiscreteDynamicsWorld::m_constraintSolver
btConstraintSolver * m_constraintSolver
Definition: btDiscreteDynamicsWorld.h:45
btDiscreteDynamicsWorld::m_ownsIslandManager
bool m_ownsIslandManager
Definition: btDiscreteDynamicsWorld.h:60
POINT2POINT_CONSTRAINT_TYPE
Definition: btTypedConstraint.h:38
btConeTwistConstraint::getTwistSpan
btScalar getTwistSpan() const
Definition: btConeTwistConstraint.h:282
btRigidBody::getMotionState
btMotionState * getMotionState()
Definition: btRigidBody.h:474
btCollisionObject::isActive
bool isActive() const
Definition: btCollisionObject.h:299
btTypedConstraint::getConstraintType
btTypedConstraintType getConstraintType() const
Definition: btTypedConstraint.h:311
D6_CONSTRAINT_TYPE
Definition: btTypedConstraint.h:41
btDiscreteDynamicsWorld.h
btRigidBody::applyImpulse
void applyImpulse(const btVector3 &impulse, const btVector3 &rel_pos)
Definition: btRigidBody.h:334
btSliderConstraint::getLowerAngLimit
btScalar getLowerAngLimit()
Definition: btSliderConstraint.h:196
btDiscreteDynamicsWorld::getNumConstraints
virtual int getNumConstraints() const
Definition: btDiscreteDynamicsWorld.cpp:1428
btDiscreteDynamicsWorld::serializeRigidBodies
void serializeRigidBodies(btSerializer *serializer)
Definition: btDiscreteDynamicsWorld.cpp:1443
HINGE_CONSTRAINT_TYPE
Definition: btTypedConstraint.h:39
btClosestNotMeConvexResultCallback::m_allowedPenetration
btScalar m_allowedPenetration
Definition: btDiscreteDynamicsWorld.cpp:798
btDiscreteDynamicsWorld::updateActivationState
virtual void updateActivationState(btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:620
btGeneric6DofConstraint::getAngle
btScalar getAngle(int axis_index) const
Get the relative Euler angle.
Definition: btGeneric6DofConstraint.cpp:732
InplaceSolverIslandCallback::m_constraints
btAlignedObjectArray< btTypedConstraint * > m_constraints
Definition: btDiscreteDynamicsWorld.cpp:95
btDispatcherInfo
Definition: btDispatcher.h:30
btDispatcherInfo::m_timeStep
btScalar m_timeStep
Definition: btDispatcher.h:53
btCollisionObject::getCcdSweptSphereRadius
btScalar getCcdSweptSphereRadius() const
Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
Definition: btCollisionObject.h:496
btDiscreteDynamicsWorld::createPredictiveContactsInternal
void createPredictiveContactsInternal(btRigidBody **bodies, int numBodies, btScalar timeStep)
Definition: btDiscreteDynamicsWorld.cpp:880
btUnionFind::unite
void unite(int p, int q)
Definition: btUnionFind.h:81
btDiscreteDynamicsWorld::addVehicle
virtual void addVehicle(btActionInterface *vehicle)
obsolete, use addAction instead
Definition: btDiscreteDynamicsWorld.cpp:687
InplaceSolverIslandCallback::operator=
InplaceSolverIslandCallback & operator=(InplaceSolverIslandCallback &other)
Definition: btDiscreteDynamicsWorld.cpp:112
btClosestNotMeConvexResultCallback::needsCollision
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
Definition: btDiscreteDynamicsWorld.cpp:833
btContactSolverInfoData::m_timeStep
btScalar m_timeStep
Definition: btContactSolverInfo.h:42
btDiscreteDynamicsWorld::removeRigidBody
virtual void removeRigidBody(btRigidBody *body)
Definition: btDiscreteDynamicsWorld.cpp:555
btCollisionWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btCollisionWorld.cpp:1513
btSphereShape.h
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:75
btRigidBody::removeConstraintRef
void removeConstraintRef(btTypedConstraint *c)
Definition: btRigidBody.cpp:456
btHingeConstraint::getRigidBodyA
const btRigidBody & getRigidBodyA() const
Definition: btHingeConstraint.h:132
btManifoldResult::calculateCombinedRestitution
static btScalar calculateCombinedRestitution(const btCollisionObject *body0, const btCollisionObject *body1)
in the future we can let the user override the methods to combine restitution and friction ...
Definition: btManifoldResult.cpp:66
btTypedConstraint::getDbgDrawSize
btScalar getDbgDrawSize()
Definition: btTypedConstraint.h:320
btChunk::m_oldPtr
void * m_oldPtr
Definition: btSerializer.h:56
btContactSolverInfoData::m_maxGyroscopicForce
btScalar m_maxGyroscopicForce
Definition: btContactSolverInfo.h:62
btSimulationIslandManager.h
btDynamicsWorld::getSolverInfo
btContactSolverInfo & getSolverInfo()
Definition: btDynamicsWorld.h:133
btCollisionWorld::getBroadphase
const btBroadphaseInterface * getBroadphase() const
Definition: btCollisionWorld.h:122
btGeneric6DofConstraint.h
btMotionState::setWorldTransform
virtual void setWorldTransform(const btTransform &worldTrans)=0
btCollisionObject::setActivationState
void setActivationState(int newState) const
Definition: btCollisionObject.cpp:60
btPersistentManifold::addManifoldPoint
int addManifoldPoint(const btManifoldPoint &newPoint, bool isPredictive=false)
Definition: btPersistentManifold.cpp:210
btSerializer::allocate
virtual btChunk * allocate(size_t size, int numElements)=0
btTranslationalLimitMotor2::m_upperLimit
btVector3 m_upperLimit
Definition: btGeneric6DofSpring2Constraint.h:172
btConeTwistConstraint::getBFrame
const btTransform & getBFrame() const
Definition: btConeTwistConstraint.h:254
btContactSolverInfoData::m_warmstartingFactor
btScalar m_warmstartingFactor
Definition: btContactSolverInfo.h:57
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
btAlignedObjectArray::quickSort
void quickSort(const L &CompareFunc)
Definition: btAlignedObjectArray.h:363
btContactSolverInfoData::m_solverMode
int m_solverMode
Definition: btContactSolverInfo.h:59
btCos
btScalar btCos(btScalar x)
Definition: btScalar.h:476
btContactSolverInfoData::m_sor
btScalar m_sor
Definition: btContactSolverInfo.h:46
btContactSolverInfoFloatData::m_friction
float m_friction
Definition: btContactSolverInfo.h:138
btSimulationIslandManager::~btSimulationIslandManager
virtual ~btSimulationIslandManager()
Definition: btSimulationIslandManager.cpp:33
btCollisionAlgorithm.h
btCollisionWorld::ClosestConvexResultCallback
Definition: btCollisionWorld.h:374
btContactSolverInfo.h
btConstraintSolver::~btConstraintSolver
virtual ~btConstraintSolver()
Definition: btConstraintSolver.h:45
btSerializer.h
btDiscreteDynamicsWorld::m_constraints
btAlignedObjectArray< btTypedConstraint * > m_constraints
Definition: btDiscreteDynamicsWorld.h:49
btRigidBody::setGravity
void setGravity(const btVector3 &acceleration)
Definition: btRigidBody.cpp:137
btConstraintSolver
Definition: btConstraintSolver.h:40
InplaceSolverIslandCallback::m_sortedConstraints
btTypedConstraint ** m_sortedConstraints
Definition: btDiscreteDynamicsWorld.cpp:88
btBroadphasePair
The btBroadphasePair class contains a pair of aabb-overlapping objects.
Definition: btBroadphaseProxy.h:185