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

Bullet Collision Detection & Physics Library

btRigidBody.cpp
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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 #include "btRigidBody.h"
17 #include "BulletCollision/CollisionShapes/btConvexShape.h"
18 #include "LinearMath/btMinMax.h"
19 #include "LinearMath/btTransformUtil.h"
20 #include "LinearMath/btMotionState.h"
21 #include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
22 #include "LinearMath/btSerializer.h"
23
24 //'temporarily' global variables
25 btScalar gDeactivationTime = btScalar(2.);
26 bool gDisableDeactivation = false;
27 static int uniqueId = 0;
28
29 btRigidBody::btRigidBody(const btRigidBody::btRigidBodyConstructionInfo& constructionInfo)
30 {
31 setupRigidBody(constructionInfo);
32 }
33
34 btRigidBody::btRigidBody(btScalar mass, btMotionState* motionState, btCollisionShape* collisionShape, const btVector3& localInertia)
35 {
36 btRigidBodyConstructionInfo cinfo(mass, motionState, collisionShape, localInertia);
37 setupRigidBody(cinfo);
38 }
39
40 void btRigidBody::setupRigidBody(const btRigidBody::btRigidBodyConstructionInfo& constructionInfo)
41 {
42 m_internalType = CO_RIGID_BODY;
43
44 m_linearVelocity.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
45 m_angularVelocity.setValue(btScalar(0.), btScalar(0.), btScalar(0.));
46 m_angularFactor.setValue(1, 1, 1);
47 m_linearFactor.setValue(1, 1, 1);
48 m_gravity.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
49 m_gravity_acceleration.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
50 m_totalForce.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
51 m_totalTorque.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)),
52 setDamping(constructionInfo.m_linearDamping, constructionInfo.m_angularDamping);
53
54 m_linearSleepingThreshold = constructionInfo.m_linearSleepingThreshold;
55 m_angularSleepingThreshold = constructionInfo.m_angularSleepingThreshold;
56 m_optionalMotionState = constructionInfo.m_motionState;
57 m_contactSolverType = 0;
58 m_frictionSolverType = 0;
59 m_additionalDamping = constructionInfo.m_additionalDamping;
60 m_additionalDampingFactor = constructionInfo.m_additionalDampingFactor;
61 m_additionalLinearDampingThresholdSqr = constructionInfo.m_additionalLinearDampingThresholdSqr;
62 m_additionalAngularDampingThresholdSqr = constructionInfo.m_additionalAngularDampingThresholdSqr;
63 m_additionalAngularDampingFactor = constructionInfo.m_additionalAngularDampingFactor;
64
65 if (m_optionalMotionState)
66 {
67 m_optionalMotionState->getWorldTransform(m_worldTransform);
68 }
69 else
70 {
71 m_worldTransform = constructionInfo.m_startWorldTransform;
72 }
73
74 m_interpolationWorldTransform = m_worldTransform;
75 m_interpolationLinearVelocity.setValue(0, 0, 0);
76 m_interpolationAngularVelocity.setValue(0, 0, 0);
77
78 //moved to btCollisionObject
79 m_friction = constructionInfo.m_friction;
80 m_rollingFriction = constructionInfo.m_rollingFriction;
81 m_spinningFriction = constructionInfo.m_spinningFriction;
82
83 m_restitution = constructionInfo.m_restitution;
84
85 setCollisionShape(constructionInfo.m_collisionShape);
86 m_debugBodyId = uniqueId++;
87
88 setMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia);
89 updateInertiaTensor();
90
91 m_rigidbodyFlags = BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY;
92
93 m_deltaLinearVelocity.setZero();
94 m_deltaAngularVelocity.setZero();
95 m_invMass = m_inverseMass * m_linearFactor;
96 m_pushVelocity.setZero();
97 m_turnVelocity.setZero();
98 }
99
100 void btRigidBody::predictIntegratedTransform(btScalar timeStep, btTransform& predictedTransform)
101 {
102 btTransformUtil::integrateTransform(m_worldTransform, m_linearVelocity, m_angularVelocity, timeStep, predictedTransform);
103 }
104
105 void btRigidBody::saveKinematicState(btScalar timeStep)
106 {
107 //todo: clamp to some (user definable) safe minimum timestep, to limit maximum angular/linear velocities
108 if (timeStep != btScalar(0.))
109 {
110 //if we use motionstate to synchronize world transforms, get the new kinematic/animated world transform
111 if (getMotionState())
112 getMotionState()->getWorldTransform(m_worldTransform);
113 btVector3 linVel, angVel;
114
115 btTransformUtil::calculateVelocity(m_interpolationWorldTransform, m_worldTransform, timeStep, m_linearVelocity, m_angularVelocity);
116 m_interpolationLinearVelocity = m_linearVelocity;
117 m_interpolationAngularVelocity = m_angularVelocity;
118 m_interpolationWorldTransform = m_worldTransform;
119 //printf("angular = %f %f %f\n",m_angularVelocity.getX(),m_angularVelocity.getY(),m_angularVelocity.getZ());
120 }
121 }
122
123 void btRigidBody::getAabb(btVector3& aabbMin, btVector3& aabbMax) const
124 {
125 getCollisionShape()->getAabb(m_worldTransform, aabbMin, aabbMax);
126 }
127
128 void btRigidBody::setGravity(const btVector3& acceleration)
129 {
130 if (m_inverseMass != btScalar(0.0))
131 {
132 m_gravity = acceleration * (btScalar(1.0) / m_inverseMass);
133 }
134 m_gravity_acceleration = acceleration;
135 }
136
137 void btRigidBody::setDamping(btScalar lin_damping, btScalar ang_damping)
138 {
139 m_linearDamping = btClamped(lin_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
140 m_angularDamping = btClamped(ang_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
141 }
142
144 void btRigidBody::applyDamping(btScalar timeStep)
145 {
146 //On new damping: see discussion/issue report here: http://code.google.com/p/bullet/issues/detail?id=74
147 //todo: do some performance comparisons (but other parts of the engine are probably bottleneck anyway
148
149 //#define USE_OLD_DAMPING_METHOD 1
150 #ifdef USE_OLD_DAMPING_METHOD
151 m_linearVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_linearDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
152 m_angularVelocity *= GEN_clamped((btScalar(1.) - timeStep * m_angularDamping), (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
153 #else
154 m_linearVelocity *= btPow(btScalar(1) - m_linearDamping, timeStep);
155 m_angularVelocity *= btPow(btScalar(1) - m_angularDamping, timeStep);
156 #endif
157
158 if (m_additionalDamping)
159 {
160 //Additional damping can help avoiding lowpass jitter motion, help stability for ragdolls etc.
161 //Such damping is undesirable, so once the overall simulation quality of the rigid body dynamics system has improved, this should become obsolete
162 if ((m_angularVelocity.length2() < m_additionalAngularDampingThresholdSqr) &&
163 (m_linearVelocity.length2() < m_additionalLinearDampingThresholdSqr))
164 {
165 m_angularVelocity *= m_additionalDampingFactor;
166 m_linearVelocity *= m_additionalDampingFactor;
167 }
168
169 btScalar speed = m_linearVelocity.length();
170 if (speed < m_linearDamping)
171 {
172 btScalar dampVel = btScalar(0.005);
173 if (speed > dampVel)
174 {
175 btVector3 dir = m_linearVelocity.normalized();
176 m_linearVelocity -= dir * dampVel;
177 }
178 else
179 {
180 m_linearVelocity.setValue(btScalar(0.), btScalar(0.), btScalar(0.));
181 }
182 }
183
184 btScalar angSpeed = m_angularVelocity.length();
185 if (angSpeed < m_angularDamping)
186 {
187 btScalar angDampVel = btScalar(0.005);
188 if (angSpeed > angDampVel)
189 {
190 btVector3 dir = m_angularVelocity.normalized();
191 m_angularVelocity -= dir * angDampVel;
192 }
193 else
194 {
195 m_angularVelocity.setValue(btScalar(0.), btScalar(0.), btScalar(0.));
196 }
197 }
198 }
199 }
200
201 void btRigidBody::applyGravity()
202 {
203 if (isStaticOrKinematicObject())
204 return;
205
206 applyCentralForce(m_gravity);
207 }
208
209 void btRigidBody::clearGravity()
210 {
211 if (isStaticOrKinematicObject())
212 return;
213
214 applyCentralForce(-m_gravity);
215 }
216
217 void btRigidBody::proceedToTransform(const btTransform& newTrans)
218 {
219 setCenterOfMassTransform(newTrans);
220 }
221
222 void btRigidBody::setMassProps(btScalar mass, const btVector3& inertia)
223 {
224 if (mass == btScalar(0.))
225 {
226 m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
227 m_inverseMass = btScalar(0.);
228 }
229 else
230 {
231 m_collisionFlags &= (~btCollisionObject::CF_STATIC_OBJECT);
232 m_inverseMass = btScalar(1.0) / mass;
233 }
234
235 //Fg = m * a
236 m_gravity = mass * m_gravity_acceleration;
237
238 m_invInertiaLocal.setValue(inertia.x() != btScalar(0.0) ? btScalar(1.0) / inertia.x() : btScalar(0.0),
239 inertia.y() != btScalar(0.0) ? btScalar(1.0) / inertia.y() : btScalar(0.0),
240 inertia.z() != btScalar(0.0) ? btScalar(1.0) / inertia.z() : btScalar(0.0));
241
242 m_invMass = m_linearFactor * m_inverseMass;
243 }
244
245 void btRigidBody::updateInertiaTensor()
246 {
247 m_invInertiaTensorWorld = m_worldTransform.getBasis().scaled(m_invInertiaLocal) * m_worldTransform.getBasis().transpose();
248 }
249
250 btVector3 btRigidBody::getLocalInertia() const
251 {
252 btVector3 inertiaLocal;
253 const btVector3 inertia = m_invInertiaLocal;
254 inertiaLocal.setValue(inertia.x() != btScalar(0.0) ? btScalar(1.0) / inertia.x() : btScalar(0.0),
255 inertia.y() != btScalar(0.0) ? btScalar(1.0) / inertia.y() : btScalar(0.0),
256 inertia.z() != btScalar(0.0) ? btScalar(1.0) / inertia.z() : btScalar(0.0));
257 return inertiaLocal;
258 }
259
260 inline btVector3 evalEulerEqn(const btVector3& w1, const btVector3& w0, const btVector3& T, const btScalar dt,
261 const btMatrix3x3& I)
262 {
263 const btVector3 w2 = I * w1 + w1.cross(I * w1) * dt - (T * dt + I * w0);
264 return w2;
265 }
266
267 inline btMatrix3x3 evalEulerEqnDeriv(const btVector3& w1, const btVector3& w0, const btScalar dt,
268 const btMatrix3x3& I)
269 {
270 btMatrix3x3 w1x, Iw1x;
271 const btVector3 Iwi = (I * w1);
272 w1.getSkewSymmetricMatrix(&w1x[0], &w1x[1], &w1x[2]);
273 Iwi.getSkewSymmetricMatrix(&Iw1x[0], &Iw1x[1], &Iw1x[2]);
274
275 const btMatrix3x3 dfw1 = I + (w1x * I - Iw1x) * dt;
276 return dfw1;
277 }
278
279 btVector3 btRigidBody::computeGyroscopicForceExplicit(btScalar maxGyroscopicForce) const
280 {
281 btVector3 inertiaLocal = getLocalInertia();
282 btMatrix3x3 inertiaTensorWorld = getWorldTransform().getBasis().scaled(inertiaLocal) * getWorldTransform().getBasis().transpose();
283 btVector3 tmp = inertiaTensorWorld * getAngularVelocity();
284 btVector3 gf = getAngularVelocity().cross(tmp);
285 btScalar l2 = gf.length2();
286 if (l2 > maxGyroscopicForce * maxGyroscopicForce)
287 {
288 gf *= btScalar(1.) / btSqrt(l2) * maxGyroscopicForce;
289 }
290 return gf;
291 }
292
293 btVector3 btRigidBody::computeGyroscopicImpulseImplicit_Body(btScalar step) const
294 {
295 btVector3 idl = getLocalInertia();
296 btVector3 omega1 = getAngularVelocity();
297 btQuaternion q = getWorldTransform().getRotation();
298
299 // Convert to body coordinates
300 btVector3 omegab = quatRotate(q.inverse(), omega1);
301 btMatrix3x3 Ib;
302 Ib.setValue(idl.x(), 0, 0,
303 0, idl.y(), 0,
304 0, 0, idl.z());
305
306 btVector3 ibo = Ib * omegab;
307
308 // Residual vector
309 btVector3 f = step * omegab.cross(ibo);
310
311 btMatrix3x3 skew0;
312 omegab.getSkewSymmetricMatrix(&skew0[0], &skew0[1], &skew0[2]);
313 btVector3 om = Ib * omegab;
314 btMatrix3x3 skew1;
315 om.getSkewSymmetricMatrix(&skew1[0], &skew1[1], &skew1[2]);
316
317 // Jacobian
318 btMatrix3x3 J = Ib + (skew0 * Ib - skew1) * step;
319
320 // btMatrix3x3 Jinv = J.inverse();
321 // btVector3 omega_div = Jinv*f;
322 btVector3 omega_div = J.solve33(f);
323
324 // Single Newton-Raphson update
325 omegab = omegab - omega_div; //Solve33(J, f);
326 // Back to world coordinates
327 btVector3 omega2 = quatRotate(q, omegab);
328 btVector3 gf = omega2 - omega1;
329 return gf;
330 }
331
332 btVector3 btRigidBody::computeGyroscopicImpulseImplicit_World(btScalar step) const
333 {
334 // use full newton-euler equations. common practice to drop the wxIw term. want it for better tumbling behavior.
335 // calculate using implicit euler step so it's stable.
336
337 const btVector3 inertiaLocal = getLocalInertia();
338 const btVector3 w0 = getAngularVelocity();
339
340 btMatrix3x3 I;
341
342 I = m_worldTransform.getBasis().scaled(inertiaLocal) *
343 m_worldTransform.getBasis().transpose();
344
345 // use newtons method to find implicit solution for new angular velocity (w')
346 // f(w') = -(T*step + Iw) + Iw' + w' + w'xIw'*step = 0
347 // df/dw' = I + 1xIw'*step + w'xI*step
348
349 btVector3 w1 = w0;
350
351 // one step of newton's method
352 {
353 const btVector3 fw = evalEulerEqn(w1, w0, btVector3(0, 0, 0), step, I);
354 const btMatrix3x3 dfw = evalEulerEqnDeriv(w1, w0, step, I);
355
356 btVector3 dw;
357 dw = dfw.solve33(fw);
358 //const btMatrix3x3 dfw_inv = dfw.inverse();
359 //dw = dfw_inv*fw;
360
361 w1 -= dw;
362 }
363
364 btVector3 gf = (w1 - w0);
365 return gf;
366 }
367
368 void btRigidBody::integrateVelocities(btScalar step)
369 {
370 if (isStaticOrKinematicObject())
371 return;
372
373 m_linearVelocity += m_totalForce * (m_inverseMass * step);
374 m_angularVelocity += m_invInertiaTensorWorld * m_totalTorque * step;
375
376 #define MAX_ANGVEL SIMD_HALF_PI
377 btScalar angvel = m_angularVelocity.length();
379 if (angvel * step > MAX_ANGVEL)
380 {
381 m_angularVelocity *= (MAX_ANGVEL / step) / angvel;
382 }
383 }
384
385 btQuaternion btRigidBody::getOrientation() const
386 {
387 btQuaternion orn;
388 m_worldTransform.getBasis().getRotation(orn);
389 return orn;
390 }
391
392 void btRigidBody::setCenterOfMassTransform(const btTransform& xform)
393 {
394 if (isKinematicObject())
395 {
396 m_interpolationWorldTransform = m_worldTransform;
397 }
398 else
399 {
400 m_interpolationWorldTransform = xform;
401 }
402 m_interpolationLinearVelocity = getLinearVelocity();
403 m_interpolationAngularVelocity = getAngularVelocity();
404 m_worldTransform = xform;
405 updateInertiaTensor();
406 }
407
408 void btRigidBody::addConstraintRef(btTypedConstraint* c)
409 {
411
412 int index = m_constraintRefs.findLinearSearch(c);
413 //don't add constraints that are already referenced
414 //btAssert(index == m_constraintRefs.size());
415 if (index == m_constraintRefs.size())
416 {
417 m_constraintRefs.push_back(c);
418 btCollisionObject* colObjA = &c->getRigidBodyA();
419 btCollisionObject* colObjB = &c->getRigidBodyB();
420 if (colObjA == this)
421 {
422 colObjA->setIgnoreCollisionCheck(colObjB, true);
423 }
424 else
425 {
426 colObjB->setIgnoreCollisionCheck(colObjA, true);
427 }
428 }
429 }
430
431 void btRigidBody::removeConstraintRef(btTypedConstraint* c)
432 {
433 int index = m_constraintRefs.findLinearSearch(c);
434 //don't remove constraints that are not referenced
435 if (index < m_constraintRefs.size())
436 {
437 m_constraintRefs.remove(c);
438 btCollisionObject* colObjA = &c->getRigidBodyA();
439 btCollisionObject* colObjB = &c->getRigidBodyB();
440 if (colObjA == this)
441 {
442 colObjA->setIgnoreCollisionCheck(colObjB, false);
443 }
444 else
445 {
446 colObjB->setIgnoreCollisionCheck(colObjA, false);
447 }
448 }
449 }
450
451 int btRigidBody::calculateSerializeBufferSize() const
452 {
453 int sz = sizeof(btRigidBodyData);
454 return sz;
455 }
456
458 const char* btRigidBody::serialize(void* dataBuffer, class btSerializer* serializer) const
459 {
460 btRigidBodyData* rbd = (btRigidBodyData*)dataBuffer;
461
462 btCollisionObject::serialize(&rbd->m_collisionObjectData, serializer);
463
464 m_invInertiaTensorWorld.serialize(rbd->m_invInertiaTensorWorld);
465 m_linearVelocity.serialize(rbd->m_linearVelocity);
466 m_angularVelocity.serialize(rbd->m_angularVelocity);
467 rbd->m_inverseMass = m_inverseMass;
468 m_angularFactor.serialize(rbd->m_angularFactor);
469 m_linearFactor.serialize(rbd->m_linearFactor);
470 m_gravity.serialize(rbd->m_gravity);
471 m_gravity_acceleration.serialize(rbd->m_gravity_acceleration);
472 m_invInertiaLocal.serialize(rbd->m_invInertiaLocal);
473 m_totalForce.serialize(rbd->m_totalForce);
474 m_totalTorque.serialize(rbd->m_totalTorque);
475 rbd->m_linearDamping = m_linearDamping;
476 rbd->m_angularDamping = m_angularDamping;
477 rbd->m_additionalDamping = m_additionalDamping;
478 rbd->m_additionalDampingFactor = m_additionalDampingFactor;
479 rbd->m_additionalLinearDampingThresholdSqr = m_additionalLinearDampingThresholdSqr;
480 rbd->m_additionalAngularDampingThresholdSqr = m_additionalAngularDampingThresholdSqr;
481 rbd->m_additionalAngularDampingFactor = m_additionalAngularDampingFactor;
482 rbd->m_linearSleepingThreshold = m_linearSleepingThreshold;
483 rbd->m_angularSleepingThreshold = m_angularSleepingThreshold;
484
485 // Fill padding with zeros to appease msan.
486 #ifdef BT_USE_DOUBLE_PRECISION
487 memset(rbd->m_padding, 0, sizeof(rbd->m_padding));
488 #endif
489
490 return btRigidBodyDataName;
491 }
492
493 void btRigidBody::serializeSingleObject(class btSerializer* serializer) const
494 {
495 btChunk* chunk = serializer->allocate(calculateSerializeBufferSize(), 1);
496 const char* structType = serialize(chunk->m_oldPtr, serializer);
497 serializer->finalizeChunk(chunk, structType, BT_RIGIDBODY_CODE, (void*)this);
498 }
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:76
btRigidBody::applyGravity
void applyGravity()
Definition: btRigidBody.cpp:201
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:50
btRigidBody::btRigidBodyConstructionInfo::m_linearDamping
btScalar m_linearDamping
Definition: btRigidBody.h:120
btVector3::serialize
void serialize(struct btVector3Data &dataOut) const
Definition: btVector3.h:1317
btRigidBody::m_invInertiaTensorWorld
btMatrix3x3 m_invInertiaTensorWorld
Definition: btRigidBody.h:61
btRigidBody::m_turnVelocity
btVector3 m_turnVelocity
Definition: btRigidBody.h:101
btRigidBody::btRigidBodyConstructionInfo::m_angularSleepingThreshold
btScalar m_angularSleepingThreshold
Definition: btRigidBody.h:134
btRigidBody::btRigidBodyConstructionInfo::m_angularDamping
btScalar m_angularDamping
Definition: btRigidBody.h:121
btRigidBody::predictIntegratedTransform
void predictIntegratedTransform(btScalar step, btTransform &predictedTransform)
continuous collision detection needs prediction
Definition: btRigidBody.cpp:100
btTransform::getRotation
btQuaternion getRotation() const
Return a quaternion representing the rotation.
Definition: btTransform.h:118
btRigidBody::m_angularDamping
btScalar m_angularDamping
Definition: btRigidBody.h:74
btRigidBody::btRigidBodyConstructionInfo::m_additionalAngularDampingThresholdSqr
btScalar m_additionalAngularDampingThresholdSqr
Definition: btRigidBody.h:141
btCollisionObject::m_interpolationWorldTransform
btTransform m_interpolationWorldTransform
m_interpolationWorldTransform is used for CCD and interpolation it can be either previous or future (...
Definition: btCollisionObject.h:56
btRigidBody::serialize
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btRigidBody.cpp:458
btQuaternion
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
Definition: btQuaternion.h:50
btVector3::length
btScalar length() const
Return the length of the vector.
Definition: btVector3.h:257
btRigidBody::serializeSingleObject
virtual void serializeSingleObject(class btSerializer *serializer) const
Definition: btRigidBody.cpp:493
btVector3::setValue
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
btRigidBody::btRigidBodyConstructionInfo::m_additionalLinearDampingThresholdSqr
btScalar m_additionalLinearDampingThresholdSqr
Definition: btRigidBody.h:140
btRigidBody::getAngularVelocity
const btVector3 & getAngularVelocity() const
Definition: btRigidBody.h:402
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btRigidBody::m_totalTorque
btVector3 m_totalTorque
Definition: btRigidBody.h:71
btMotionState.h
gDisableDeactivation
bool gDisableDeactivation
Definition: btRigidBody.cpp:26
btRigidBody::m_additionalDamping
bool m_additionalDamping
Definition: btRigidBody.h:76
btCollisionObject::serialize
virtual const char * serialize(void *dataBuffer, class btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btCollisionObject.cpp:81
btTypedConstraint::getRigidBodyA
const btRigidBody & getRigidBodyA() const
Definition: btTypedConstraint.h:214
btRigidBody::btRigidBodyConstructionInfo::m_mass
btScalar m_mass
Definition: btRigidBody.h:111
btRigidBody::m_contactSolverType
int m_contactSolverType
Definition: btRigidBody.h:518
btRigidBody::m_rigidbodyFlags
int m_rigidbodyFlags
Definition: btRigidBody.h:91
btRigidBody::setGravity
void setGravity(const btVector3 &acceleration)
Definition: btRigidBody.cpp:128
btRigidBody::computeGyroscopicForceExplicit
btVector3 computeGyroscopicForceExplicit(btScalar maxGyroscopicForce) const
explicit version is best avoided, it gains energy
Definition: btRigidBody.cpp:279
btVector3::cross
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
Definition: btVector3.h:380
btQuaternion::inverse
btQuaternion inverse() const
Return the inverse of this quaternion.
Definition: btQuaternion.h:497
btChunk
Definition: btSerializer.h:48
btRigidBody::updateInertiaTensor
void updateInertiaTensor()
Definition: btRigidBody.cpp:245
btAlignedObjectArray::findLinearSearch
int findLinearSearch(const T &key) const
Definition: btAlignedObjectArray.h:438
btRigidBody::getAabb
void getAabb(btVector3 &aabbMin, btVector3 &aabbMax) const
Definition: btRigidBody.cpp:123
btMotionState::getWorldTransform
virtual void getWorldTransform(btTransform &worldTrans) const =0
evalEulerEqn
btVector3 evalEulerEqn(const btVector3 &w1, const btVector3 &w0, const btVector3 &T, const btScalar dt, const btMatrix3x3 &I)
Definition: btRigidBody.cpp:260
btRigidBody::m_inverseMass
btScalar m_inverseMass
Definition: btRigidBody.h:64
btConvexShape.h
btRigidBody::integrateVelocities
void integrateVelocities(btScalar step)
Definition: btRigidBody.cpp:368
btCollisionObject::m_worldTransform
btTransform m_worldTransform
Definition: btCollisionObject.h:52
btRigidBody.h
btRigidBody::computeGyroscopicImpulseImplicit_World
btVector3 computeGyroscopicImpulseImplicit_World(btScalar dt) const
perform implicit force computation in world space
Definition: btRigidBody.cpp:332
BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY
@ BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY
Definition: btRigidBody.h:47
btMatrix3x3::solve33
btVector3 solve33(const btVector3 &b) const
Solve A * x = b, where b is a column vector.
Definition: btMatrix3x3.h:632
btRigidBody::m_gravity
btVector3 m_gravity
Definition: btRigidBody.h:67
btVector3::setZero
void setZero()
Definition: btVector3.h:671
btRigidBody::btRigidBodyConstructionInfo::m_spinningFriction
btScalar m_spinningFriction
Definition: btRigidBody.h:128
btCollisionObject::isKinematicObject
bool isKinematicObject() const
Definition: btCollisionObject.h:200
btTransformUtil.h
gDeactivationTime
btScalar gDeactivationTime
Definition: btRigidBody.cpp:25
btRigidBody::btRigidBodyConstructionInfo::m_startWorldTransform
btTransform m_startWorldTransform
Definition: btRigidBody.h:116
btCollisionObject::~btCollisionObject
virtual ~btCollisionObject()
Definition: btCollisionObject.cpp:57
btRigidBody::setDamping
void setDamping(btScalar lin_damping, btScalar ang_damping)
Definition: btRigidBody.cpp:137
btRigidBody::m_angularSleepingThreshold
btScalar m_angularSleepingThreshold
Definition: btRigidBody.h:83
btCollisionObject::m_spinningFriction
btScalar m_spinningFriction
Definition: btCollisionObject.h:88
btRigidBody::getOrientation
btQuaternion getOrientation() const
Definition: btRigidBody.cpp:385
btVector3::y
const btScalar & y() const
Return the y value.
Definition: btVector3.h:577
btTypedConstraint::getRigidBodyB
const btRigidBody & getRigidBodyB() const
Definition: btTypedConstraint.h:218
btCollisionObject::isStaticOrKinematicObject
bool isStaticOrKinematicObject() const
Definition: btCollisionObject.h:205
btRigidBody::m_additionalLinearDampingThresholdSqr
btScalar m_additionalLinearDampingThresholdSqr
Definition: btRigidBody.h:78
btRigidBody::m_optionalMotionState
btMotionState * m_optionalMotionState
Definition: btRigidBody.h:86
btCollisionObject::m_internalType
int m_internalType
m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody,...
Definition: btCollisionObject.h:94
btRigidBody::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btRigidBody.cpp:451
btRigidBody::clearGravity
void clearGravity()
Definition: btRigidBody.cpp:209
btCollisionObject::setIgnoreCollisionCheck
void setIgnoreCollisionCheck(const btCollisionObject *co, bool ignoreCollisionCheck)
Definition: btCollisionObject.h:236
btCollisionObject::getWorldTransform
btTransform & getWorldTransform()
Definition: btCollisionObject.h:367
btCollisionObject::CO_RIGID_BODY
@ CO_RIGID_BODY
Definition: btCollisionObject.h:146
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition: btCollisionShape.h:28
btRigidBody::setupRigidBody
void setupRigidBody(const btRigidBodyConstructionInfo &constructionInfo)
setupRigidBody is only used internally by the constructor
Definition: btRigidBody.cpp:40
btRigidBody::m_angularFactor
btVector3 m_angularFactor
Definition: btRigidBody.h:98
btRigidBody::getCollisionShape
const btCollisionShape * getCollisionShape() const
Definition: btRigidBody.h:242
btRigidBody::btRigidBodyConstructionInfo::m_restitution
btScalar m_restitution
best simulation results using zero restitution.
Definition: btRigidBody.h:131
btRigidBody::applyCentralForce
void applyCentralForce(const btVector3 &force)
Definition: btRigidBody.h:274
btCollisionObject::setCollisionShape
virtual void setCollisionShape(btCollisionShape *collisionShape)
Definition: btCollisionObject.h:219
btRigidBody::proceedToTransform
void proceedToTransform(const btTransform &newTrans)
Definition: btRigidBody.cpp:217
btTypedConstraint.h
btMinMax.h
btRigidBodyData
#define btRigidBodyData
Definition: btRigidBody.h:35
btRigidBody::btRigidBodyConstructionInfo::m_friction
btScalar m_friction
best simulation results when friction is non-zero
Definition: btRigidBody.h:124
btRigidBody::btRigidBody
btRigidBody(const btRigidBodyConstructionInfo &constructionInfo)
btRigidBody constructor using construction info
Definition: btRigidBody.cpp:29
btRigidBody::m_linearFactor
btVector3 m_linearFactor
Definition: btRigidBody.h:65
btTransform::getBasis
btMatrix3x3 & getBasis()
Return the basis matrix for the rotation.
Definition: btTransform.h:108
btRigidBody::m_pushVelocity
btVector3 m_pushVelocity
Definition: btRigidBody.h:100
btCollisionShape::getAabb
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t.
btMatrix3x3
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
Definition: btMatrix3x3.h:48
btRigidBody::m_angularVelocity
btVector3 m_angularVelocity
Definition: btRigidBody.h:63
btMatrix3x3::transpose
btMatrix3x3 transpose() const
Return the transpose of the matrix.
Definition: btMatrix3x3.h:1033
btSerializer.h
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
btMotionState
The btMotionState interface class allows the dynamics world to synchronize and interpolate the update...
Definition: btMotionState.h:24
btRigidBody::btRigidBodyConstructionInfo::m_additionalDamping
bool m_additionalDamping
Definition: btRigidBody.h:138
btRigidBody::btRigidBodyConstructionInfo::m_localInertia
btVector3 m_localInertia
Definition: btRigidBody.h:119
btRigidBody::m_invInertiaLocal
btVector3 m_invInertiaLocal
Definition: btRigidBody.h:69
btSerializer::finalizeChunk
virtual void finalizeChunk(btChunk *chunk, const char *structType, int chunkCode, void *oldPtr)=0
btRigidBody::saveKinematicState
void saveKinematicState(btScalar step)
Definition: btRigidBody.cpp:105
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
btRigidBody::m_deltaLinearVelocity
btVector3 m_deltaLinearVelocity
Definition: btRigidBody.h:96
btRigidBody::m_linearSleepingThreshold
btScalar m_linearSleepingThreshold
Definition: btRigidBody.h:82
btCollisionObject::m_rollingFriction
btScalar m_rollingFriction
Definition: btCollisionObject.h:87
btRigidBody::getLinearVelocity
const btVector3 & getLinearVelocity() const
Definition: btRigidBody.h:398
btChunk::m_oldPtr
void * m_oldPtr
Definition: btSerializer.h:52
btCollisionObject::CF_STATIC_OBJECT
@ CF_STATIC_OBJECT
Definition: btCollisionObject.h:130
evalEulerEqnDeriv
btMatrix3x3 evalEulerEqnDeriv(const btVector3 &w1, const btVector3 &w0, const btScalar dt, const btMatrix3x3 &I)
Definition: btRigidBody.cpp:267
btRigidBody::applyDamping
void applyDamping(btScalar timeStep)
applyDamping damps the velocity, using the given m_linearDamping and m_angularDamping
Definition: btRigidBody.cpp:144
btRigidBody::addConstraintRef
void addConstraintRef(btTypedConstraint *c)
Definition: btRigidBody.cpp:408
btCollisionObject::m_collisionFlags
int m_collisionFlags
Definition: btCollisionObject.h:76
btCollisionObject::m_interpolationAngularVelocity
btVector3 m_interpolationAngularVelocity
Definition: btCollisionObject.h:60
btRigidBody::m_additionalAngularDampingThresholdSqr
btScalar m_additionalAngularDampingThresholdSqr
Definition: btRigidBody.h:79
btRigidBody::m_debugBodyId
int m_debugBodyId
Definition: btRigidBody.h:93
btMatrix3x3::setValue
void setValue(const btScalar &xx, const btScalar &xy, const btScalar &xz, const btScalar &yx, const btScalar &yy, const btScalar &yz, const btScalar &zx, const btScalar &zy, const btScalar &zz)
Set the values of the matrix explicitly (row major)
Definition: btMatrix3x3.h:202
btSerializer
Definition: btSerializer.h:66
btRigidBodyDataName
#define btRigidBodyDataName
Definition: btRigidBody.h:36
btRigidBody::setMassProps
void setMassProps(btScalar mass, const btVector3 &inertia)
Definition: btRigidBody.cpp:222
btVector3::x
const btScalar & x() const
Return the x value.
Definition: btVector3.h:575
btClamped
const T & btClamped(const T &a, const T &lb, const T &ub)
Definition: btMinMax.h:33
btRigidBody::btRigidBodyConstructionInfo::m_additionalDampingFactor
btScalar m_additionalDampingFactor
Definition: btRigidBody.h:139
btRigidBody::btRigidBodyConstructionInfo::m_collisionShape
btCollisionShape * m_collisionShape
Definition: btRigidBody.h:118
btRigidBody::m_constraintRefs
btAlignedObjectArray< btTypedConstraint * > m_constraintRefs
Definition: btRigidBody.h:89
btCollisionObject::m_restitution
btScalar m_restitution
Definition: btCollisionObject.h:86
btRigidBody::m_additionalDampingFactor
btScalar m_additionalDampingFactor
Definition: btRigidBody.h:77
btRigidBody::m_frictionSolverType
int m_frictionSolverType
Definition: btRigidBody.h:519
btRigidBody::m_linearDamping
btScalar m_linearDamping
Definition: btRigidBody.h:73
btRigidBody::m_linearVelocity
btVector3 m_linearVelocity
Definition: btRigidBody.h:62
btMatrix3x3::getRotation
void getRotation(btQuaternion &q) const
Get the matrix represented as a quaternion.
Definition: btMatrix3x3.h:404
btRigidBody::btRigidBodyConstructionInfo::m_motionState
btMotionState * m_motionState
When a motionState is provided, the rigid body will initialize its world transform from the motion st...
Definition: btRigidBody.h:115
btMatrix3x3::scaled
btMatrix3x3 scaled(const btVector3 &s) const
Create a scaled copy of the matrix.
Definition: btMatrix3x3.h:606
btRigidBody::m_gravity_acceleration
btVector3 m_gravity_acceleration
Definition: btRigidBody.h:68
btRigidBody::setCenterOfMassTransform
void setCenterOfMassTransform(const btTransform &xform)
Definition: btRigidBody.cpp:392
btRigidBody::btRigidBodyConstructionInfo::m_additionalAngularDampingFactor
btScalar m_additionalAngularDampingFactor
Definition: btRigidBody.h:142
btRigidBody::btRigidBodyConstructionInfo::m_rollingFriction
btScalar m_rollingFriction
the m_rollingFriction prevents rounded shapes, such as spheres, cylinders and capsules from rolling f...
Definition: btRigidBody.h:127
btRigidBody::m_deltaAngularVelocity
btVector3 m_deltaAngularVelocity
Definition: btRigidBody.h:97
btRigidBody::btRigidBodyConstructionInfo
The btRigidBodyConstructionInfo structure provides information to create a rigid body.
Definition: btRigidBody.h:110
btRigidBody::m_additionalAngularDampingFactor
btScalar m_additionalAngularDampingFactor
Definition: btRigidBody.h:80
BT_RIGIDBODY_CODE
#define BT_RIGIDBODY_CODE
Definition: btSerializer.h:112
btAlignedObjectArray::push_back
void push_back(const T &_Val)
Definition: btAlignedObjectArray.h:257
MAX_ANGVEL
#define MAX_ANGVEL
btMatrix3x3::serialize
void serialize(struct btMatrix3x3Data &dataOut) const
Definition: btMatrix3x3.h:1385
btVector3::getSkewSymmetricMatrix
void getSkewSymmetricMatrix(btVector3 *v0, btVector3 *v1, btVector3 *v2) const
Definition: btVector3.h:648
btAlignedObjectArray::remove
void remove(const T &key)
Definition: btAlignedObjectArray.h:480
btSqrt
btScalar btSqrt(btScalar y)
Definition: btScalar.h:466
btPow
btScalar btPow(btScalar x, btScalar y)
Definition: btScalar.h:521
btCollisionObject::m_interpolationLinearVelocity
btVector3 m_interpolationLinearVelocity
Definition: btCollisionObject.h:59
uniqueId
static int uniqueId
Definition: btRigidBody.cpp:27
btVector3::normalized
btVector3 normalized() const
Return a normalized version of this vector.
Definition: btVector3.h:949
btTransformUtil::calculateVelocity
static void calculateVelocity(const btTransform &transform0, const btTransform &transform1, btScalar timeStep, btVector3 &linVel, btVector3 &angVel)
Definition: btTransformUtil.h:115
btRigidBody::removeConstraintRef
void removeConstraintRef(btTypedConstraint *c)
Definition: btRigidBody.cpp:431
btSerializer::allocate
virtual btChunk * allocate(size_t size, int numElements)=0
btRigidBody::btRigidBodyConstructionInfo::m_linearSleepingThreshold
btScalar m_linearSleepingThreshold
Definition: btRigidBody.h:133
btVector3::z
const btScalar & z() const
Return the z value.
Definition: btVector3.h:579
btCollisionObject::m_friction
btScalar m_friction
Definition: btCollisionObject.h:85
btRigidBody::getMotionState
btMotionState * getMotionState()
Definition: btRigidBody.h:502
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:142
btRigidBody::m_totalForce
btVector3 m_totalForce
Definition: btRigidBody.h:70
btTransformUtil::integrateTransform
static void integrateTransform(const btTransform &curTrans, const btVector3 &linvel, const btVector3 &angvel, btScalar timeStep, btTransform &predictedTransform)
Definition: btTransformUtil.h:32
btVector3::length2
btScalar length2() const
Return the length of the vector squared.
Definition: btVector3.h:251
quatRotate
btVector3 quatRotate(const btQuaternion &rotation, const btVector3 &v)
Definition: btQuaternion.h:926
btRigidBody::computeGyroscopicImpulseImplicit_Body
btVector3 computeGyroscopicImpulseImplicit_Body(btScalar step) const
perform implicit force computation in body space (inertial frame)
Definition: btRigidBody.cpp:293
btRigidBody::m_invMass
btVector3 m_invMass
Definition: btRigidBody.h:99
btRigidBody::getLocalInertia
btVector3 getLocalInertia() const
Definition: btRigidBody.cpp:250