My Project: dynamics.mod/NewtonDynamics/source/physics/dgBody.h Source File

My Project

dgBody.h
Go to the documentation of this file.
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21
22 #ifndef _DG_BODY_H_
23 #define _DG_BODY_H_
24
25 #include "dgPhysicsStdafx.h"
26 #include "dgBroadPhase.h"
27 #include "dgBodyMasterList.h"
28
29 class dgLink;
30 class dgBody;
31 class dgWorld;
32 class dgCollision;
33 class dgBroadPhaseNode;
34 class dgCollisionInstance;
35
36
37 #define DG_MINIMUM_MASS dgFloat32(1.0e-3f)
38 #define DG_INFINITE_MASS dgFloat32(1.0e15f)
39
40 #define OverlapTest(body0,body1) dgOverlapTest ((body0)->m_minAABB, (body0)->m_maxAABB, (body1)->m_minAABB, (body1)->m_maxAABB)
41
42 //DG_MSC_VECTOR_ALIGMENT
43 DG_MSC_VECTOR_ALIGMENT
44 class dgBody
45 {
46 public:
47 typedef void (dgApi *OnBodyDestroy) (dgBody& me);
48 typedef void (dgApi *OnApplyExtForceAndTorque) (dgBody& me, dgFloat32 timestep, dgInt32 threadIndex);
49 typedef void (dgApi *OnMatrixUpdateCallback) (const dgBody& me, const dgMatrix& matrix, dgInt32 threadIndex);
50
51 enum dgRTTI
52 {
53 m_baseBodyRTTI = 1<<0,
54 m_dynamicBodyRTTI = 1<<1,
55 m_kinematicBodyRTTI = 1<<2,
56 m_deformableBodyRTTI = 1<<3,
57 };
58
59 enum dgType
60 {
61 m_dynamicBody = 0,
62 m_kinematicBody,
63 m_deformableBody,
64 };
65
66
67 DG_CLASS_ALLOCATOR(allocator)
68
69
70 dgBody();
71 dgBody (dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionNode, dgDeserialize serializeCallback, void* const userData);
72 virtual ~dgBody();
73
74 dgType GetType () const;
75 dgInt32 IsRTTIType (dgUnsigned32 rtti) const;
76
77 void* GetUserData() const;
78 void SetUserData (void* const userData);
79 dgWorld* GetWorld() const;
80
81
82 const dgMatrix& GetMatrix() const;
83 const dgQuaternion& GetRotation() const;
84 const dgVector& GetPosition() const;
85
86
87 void SetCentreOfMass (const dgVector& com);
88 const dgVector& GetCentreOfMass () const;
89
90 void GetAABB (dgVector &p0, dgVector &p1) const;
91
92 const dgVector& GetOmega() const;
93 const dgVector& GetVelocity() const;
94 const dgVector& GetNetForce() const;
95 const dgVector& GetNetTorque() const;
96
97 dgVector GetVelocityAtPoint (const dgVector& point) const;
98
99 void SetOmega (const dgVector& omega);
100 void SetVelocity (const dgVector& velocity);
101
102 dgUnsigned32 GetGroupID () const;
103 virtual void SetGroupID (dgUnsigned32 id);
104 dgInt32 GetUniqueID () const;
105
106 bool GetContinueCollisionMode () const;
107 void SetContinueCollisionMode (bool mode);
108 bool GetCollisionWithLinkedBodies () const;
109 void SetCollisionWithLinkedBodies (bool state);
110
111 void Freeze ();
112 void Unfreeze ();
113 bool GetFreeze () const;
114 void SetFreeze (bool state);
115
116 bool GetSleepState () const;
117 void SetSleepState (bool state);
118
119 bool GetAutoSleep () const;
120 void SetAutoSleep (bool state);
121
122 dgCollisionInstance* GetCollision () const;
123 dgBodyMasterList::dgListNode* GetMasterList() const;
124
125 OnBodyDestroy GetDestructorCallback () const;
126 void SetDestructorCallback (OnBodyDestroy destructor);
127 OnMatrixUpdateCallback GetMatrixUpdateCallback () const;
128 void SetMatrixUpdateCallback (OnMatrixUpdateCallback callback);
129
130 dgVector GetMass() const;
131 dgVector GetInvMass() const;
132 const dgMatrix& GetInertiaMatrix () const;
133
134 virtual dgMatrix CalculateInertiaMatrix () const;
135 virtual dgMatrix CalculateInvInertiaMatrix () const;
136
137 bool IsCollidable() const;
138 virtual void SetCollidable (bool state) = 0;
139 virtual bool IsInEquilibrium () const = 0;
140
141 virtual const dgVector& GetForce() const = 0;
142 virtual const dgVector& GetTorque() const = 0;
143 virtual void AddForce (const dgVector& force) = 0;
144 virtual void AddTorque (const dgVector& torque) = 0;
145 virtual void SetForce (const dgVector& force) = 0;
146 virtual void SetTorque (const dgVector& torque) = 0;
147
148 virtual dgFloat32 GetLinearDamping () const = 0;
149 virtual dgVector GetAngularDamping () const = 0;
150 virtual void SetLinearDamping (dgFloat32 linearDamp) = 0;
151 virtual void SetAngularDamping (const dgVector& angularDamp) = 0;
152 virtual void AddDampingAcceleration() = 0;
153
154 virtual void SetMassMatrix (dgFloat32 mass, dgFloat32 Ix, dgFloat32 Iy, dgFloat32 Iz);
155 virtual void SetMassProperties (dgFloat32 mass, const dgCollisionInstance* const collision);
156
157 virtual dgVector PredictLinearVelocity(dgFloat32 timestep) const = 0;
158 virtual dgVector PredictAngularVelocity(dgFloat32 timestep) const = 0;
159
160
161 virtual void AddImpulse (const dgVector& pointVeloc, const dgVector& pointPosit);
162 virtual void ApplyImpulsePair (const dgVector& linearImpulse, const dgVector& angularImpulse);
163 virtual void ApplyImpulsesAtPoint (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const impulseArray, const dgFloat32* const pointArray);
164
165 virtual void InvalidateCache();
166
167 virtual void SetMatrix(const dgMatrix& matrix);
168 virtual void SetMatrixIgnoreSleep(const dgMatrix& matrix);
169 virtual void IntegrateVelocity (dgFloat32 timestep);
170 virtual void AttachCollision (dgCollisionInstance* const collision);
171
172 virtual void ApplyExtenalForces (dgFloat32 timestep, dgInt32 threadIndex) = 0;
173 virtual OnApplyExtForceAndTorque GetExtForceAndTorqueCallback () const = 0;
174 virtual void SetExtForceAndTorqueCallback (OnApplyExtForceAndTorque callback) = 0;
175
176 virtual dgFloat32 RayCast (const dgLineBox& line, OnRayCastAction filter, OnRayPrecastAction preFilter, void* const userData, dgFloat32 minT) const;
177 virtual dgFloat32 ConvexRayCast (const dgFastRayTest& ray, const dgCollisionInstance* const convexShape, const dgVector& shapeMinBox, const dgVector& shapeMaxBox, const dgMatrix& origin, const dgVector& shapeVeloc, OnRayCastAction filter, OnRayPrecastAction preFilter, void* const userData, dgFloat32 minT, dgInt32 threadId) const;
178
179
180 virtual void Serialize (const dgTree<dgInt32, const dgCollision*>* const collisionNode, dgSerialize serializeCallback, void* const userData);
181
182 virtual dgConstraint* GetFirstJoint() const;
183 virtual dgConstraint* GetNextJoint(dgConstraint* const joint) const;
184 virtual dgConstraint* GetFirstContact() const;
185 virtual dgConstraint* GetNextContact(dgConstraint* const joint) const;
186 virtual dgVector CalculateInverseDynamicForce (const dgVector& desiredVeloc, dgFloat32 timestep) const;
187
188 void SetMatrixOriginAndRotation(const dgMatrix& matrix);
189
190 protected:
191 void UpdateWorlCollisionMatrix() const;
192 void UpdateMatrix (dgFloat32 timestep, dgInt32 threadIndex);
193 void UpdateCollisionMatrix (dgFloat32 timestep, dgInt32 threadIndex);
194
195
196 // member variables:
197 protected:
198 void CalcInvInertiaMatrix ();
199 dgVector GetApparentMass() const;
200 void SetAparentMassMatrix (const dgVector& massMatrix);
201
202
203 dgMatrix m_invWorldInertiaMatrix;
204 dgMatrix m_matrix;
205 dgQuaternion m_rotation;
206 dgVector m_mass;
207 dgVector m_invMass;
208 dgVector m_veloc;
209 dgVector m_omega;
210 dgVector m_minAABB;
211 dgVector m_maxAABB;
212 dgVector m_netForce;
213 dgVector m_netTorque;
214 dgVector m_localCentreOfMass;
215 dgVector m_globalCentreOfMass;
216 dgVector m_aparentMass;
217 dgInt32 m_index;
218 dgInt32 m_uniqueID;
219 dgInt32 m_bodyGroupId;
220 dgInt32 m_rtti;
221 dgInt32 m_type;
222 dgUnsigned32 m_dynamicsLru;
223 dgUnsigned32 m_genericLRUMark;
224
225 dgThread::dgCriticalSection m_criticalSectionLock;
226 union
227 {
228 dgUnsigned32 m_flags;
229 struct {
230 dgUnsigned32 m_freeze : 1;
231 dgUnsigned32 m_sleeping : 1;
232 dgUnsigned32 m_autoSleep : 1;
233 dgUnsigned32 m_equilibrium : 1;
234 dgUnsigned32 m_continueCollisionMode : 1;
235 dgUnsigned32 m_spawnnedFromCallback : 1;
236 dgUnsigned32 m_collideWithLinkedBodies : 1;
237 dgUnsigned32 m_inCallback : 1;
238 dgUnsigned32 m_collidable : 1;
239 dgUnsigned32 m_resting : 1;
240 dgUnsigned32 m_active : 1;
241 };
242 };
243
244 void* m_userData;
245 dgWorld* m_world;
246 dgCollisionInstance* m_collision;
247 dgBroadPhase::dgNode* m_collisionCell;
248 dgBodyMasterList::dgListNode* m_masterNode;
249
250 OnBodyDestroy m_destructor;
251 OnMatrixUpdateCallback m_matrixUpdate;
252
253 friend class dgWorld;
254 friend class dgContact;
255 friend class dgConstraint;
256 friend class dgBroadPhase;
257 friend class dgAmpInstance;
258 friend class dgCollisionBVH;
259 friend class dgBroadPhaseNode;
260 friend class dgBodyMasterList;
261 friend class dgCollisionScene;
262 friend class dgCollisionConvex;
263 friend class dgCollisionCompound;
264 friend class dgCollisionUserMesh;
265 friend class dgWorldDynamicUpdate;
266 friend class dgBilateralConstraint;
267 friend class dgCollisionConvexPolygon;
268 friend class dgCollidingPairCollector;
269
270 } DG_GCC_VECTOR_ALIGMENT;
271
272 // *****************************************************************************
273 //
274 // Implementation
275 //
276 // *****************************************************************************
277 DG_INLINE const dgMatrix& dgBody::GetInertiaMatrix () const
278 {
279 return m_invWorldInertiaMatrix;
280 }
281
282
283
284 DG_INLINE dgVector dgBody::GetInvMass() const
285 {
286 return m_invMass;
287 }
288
289 DG_INLINE dgVector dgBody::GetMass() const
290 {
291 return m_mass;
292 }
293
294
295 DG_INLINE dgBody::dgType dgBody::GetType () const
296 {
297 return dgType (m_type);
298 }
299
300 DG_INLINE dgInt32 dgBody::IsRTTIType (dgUnsigned32 rtti) const
301 {
302 return rtti & m_rtti;
303 }
304
305 DG_INLINE void dgBody::SetUserData(void* const userData)
306 {
307 m_userData = userData;
308 }
309
310 DG_INLINE void* dgBody::GetUserData() const
311 {
312 return m_userData;
313 }
314
315 DG_INLINE dgWorld* dgBody::GetWorld() const
316 {
317 return m_world;
318 }
319
320
321 DG_INLINE dgUnsigned32 dgBody::GetGroupID () const
322 {
323 return dgUnsigned32 (m_bodyGroupId);
324 }
325
326 DG_INLINE void dgBody::SetGroupID (dgUnsigned32 id)
327 {
328 m_bodyGroupId = dgInt32 (id);
329 }
330
331
332
333 DG_INLINE dgBodyMasterList::dgListNode* dgBody::GetMasterList() const
334 {
335 return m_masterNode;
336 }
337
338 DG_INLINE void dgBody::GetAABB (dgVector &p0, dgVector &p1) const
339 {
340 p0.m_x = m_minAABB.m_x;
341 p0.m_y = m_minAABB.m_y;
342 p0.m_z = m_minAABB.m_z;
343 p1.m_x = m_maxAABB.m_x;
344 p1.m_y = m_maxAABB.m_y;
345 p1.m_z = m_maxAABB.m_z;
346 }
347
348 DG_INLINE const dgVector& dgBody::GetOmega() const
349 {
350 return m_omega;
351 }
352
353 DG_INLINE const dgVector& dgBody::GetVelocity() const
354 {
355 return m_veloc;
356 }
357
358 DG_INLINE void dgBody::SetOmega (const dgVector& omega)
359 {
360 m_omega = omega;
361 m_equilibrium = false;
362 }
363
364 DG_INLINE dgVector dgBody::GetVelocityAtPoint (const dgVector& point) const
365 {
366 return m_veloc + m_omega * (point - m_globalCentreOfMass);
367 }
368
369 DG_INLINE void dgBody::SetVelocity (const dgVector& velocity)
370 {
371 m_veloc = velocity;
372 m_equilibrium = false;
373 }
374
375 DG_INLINE const dgMatrix& dgBody::GetMatrix() const
376 {
377 return m_matrix;
378 }
379
380 DG_INLINE const dgVector& dgBody::GetPosition() const
381 {
382 return m_matrix.m_posit;
383 }
384
385 DG_INLINE const dgQuaternion& dgBody::GetRotation() const
386 {
387 return m_rotation;
388 }
389
390 DG_INLINE const dgVector& dgBody::GetCentreOfMass () const
391 {
392 return m_localCentreOfMass;
393 }
394
395 DG_INLINE void dgBody::SetCentreOfMass (const dgVector& com)
396 {
397 m_localCentreOfMass.m_x = com.m_x;
398 m_localCentreOfMass.m_y = com.m_y;
399 m_localCentreOfMass.m_z = com.m_z;
400 m_localCentreOfMass.m_w = dgFloat32 (1.0f);
401 m_globalCentreOfMass = m_matrix.TransformVector (m_localCentreOfMass);
402 }
403
404
405 DG_INLINE dgInt32 dgBody::GetUniqueID () const
406 {
407 return m_uniqueID;
408 }
409
410
411 DG_INLINE void dgBody::SetDestructorCallback (OnBodyDestroy destructor)
412 {
413 m_destructor = destructor;
414 }
415
416 DG_INLINE dgBody::OnBodyDestroy dgBody::GetDestructorCallback () const
417 {
418 return m_destructor;
419 }
420
421
422 DG_INLINE void dgBody::SetMatrixUpdateCallback (OnMatrixUpdateCallback callback)
423 {
424 m_matrixUpdate = callback;
425 }
426
427 DG_INLINE dgBody::OnMatrixUpdateCallback dgBody::GetMatrixUpdateCallback () const
428 {
429 return m_matrixUpdate;
430 }
431
432
433
434 DG_INLINE dgCollisionInstance* dgBody::GetCollision () const
435 {
436 return m_collision;
437 }
438
439 DG_INLINE void dgBody::SetContinueCollisionMode (bool mode)
440 {
441 m_continueCollisionMode = dgUnsigned32 (mode);
442 }
443
444 DG_INLINE bool dgBody::GetContinueCollisionMode () const
445 {
446 return m_continueCollisionMode;
447 }
448
449 DG_INLINE void dgBody::SetCollisionWithLinkedBodies (bool state)
450 {
451 m_collideWithLinkedBodies = dgUnsigned32 (state);
452 }
453
454 DG_INLINE bool dgBody::GetCollisionWithLinkedBodies () const
455 {
456 return m_collideWithLinkedBodies;
457 }
458
459 DG_INLINE bool dgBody::GetFreeze () const
460 {
461 return m_freeze;
462 }
463
464 DG_INLINE void dgBody::SetAutoSleep (bool state)
465 {
466 m_autoSleep = dgUnsigned32 (state);
467 if (m_autoSleep == 0) {
468 m_sleeping = false;
469 }
470 }
471
472 DG_INLINE bool dgBody::GetAutoSleep () const
473 {
474 return m_autoSleep;
475 }
476
477 DG_INLINE bool dgBody::GetSleepState () const
478 {
479 return m_sleeping;
480 }
481
482 DG_INLINE void dgBody::SetSleepState (bool state)
483 {
484 m_sleeping = state;
485 m_equilibrium = state;
486 }
487
488
489 DG_INLINE bool dgBody::IsCollidable() const
490 {
491 return m_collidable;
492 }
493
494 DG_INLINE dgVector dgBody::GetApparentMass() const
495 {
496 return m_aparentMass;
497 }
498
499
500 DG_INLINE void dgBody::SetMatrixOriginAndRotation(const dgMatrix& matrix)
501 {
502 m_matrix = matrix;
503
504 #ifdef _DEBUG
505 for (int i = 0; i < 4; i ++) {
506 for (int j = 0; j < 4; j ++) {
507 dgAssert (dgCheckFloat(m_matrix[i][j]));
508 }
509 }
510
511 int j0 = 1;
512 int j1 = 2;
513 for (dgInt32 i = 0; i < 3; i ++) {
514 dgAssert (m_matrix[i][3] == 0.0f);
515 dgFloat32 val = m_matrix[i] % m_matrix[i];
516 dgAssert (dgAbsf (val - 1.0f) < 1.0e-4f);
517 dgVector tmp (m_matrix[j0] * m_matrix[j1]);
518 val = tmp % m_matrix[i];
519 dgAssert (dgAbsf (val - 1.0f) < 1.0e-4f);
520 j0 = j1;
521 j1 = i;
522 }
523 #endif
524
525 m_rotation = dgQuaternion (m_matrix);
526 m_globalCentreOfMass = m_matrix.TransformVector (m_localCentreOfMass);
527 }
528
529
530 DG_INLINE const dgVector& dgBody::GetNetForce() const
531 {
532 return m_netForce;
533 }
534
535 DG_INLINE const dgVector& dgBody::GetNetTorque() const
536 {
537 return m_netTorque;
538 }
539
540
541 DG_INLINE void dgBody::CalcInvInertiaMatrix ()
542 {
543 dgAssert (m_invWorldInertiaMatrix[0][3] == dgFloat32 (0.0f));
544 dgAssert (m_invWorldInertiaMatrix[1][3] == dgFloat32 (0.0f));
545 dgAssert (m_invWorldInertiaMatrix[2][3] == dgFloat32 (0.0f));
546 dgAssert (m_invWorldInertiaMatrix[3][3] == dgFloat32 (1.0f));
547
548 m_invWorldInertiaMatrix = CalculateInvInertiaMatrix ();
549
550 dgAssert (m_invWorldInertiaMatrix[0][3] == dgFloat32 (0.0f));
551 dgAssert (m_invWorldInertiaMatrix[1][3] == dgFloat32 (0.0f));
552 dgAssert (m_invWorldInertiaMatrix[2][3] == dgFloat32 (0.0f));
553 dgAssert (m_invWorldInertiaMatrix[3][3] == dgFloat32 (1.0f));
554 }
555
556
557 #endif
558
dgBody::dgRTTI
dgRTTI
Definition: dgBody.h:51
dgList< dgBodyMasterListRow >::dgListNode
friend class dgListNode
Definition: dgList.h:249
dgBody::m_userData
void * m_userData
Definition: dgBody.h:244
dgBody::GetFirstJoint
virtual dgConstraint * GetFirstJoint() const
Definition: dgBody.cpp:338
dgBody::GetFirstContact
virtual dgConstraint * GetFirstContact() const
Definition: dgBody.cpp:371
dgApi
#define dgApi
Definition: dgTypes.h:263
dgBody::CalcInvInertiaMatrix
void CalcInvInertiaMatrix()
Definition: dgBody.h:541
dgBody::m_maxAABB
dgVector m_maxAABB
Definition: dgBody.h:211
dgContact
Definition: dgContact.h:195
dgLineBox
Definition: dgBroadPhase.h:43
dgBody::m_deformableBody
Definition: dgBody.h:63
dgBody::dgBroadPhaseNode
friend class dgBroadPhaseNode
Definition: dgBody.h:259
dgBody::GetUserData
void * GetUserData() const
Definition: dgBody.h:310
dgAmpInstance
Definition: dgAmpInstance.h:143
OnRayCastAction
dgFloat32(dgApi * OnRayCastAction)(const dgBody *const body, const dgCollisionInstance *const collision, const dgVector &contact, const dgVector &normal, dgInt64 collisionID, void *const userData, dgFloat32 intersetParam)
Definition: dgBroadPhase.h:37
dgBody::m_aparentMass
dgVector m_aparentMass
Definition: dgBody.h:216
dgCollidingPairCollector
Definition: dgContact.h:49
dgBodyMasterList
Definition: dgBodyMasterList.h:57
dgBody::m_genericLRUMark
dgUnsigned32 m_genericLRUMark
Definition: dgBody.h:223
dgBody::m_dynamicsLru
dgUnsigned32 m_dynamicsLru
Definition: dgBody.h:222
dgBody::AddForce
virtual void AddForce(const dgVector &force)=0
dgAbsf
DG_INLINE dgFloat32 dgAbsf(dgFloat32 x)
Definition: dgTypes.h:627
dgBody::GetOmega
const dgVector & GetOmega() const
Definition: dgBody.h:348
dgBody::GetLinearDamping
virtual dgFloat32 GetLinearDamping() const =0
dgCollisionBVH
Definition: dgCollisionBVH.h:32
dgBody::SetTorque
virtual void SetTorque(const dgVector &torque)=0
dgBody::GetCollisionWithLinkedBodies
bool GetCollisionWithLinkedBodies() const
Definition: dgBody.h:454
dgBody::m_masterNode
dgBodyMasterList::dgListNode * m_masterNode
Definition: dgBody.h:248
dgFastRayTest
Definition: dgIntersections.h:52
dgBody::SetAutoSleep
void SetAutoSleep(bool state)
Definition: dgBody.h:464
dgBody::GetMass
dgVector GetMass() const
Definition: dgBody.h:289
dgBody::m_active
dgUnsigned32 m_active
Definition: dgBody.h:240
dgBody
Definition: dgBody.h:44
dgBody::GetInvMass
dgVector GetInvMass() const
Definition: dgBody.h:284
dgBody::SetAparentMassMatrix
void SetAparentMassMatrix(const dgVector &massMatrix)
Definition: dgBody.cpp:448
dgBody::AddTorque
virtual void AddTorque(const dgVector &torque)=0
dgBody::m_collision
dgCollisionInstance * m_collision
Definition: dgBody.h:246
userData
void *const userData
Definition: dgBroadPhase.h:35
DG_INLINE
#define DG_INLINE
Definition: dgTypes.h:178
dgAssert
#define dgAssert(x)
Definition: dgTypes.h:158
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
dgBody::SetVelocity
void SetVelocity(const dgVector &velocity)
Definition: dgBody.h:369
dgBody::GetFreeze
bool GetFreeze() const
Definition: dgBody.h:459
dgBody::GetRotation
const dgQuaternion & GetRotation() const
Definition: dgBody.h:385
dgMatrix::TransformVector
dgVector TransformVector(const dgVector &v) const
Definition: dgMatrix.h:222
void
typedef void(dgApi *ConstraintsForceFeeback)(const dgConstraint &me
dgBody::SetMatrixOriginAndRotation
void SetMatrixOriginAndRotation(const dgMatrix &matrix)
Definition: dgBody.h:500
dgBody::SetMassMatrix
virtual void SetMassMatrix(dgFloat32 mass, dgFloat32 Ix, dgFloat32 Iy, dgFloat32 Iz)
Definition: dgBody.cpp:464
dgBody::AttachCollision
virtual void AttachCollision(dgCollisionInstance *const collision)
Definition: dgBody.cpp:146
dgVector
Definition: dgVector.h:639
dgThread
Definition: dgThread.h:32
dgBroadPhase.h
dgBody::m_omega
dgVector m_omega
Definition: dgBody.h:209
dgBody::GetExtForceAndTorqueCallback
virtual OnApplyExtForceAndTorque GetExtForceAndTorqueCallback() const =0
dgBody::m_minAABB
dgVector m_minAABB
Definition: dgBody.h:210
dgBody::m_spawnnedFromCallback
dgUnsigned32 m_spawnnedFromCallback
Definition: dgBody.h:235
dgBody::SetMassProperties
virtual void SetMassProperties(dgFloat32 mass, const dgCollisionInstance *const collision)
Definition: dgBody.cpp:542
dgBody::m_bodyGroupId
dgInt32 m_bodyGroupId
Definition: dgBody.h:219
dgBody::GetGroupID
dgUnsigned32 GetGroupID() const
Definition: dgBody.h:321
dgBody::m_criticalSectionLock
dgThread::dgCriticalSection m_criticalSectionLock
Definition: dgBody.h:225
dgVector::m_z
dgFloat32 m_z
Definition: dgVector.h:1027
dgBody::GetVelocity
const dgVector & GetVelocity() const
Definition: dgBody.h:353
dgBody::m_mass
dgVector m_mass
Definition: dgBody.h:206
dgBody::ConvexRayCast
virtual dgFloat32 ConvexRayCast(const dgFastRayTest &ray, const dgCollisionInstance *const convexShape, const dgVector &shapeMinBox, const dgVector &shapeMaxBox, const dgMatrix &origin, const dgVector &shapeVeloc, OnRayCastAction filter, OnRayPrecastAction preFilter, void *const userData, dgFloat32 minT, dgInt32 threadId) const
Definition: dgBody.cpp:251
dgBody::SetCollisionWithLinkedBodies
void SetCollisionWithLinkedBodies(bool state)
Definition: dgBody.h:449
dgBody::m_globalCentreOfMass
dgVector m_globalCentreOfMass
Definition: dgBody.h:215
dgBody::m_world
dgWorld * m_world
Definition: dgBody.h:245
dgBody::SetMatrixUpdateCallback
void SetMatrixUpdateCallback(OnMatrixUpdateCallback callback)
Definition: dgBody.h:422
dgBody::m_kinematicBodyRTTI
Definition: dgBody.h:55
dgBody::m_matrixUpdate
OnMatrixUpdateCallback m_matrixUpdate
Definition: dgBody.h:251
DG_CLASS_ALLOCATOR
#define DG_CLASS_ALLOCATOR(allocator)
Definition: dgMemory.h:60
dgBody::SetExtForceAndTorqueCallback
virtual void SetExtForceAndTorqueCallback(OnApplyExtForceAndTorque callback)=0
dgBody::GetNextJoint
virtual dgConstraint * GetNextJoint(dgConstraint *const joint) const
Definition: dgBody.cpp:351
dgBody::SetDestructorCallback
void SetDestructorCallback(OnBodyDestroy destructor)
Definition: dgBody.h:411
dgBody::m_continueCollisionMode
dgUnsigned32 m_continueCollisionMode
Definition: dgBody.h:234
dgBody::SetAngularDamping
virtual void SetAngularDamping(const dgVector &angularDamp)=0
dgCollisionConvexPolygon
Definition: dgCollisionConvexPolygon.h:31
dgBody::m_uniqueID
dgInt32 m_uniqueID
Definition: dgBody.h:218
dgQuaternion
Definition: dgQuaternion.h:31
dgBody::IntegrateVelocity
virtual void IntegrateVelocity(dgFloat32 timestep)
Definition: dgBody.cpp:277
dgBody::GetDestructorCallback
OnBodyDestroy GetDestructorCallback() const
Definition: dgBody.h:416
dgBody::GetWorld
dgWorld * GetWorld() const
Definition: dgBody.h:315
dgBody::InvalidateCache
virtual void InvalidateCache()
Definition: dgBody.cpp:590
dgBilateralConstraint
Definition: dgBilateralConstraint.h:29
dgBody::OnBodyDestroy
void(dgApi * OnBodyDestroy)(dgBody &me)
Definition: dgBody.h:47
DG_GCC_VECTOR_ALIGMENT
DG_MSC_VECTOR_ALIGMENT class dgBody DG_GCC_VECTOR_ALIGMENT
dgBody::m_kinematicBody
Definition: dgBody.h:62
dgBody::SetOmega
void SetOmega(const dgVector &omega)
Definition: dgBody.h:358
dgBody::m_localCentreOfMass
dgVector m_localCentreOfMass
Definition: dgBody.h:214
dgBody::GetForce
virtual const dgVector & GetForce() const =0
dgBody::m_inCallback
dgUnsigned32 m_inCallback
Definition: dgBody.h:237
dgWorldDynamicUpdate
Definition: dgWorldDynamicUpdate.h:252
dgSerialize
void(dgApi * dgSerialize)(void *const userData, const void *const buffer, size_t size)
Definition: dgTypes.h:280
dgTree
Definition: dgTree.h:88
dgBody::m_baseBodyRTTI
Definition: dgBody.h:53
DG_MSC_VECTOR_ALIGMENT
#define DG_MSC_VECTOR_ALIGMENT
Definition: dgTypes.h:194
dgBody::m_matrix
dgMatrix m_matrix
Definition: dgBody.h:204
dgBody::ApplyImpulsePair
virtual void ApplyImpulsePair(const dgVector &linearImpulse, const dgVector &angularImpulse)
Definition: dgBody.cpp:655
dgBody::GetContinueCollisionMode
bool GetContinueCollisionMode() const
Definition: dgBody.h:444
dgVector::m_x
dgFloat32 m_x
Definition: dgVector.h:1025
dgBody::Freeze
void Freeze()
Definition: dgBody.cpp:418
dgBody::CalculateInvInertiaMatrix
virtual dgMatrix CalculateInvInertiaMatrix() const
Definition: dgBody.cpp:577
dgBroadPhase
Definition: dgBroadPhase.h:65
dgDeserialize
void(dgApi * dgDeserialize)(void *const userData, void *buffer, size_t size)
Definition: dgTypes.h:279
dgBody::GetPosition
const dgVector & GetPosition() const
Definition: dgBody.h:380
dgBody::GetCentreOfMass
const dgVector & GetCentreOfMass() const
Definition: dgBody.h:390
dgBody::SetUserData
void SetUserData(void *const userData)
Definition: dgBody.h:305
dgBody::m_netTorque
dgVector m_netTorque
Definition: dgBody.h:213
dgBody::RayCast
virtual dgFloat32 RayCast(const dgLineBox &line, OnRayCastAction filter, OnRayPrecastAction preFilter, void *const userData, dgFloat32 minT) const
Definition: dgBody.cpp:219
dgBody::m_collidable
dgUnsigned32 m_collidable
Definition: dgBody.h:238
dgBody::m_rtti
dgInt32 m_rtti
Definition: dgBody.h:220
dgBody::SetFreeze
void SetFreeze(bool state)
Definition: dgBody.cpp:408
dgBody::m_netForce
dgVector m_netForce
Definition: dgBody.h:212
OnRayPrecastAction
dgUnsigned32(dgApi * OnRayPrecastAction)(const dgBody *const body, const dgCollisionInstance *const collision, void *const userData)
Definition: dgBroadPhase.h:36
dgBody::Unfreeze
void Unfreeze()
Definition: dgBody.cpp:431
dgBody::SetMatrix
virtual void SetMatrix(const dgMatrix &matrix)
Definition: dgBody.cpp:176
dgBody::SetLinearDamping
virtual void SetLinearDamping(dgFloat32 linearDamp)=0
dgCollisionInstance
Definition: dgCollisionInstance.h:30
dgBody::m_invWorldInertiaMatrix
dgMatrix m_invWorldInertiaMatrix
Definition: dgBody.h:203
dgBody::SetContinueCollisionMode
void SetContinueCollisionMode(bool mode)
Definition: dgBody.h:439
dgBody::GetCollision
dgCollisionInstance * GetCollision() const
Definition: dgBody.h:434
dgBody::IsCollidable
bool IsCollidable() const
Definition: dgBody.h:489
dgBody::m_type
dgInt32 m_type
Definition: dgBody.h:221
dgBroadPhase::dgNode
Definition: dgBroadPhase.cpp:43
dgBody::GetInertiaMatrix
const dgMatrix & GetInertiaMatrix() const
Definition: dgBody.h:277
dgBody::m_resting
dgUnsigned32 m_resting
Definition: dgBody.h:239
dgCollisionScene
Definition: dgCollisionScene.h:31
dgUnsigned32
unsigned dgUnsigned32
Definition: dgTypes.h:219
dgBody::GetNetForce
const dgVector & GetNetForce() const
Definition: dgBody.h:530
dgCollisionConvex
Definition: dgCollisionConvex.h:42
dgCheckFloat
#define dgCheckFloat(x)
Definition: dgTypes.h:273
dgBody::Serialize
virtual void Serialize(const dgTree< dgInt32, const dgCollision *> *const collisionNode, dgSerialize serializeCallback, void *const userData)
Definition: dgBody.cpp:158
dgBody::m_destructor
OnBodyDestroy m_destructor
Definition: dgBody.h:250
dgBody::CalculateInertiaMatrix
virtual dgMatrix CalculateInertiaMatrix() const
Definition: dgBody.cpp:564
dgBody::m_collisionCell
dgBroadPhase::dgNode * m_collisionCell
Definition: dgBody.h:247
dgBody::GetAngularDamping
virtual dgVector GetAngularDamping() const =0
dgBody::m_dynamicBodyRTTI
Definition: dgBody.h:54
dgBody::GetSleepState
bool GetSleepState() const
Definition: dgBody.h:477
dgBody::m_autoSleep
dgUnsigned32 m_autoSleep
Definition: dgBody.h:232
dgBody::m_veloc
dgVector m_veloc
Definition: dgBody.h:208
dgBody::IsInEquilibrium
virtual bool IsInEquilibrium() const =0
threadIndex
dgFloat32 dgInt32 threadIndex
Definition: dgConstraint.h:44
dgBody::m_rotation
dgQuaternion m_rotation
Definition: dgBody.h:205
timestep
dgFloat32 timestep
Definition: dgBallConstraint.h:34
dgBody::PredictAngularVelocity
virtual dgVector PredictAngularVelocity(dgFloat32 timestep) const =0
dgBody::PredictLinearVelocity
virtual dgVector PredictLinearVelocity(dgFloat32 timestep) const =0
dgCollision
Definition: dgCollision.h:217
dgBody::m_freeze
dgUnsigned32 m_freeze
Definition: dgBody.h:230
dgBody::GetMatrix
const dgMatrix & GetMatrix() const
Definition: dgBody.h:375
dgBody::ApplyImpulsesAtPoint
virtual void ApplyImpulsesAtPoint(dgInt32 count, dgInt32 strideInBytes, const dgFloat32 *const impulseArray, const dgFloat32 *const pointArray)
Definition: dgBody.cpp:671
dgCollisionUserMesh
Definition: dgCollisionUserMesh.h:30
dgBody::m_deformableBodyRTTI
Definition: dgBody.h:56
dgBody::m_index
dgInt32 m_index
Definition: dgBody.h:217
dgMatrix
Definition: dgMatrix.h:40
dgPhysicsStdafx.h
dgMatrix::m_posit
dgVector m_posit
Definition: dgMatrix.h:104
dgBody::m_flags
dgUnsigned32 m_flags
Definition: dgBody.h:228
dgBody::m_collideWithLinkedBodies
dgUnsigned32 m_collideWithLinkedBodies
Definition: dgBody.h:236
dgBody::GetType
dgType GetType() const
Definition: dgBody.h:295
dgBody::m_equilibrium
dgUnsigned32 m_equilibrium
Definition: dgBody.h:233
dgConstraint
Definition: dgConstraint.h:140
dgBody::GetAABB
void GetAABB(dgVector &p0, dgVector &p1) const
Definition: dgBody.h:338
dgWorld
Definition: dgWorld.h:129
dgBody::UpdateCollisionMatrix
void UpdateCollisionMatrix(dgFloat32 timestep, dgInt32 threadIndex)
Definition: dgBody.cpp:198
dgBody::OnMatrixUpdateCallback
void(dgApi * OnMatrixUpdateCallback)(const dgBody &me, const dgMatrix &matrix, dgInt32 threadIndex)
Definition: dgBody.h:49
dgBody::IsRTTIType
dgInt32 IsRTTIType(dgUnsigned32 rtti) const
Definition: dgBody.h:300
dgBody::GetUniqueID
dgInt32 GetUniqueID() const
Definition: dgBody.h:405
dgBody::CalculateInverseDynamicForce
virtual dgVector CalculateInverseDynamicForce(const dgVector &desiredVeloc, dgFloat32 timestep) const
Definition: dgBody.cpp:322
dgBody::AddImpulse
virtual void AddImpulse(const dgVector &pointVeloc, const dgVector &pointPosit)
Definition: dgBody.cpp:600
dgBody::SetMatrixIgnoreSleep
virtual void SetMatrixIgnoreSleep(const dgMatrix &matrix)
Definition: dgBody.cpp:185
dgVector::m_w
dgFloat32 m_w
Definition: dgVector.h:1028
dgBody::SetGroupID
virtual void SetGroupID(dgUnsigned32 id)
Definition: dgBody.h:326
dgBody::dgType
dgType
Definition: dgBody.h:59
dgBody::SetCentreOfMass
void SetCentreOfMass(const dgVector &com)
Definition: dgBody.h:395
dgBody::SetSleepState
void SetSleepState(bool state)
Definition: dgBody.h:482
dgBody::GetApparentMass
dgVector GetApparentMass() const
Definition: dgBody.h:494
dgBody::GetMatrixUpdateCallback
OnMatrixUpdateCallback GetMatrixUpdateCallback() const
Definition: dgBody.h:427
dgBody::SetCollidable
virtual void SetCollidable(bool state)=0
dgBody::GetVelocityAtPoint
dgVector GetVelocityAtPoint(const dgVector &point) const
Definition: dgBody.h:364
dgBody::GetNetTorque
const dgVector & GetNetTorque() const
Definition: dgBody.h:535
dgBody::AddDampingAcceleration
virtual void AddDampingAcceleration()=0
dgBody::SetForce
virtual void SetForce(const dgVector &force)=0
dgBody::UpdateMatrix
void UpdateMatrix(dgFloat32 timestep, dgInt32 threadIndex)
Definition: dgBody.cpp:268
dgBody::OnApplyExtForceAndTorque
void(dgApi * OnApplyExtForceAndTorque)(dgBody &me, dgFloat32 timestep, dgInt32 threadIndex)
Definition: dgBody.h:48
dgBodyMasterList.h
dgBody::m_sleeping
dgUnsigned32 m_sleeping
Definition: dgBody.h:231
dgBody::m_invMass
dgVector m_invMass
Definition: dgBody.h:207
dgBody::ApplyExtenalForces
virtual void ApplyExtenalForces(dgFloat32 timestep, dgInt32 threadIndex)=0
dgBody::GetAutoSleep
bool GetAutoSleep() const
Definition: dgBody.h:472
dgBody::UpdateWorlCollisionMatrix
void UpdateWorlCollisionMatrix() const
Definition: dgBody.cpp:191
dgCollisionCompound
Definition: dgCollisionCompound.h:35
dgBody::GetTorque
virtual const dgVector & GetTorque() const =0
dgVector::m_y
dgFloat32 m_y
Definition: dgVector.h:1026
dgBody::GetNextContact
virtual dgConstraint * GetNextContact(dgConstraint *const joint) const
Definition: dgBody.cpp:385
dgBody::m_dynamicBody
Definition: dgBody.h:61
dgBody::GetMasterList
dgBodyMasterList::dgListNode * GetMasterList() const
Definition: dgBody.h:333