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

My Project

dgWorld.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_WORLD_H_
23 #define _DG_WORLD_H_
24
25
26 #include "dgBody.h"
27 #include "dgContact.h"
28 #include "dgCollision.h"
29 #include "dgBroadPhase.h"
30 #include "dgCollisionScene.h"
31 #include "dgBodyMasterList.h"
32 #include "dgWorldDynamicUpdate.h"
33 #include "dgDeformableBodiesUpdate.h"
34 #include "dgCollisionCompoundFractured.h"
35
36 #define DG_REDUCE_CONTACT_TOLERANCE dgFloat32 (5.0e-2f)
37
38
39 #define DG_SLEEP_ENTRIES 8
40 #define DG_MAX_DESTROYED_BODIES_BY_FORCE 8
41
42
43 class dgBody;
44 class dgAmpInstance;
45 class dgDynamicBody;
46 class dgKinematicBody;
47 class dgCollisionPoint;
48 class dgUserConstraint;
49 class dgBallConstraint;
50 class dgHingeConstraint;
51 class dgUserMeshCreation;
52 class dgSlidingConstraint;
53 class dgCollisionInstance;
54 class dgUpVectorConstraint;
55 class dgUniversalConstraint;
56 class dgCorkscrewConstraint;
57 class dgCollisionDeformableMesh;
58
59
60 class dgBodyCollisionList: public dgTree<const dgCollision*, dgUnsigned32>
61 {
62 public:
63 dgBodyCollisionList (dgMemoryAllocator* const allocator)
64 :dgTree<const dgCollision*, dgUnsigned32>(allocator)
65 {
66 }
67 };
68
69 class dgBodyMaterialList: public dgTree<dgContactMaterial, dgUnsigned32>
70 {
71 public:
72 dgBodyMaterialList (dgMemoryAllocator* const allocator)
73 :dgTree<dgContactMaterial, dgUnsigned32>(allocator)
74 {
75 }
76 };
77
78
79 class dgCollisionParamProxy;
80
81 enum dgPerformanceCounters
82 {
83 m_worldTicks = 0,
84
85 m_collisionTicks,
86 m_broadPhaceTicks,
87 m_narrowPhaseTicks,
88
89 m_dynamicsTicks,
90 m_dynamicsBuildSpanningTreeTicks,
91 m_dynamicsSolveSpanningTreeTicks,
92
93 m_forceCallbackTicks,
94 m_softBodyTicks,
95
96 m_preUpdataListerTicks,
97 m_postUpdataListerTicks,
98
99 m_counterSize
100 };
101
102 class dgWorld;
103 class dgCollisionInstance;
104
105 class dgSolverSleepTherfesholds
106 {
107 public:
108 dgFloat32 m_maxAccel;
109 dgFloat32 m_maxAlpha;
110 dgFloat32 m_maxVeloc;
111 dgFloat32 m_maxOmega;
112 dgInt32 m_steps;
113 };
114
115
116 class dgWorldThreadPool: public dgThreadHive
117 {
118 public:
119 dgWorldThreadPool(dgMemoryAllocator* const allocator)
120 :dgThreadHive(allocator)
121 {
122 }
123
124 virtual void OnBeginWorkerThread (dgInt32 threadId);
125 virtual void OnEndWorkerThread (dgInt32 threadId);
126 };
127
128 DG_MSC_VECTOR_ALIGMENT
129 class dgWorld
130 :public dgBodyMasterList
131 ,public dgBodyMaterialList
132 ,public dgBodyCollisionList
133 ,public dgDeformableBodiesUpdate
134 ,public dgActiveContacts
135 ,public dgCollidingPairCollector
136 ,public dgWorldDynamicUpdate
137 ,public dgMutexThread
138 ,public dgAsyncThread
139 ,public dgWorldThreadPool
140 {
141 public:
142
143 typedef dgUnsigned32 (dgApi *OnIslandUpdate) (const dgWorld* const world, void* island, dgInt32 bodyCount);
144 typedef void (dgApi *OnListenerBodyDestroyCallback) (const dgWorld* const world, void* const listener, dgBody* const body);
145 typedef void (dgApi *OnListenerUpdateCallback) (const dgWorld* const world, void* const listener, dgFloat32 timestep);
146 typedef void (dgApi *OnListenerDestroyCallback) (const dgWorld* const world, void* const listener);
147 typedef void (dgApi *OnBodySerialize) (dgBody& me, dgSerialize funt, void* const serilalizeObject);
148 typedef void (dgApi *OnBodyDeserialize) (dgBody& me, dgDeserialize funt, void* const serilalizeObject);
149 typedef void (dgApi *OnCollisionInstanceDestroy) (const dgWorld* const world, const dgCollisionInstance* const collision);
150 typedef void (dgApi *OnCollisionInstanceDuplicate) (const dgWorld* const world, dgCollisionInstance* const collision, const dgCollisionInstance* const sourceCollision);
151
152 class dgListener
153 {
154 public:
155 dgListener()
156 :m_world(NULL)
157 ,m_userData(NULL)
158 ,m_onListenerUpdate(NULL)
159 ,m_onListenerDestroy(NULL)
160 ,m_onBodyDestroy(NULL)
161 {
162 }
163
164 ~dgListener()
165 {
166 if (m_onListenerDestroy) {
167 m_onListenerDestroy(m_world, m_userData);
168 }
169 }
170
171 char m_name[32];
172 dgWorld* m_world;
173 void* m_userData;
174 OnListenerUpdateCallback m_onListenerUpdate;
175 OnListenerDestroyCallback m_onListenerDestroy;
176 OnListenerBodyDestroyCallback m_onBodyDestroy;
177 };
178
179 class dgListenerList: public dgList <dgListener>
180 {
181 public:
182 dgListenerList (dgMemoryAllocator* const allocator)
183 :dgList <dgListener>(allocator)
184 {
185 }
186
187 ~dgListenerList()
188 {
189 }
190 };
191
192 DG_CLASS_ALLOCATOR(allocator)
193
194 dgWorld(dgMemoryAllocator* const allocator);
195 ~dgWorld();
196
197 dgBroadPhase* GetBroadPhase() const;
198
199 void SetSolverMode (dgInt32 mode);
200 void SetFrictionMode (dgInt32 mode);
201
202 dgInt32 EnumerateHardwareModes() const;
203 dgInt32 GetCurrentHardwareMode() const;
204 void SetCurrentHardwareMode(dgInt32 deviceIndex);
205 void GetHardwareVendorString (dgInt32 deviceIndex, char* const description, dgInt32 maxlength) const;
206
207
208 void EnableThreadOnSingleIsland(dgInt32 mode);
209 dgInt32 GetThreadOnSingleIsland() const;
210
211 void FlushCache();
212
213 void* GetUserData() const;
214 void SetUserData (void* const userData);
215
216 void Update (dgFloat32 timestep);
217 void UpdateAsync (dgFloat32 timestep);
218
219 void StepDynamics (dgFloat32 timestep);
220
221 dgInt32 Collide (const dgCollisionInstance* const collisionA, const dgMatrix& matrixA,
222 const dgCollisionInstance* const collisionB, const dgMatrix& matrixB,
223 dgTriplex* const points, dgTriplex* const normals, dgFloat32* const penetration,
224 dgInt64* const attibuteA, dgInt64* const attibuteB, dgInt32 maxContacts, dgInt32 threadIndex);
225
226 dgInt32 CollideContinue (const dgCollisionInstance* const collisionA, const dgMatrix& matrixA, const dgVector& velocA, const dgVector& omegaA,
227 const dgCollisionInstance* const collisionB, const dgMatrix& matrixB, const dgVector& velocB, const dgVector& omegaB,
228 dgFloat32& timeStep, dgTriplex* const points, dgTriplex* const normals, dgFloat32* const penetration,
229 dgInt64* const attibuteA, dgInt64* const attibuteB, dgInt32 maxContacts, dgInt32 threadIndex);
230
231 bool IntersectionTest (const dgCollisionInstance* const collisionA, const dgMatrix& matrixA,
232 const dgCollisionInstance* const collisionB, const dgMatrix& matrixB,
233 dgInt32 threadIndex);
234
235 dgInt32 ClosestPoint (dgTriplex& point, const dgCollisionInstance* const collision, const dgMatrix& matrix, dgTriplex& contact, dgTriplex& normal, dgInt32 threadIndex);
236 dgInt32 ClosestPoint (const dgCollisionInstance* const collisionA, const dgMatrix& matrixA,
237 const dgCollisionInstance* const collisionB, const dgMatrix& matrixB,
238 dgTriplex& contactA, dgTriplex& contactB, dgTriplex& normalAB, dgInt32 threadIndex);
239
240
241 void SetFrictionThreshold (dgFloat32 acceletion);
242
243
244 dgBody* GetIslandBody (const void* const island, dgInt32 index) const;
245
246
247 void* GetListenerUserData (void* const listener) const;
248 void* FindPreListener (const char* const nameid) const;
249 void* FindPostListener (const char* const nameid) const;
250 void* AddPreListener (const char* const nameid, void* const userData, OnListenerUpdateCallback updateCallback, OnListenerDestroyCallback destroyCallback);
251 void* AddPostListener (const char* const nameid, void* const userData, OnListenerUpdateCallback updateCallback, OnListenerDestroyCallback destroyCallback);
252 void SetListenerBodyDestroyCallback (void* const listener, OnListenerBodyDestroyCallback callback);
253 OnListenerBodyDestroyCallback GetListenerBodyDestroyCallback (void* const listener) const;
254
255 void SetIslandUpdateCallback (OnIslandUpdate callback);
256
257 void InitBody (dgBody* const body, dgCollisionInstance* const collision, const dgMatrix& matrix);
258 dgDynamicBody* CreateDynamicBody (dgCollisionInstance* const collision, const dgMatrix& matrix);
259 dgKinematicBody* CreateKinematicBody (dgCollisionInstance* const collision, const dgMatrix& matrix);
260 dgBody* CreateDeformableBody (dgCollisionInstance* const collision, const dgMatrix& matrix);
261 void DestroyBody(dgBody* const body);
262 void DestroyAllBodies ();
263
264 // void AddToBreakQueue (const dgContact* const contactJoint, dgBody* const body, dgFloat32 maxForce);
265
266 // modify the velocity and angular velocity of a body in such a way
267 // that the velocity of pointPosit is increase by pointDeltaVeloc
268 // pointVeloc and pointPosit are in world space
269 // void AddBodyImpulse (dgBody* body, const dgVector& pointDeltaVeloc, const dgVector& pointPosit);
270 // void ApplyImpulseArray (dgBody* body, dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const impulseArray, const dgFloat32* const pointArray);
271
272 // apply the transform matrix to the body and recurse trough all bodies attached to this body with a
273 // bilateral joint contact joint are ignored.
274 void BodySetMatrix (dgBody* const body, const dgMatrix& matrix);
275
276 dgInt32 GetBodiesCount() const;
277 dgInt32 GetConstraintsCount() const;
278
279 dgCollisionInstance* CreateInstance (const dgCollision* const child, dgInt32 shapeID, const dgMatrix& offsetMatrix);
280
281 dgCollisionInstance* CreateNull ();
282 dgCollisionInstance* CreateSphere (dgFloat32 radiusdg, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix());
283 dgCollisionInstance* CreateCone (dgFloat32 radius, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix());
284 dgCollisionInstance* CreateCapsule (dgFloat32 radius, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix());
285 dgCollisionInstance* CreateCylinder (dgFloat32 radius, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix());
286 dgCollisionInstance* CreateBox (dgFloat32 dx, dgFloat32 dy, dgFloat32 dz, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix());
287 dgCollisionInstance* CreateConvexHull (dgInt32 count, const dgFloat32* const points, dgInt32 strideInBytes, dgFloat32 thickness, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix());
288 dgCollisionInstance* CreateTaperedCapsule (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix());
289 dgCollisionInstance* CreateTaperedCylinder (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix());
290 dgCollisionInstance* CreateChamferCylinder (dgFloat32 radius, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix());
291 dgCollisionInstance* CreateCompound ();
292 dgCollisionInstance* CreateFracturedCompound (dgMeshEffect* const solidMesh, int shapeID, int fracturePhysicsMaterialID, int pointcloudCount, const dgFloat32* const vertexCloud, int strideInBytes, int materialID, const dgMatrix& textureMatrix,
293 dgCollisionCompoundFractured::OnEmitFractureChunkCallBack emitFrafuredChunk, dgCollisionCompoundFractured::OnEmitNewCompundFractureCallBack emitFracturedCompound, dgCollisionCompoundFractured::OnReconstructFractureMainMeshCallBack reconstructMainMesh);
294 dgCollisionInstance* CreateDeformableMesh (dgMeshEffect* const mesh, dgInt32 shapeID);
295 dgCollisionInstance* CreateClothPatchMesh (dgMeshEffect* const mesh, dgInt32 shapeID, const dgClothPatchMaterial& structuralMaterial, const dgClothPatchMaterial& bendMaterial);
296 dgCollisionInstance* CreateBVH ();
297 dgCollisionInstance* CreateStaticUserMesh (const dgVector& boxP0, const dgVector& boxP1, const dgUserMeshCreation& data);
298 dgCollisionInstance* CreateHeightField (dgInt32 width, dgInt32 height, dgInt32 contructionMode, dgInt32 elevationDataType, const void* const elevationMap, const dgInt8* const atributeMap, dgFloat32 verticalScale, dgFloat32 horizontalScale);
299 dgCollisionInstance* CreateScene ();
300
301 void SetCollisionInstanceConstructorDestructor (OnCollisionInstanceDuplicate constructor, OnCollisionInstanceDestroy destructor);
302
303 static void OnSerializeToFile (void* const userData, const void* const buffer, size_t size);
304 static void OnBodySerializeToFile (dgBody& body, dgSerialize serializeCallback, void* const userData);
305
306 void SerializeToFile (const char* const fileName) const;
307 void SerializeBodyArray (dgBody** const array, dgInt32 count, OnBodySerialize bodyCallback, dgSerialize serializeCallback, void* const userData) const;
308 void DeserializeBodyArray (OnBodyDeserialize bodyCallback, dgDeserialize deserializeCallback, void* const userData);
309
310 void SerializeCollision (dgCollisionInstance* const shape, dgSerialize deserialization, void* const userData) const;
311 dgCollisionInstance* CreateCollisionFromSerialization (dgDeserialize deserialization, void* const userData);
312 void ReleaseCollision(const dgCollision* const collision);
313
314 dgUpVectorConstraint* CreateUpVectorConstraint (const dgVector& pin, dgBody *body);
315
316 dgBallConstraint* CreateBallConstraint (const dgVector& pivot, dgBody* const body0, dgBody *refBody = NULL);
317 dgHingeConstraint* CreateHingeConstraint (const dgVector& pivot, const dgVector& pin, dgBody* const body0, dgBody *refBody = NULL);
318 dgSlidingConstraint* CreateSlidingConstraint (const dgVector& pivot, const dgVector& pin, dgBody* const body0, dgBody *refBody = NULL);
319 dgCorkscrewConstraint* CreateCorkscrewConstraint (const dgVector& pivot, const dgVector& pin, dgBody* const body0, dgBody *refBody = NULL);
320 dgUniversalConstraint* CreateUniversalConstraint (const dgVector& pivot, const dgVector& pin0, const dgVector& pin1, dgBody* const body0, dgBody *body1 = NULL);
321
322
323 void DestroyConstraint (dgConstraint* constraint);
324 dgUnsigned32 CreateBodyGroupID();
325 void RemoveAllGroupID();
326
327 dgUnsigned32 GetDefualtBodyGroupID() const;
328 dgContactMaterial* GetMaterial (dgUnsigned32 bodyGroupId0, dgUnsigned32 bodyGroupId1) const;
329
330 dgContactMaterial* GetFirstMaterial () const;
331 dgContactMaterial* GetNextMaterial (dgContactMaterial* material) const;
332
333 OnGetPerformanceCountCallback GetPerformaceFuntion()const ;
334 void SetPerfomanceCounter(OnGetPerformanceCountCallback callback);
335
336 void SetThreadsCount (dgInt32 count);
337 dgUnsigned32 GetPerfomanceTicks (dgUnsigned32 entry) const;
338 dgUnsigned32 GetThreadPerfomanceTicks (dgUnsigned32 threadIndex) const;
339
340 //Parallel Job dispatcher for user related stuff
341 void ExecuteUserJob (dgWorkerThreadTaskCallback userJobKernel, void* const userJobKernelContext);
342
343 void BodyEnableSimulation (dgBody* const body);
344 void BodyDisableSimulation (dgBody* const body);
345 bool GetBodyEnableDisableSimulationState (dgBody* const body) const;
346
347 dgBody* GetSentinelBody() const;
348 dgMemoryAllocator* GetAllocator() const;
349
350
351 dgFloat32 GetContactMergeTolerance() const;
352 void SetContactMergeTolerance(dgFloat32 tolerenace);
353
354 void Sync ();
355
356 private:
357
358 void CalculateContacts (dgCollidingPairCollector::dgPair* const pair, dgFloat32 timestep, dgInt32 threadIndex, bool ccdMode, bool intersectionTestOnly);
359 dgInt32 PruneContacts (dgInt32 count, dgContactPoint* const contact, dgInt32 maxCount = (DG_CONSTRAINT_MAX_ROWS / 3)) const;
360 dgInt32 ReduceContacts (dgInt32 count, dgContactPoint* const contact, dgInt32 maxCount, dgFloat32 tol, dgInt32 arrayIsSorted = 0) const;
361
362 // dgInt32 CalculateHullToHullContacts (dgCollisionParamProxy& proxy) const;
363 // void PopulateContacts (dgContact* const contact, dgCollidingPairCollector::dgPair* const pair, dgFloat32 timestep, dgInt32 threadIndex);
364 // dgInt32 CalculateConicConvexToHullContacts (dgCollisionParamProxy& proxy) const;
365 // dgInt32 CalculateConvexToConvexContinuesContacts (dgFloat32& timestep, dgBody* body1, dgBody* body2, dgContactPoint contactOut[]) const;
366 // dgInt32 CalculateConvexToConvexContinuesContacts (dgCollisionParamProxy& proxy) const;
367 // dgInt32 CalculateConvexToConvexContinuesContacts (dgCollisionParamProxy& proxy) const;
368 // dgInt32 CalculateConvexToConvexContacts (dgFloat32& timestep, dgBody* conv1, dgBody* conv2, dgFloat32 penetrationPadding, dgContactPoint* const contact) const;
369 // dgInt32 CalculateConvexToNonConvexContacts (dgFloat32& timestep, dgBody* conv, dgBody* nConv, dgContactPoint* const contact, dgInt32 maxContacts) const;
370 // dgInt32 CalculatecConvexConvexCastContacts (dgCollisionParamProxy& proxy, bool& algorithmSuccessful) const;
371
372 dgInt32 ValidateContactCache (dgContact* const contact, dgFloat32 timestep) const;
373
374 dgInt32 CalculateConvexPolygonToHullContactsDescrete (dgCollisionParamProxy& proxy) const;
375
376 dgInt32 CalculatePolySoupToHullContactsDescrete (dgCollisionParamProxy& proxy) const;
377 dgInt32 CalculateConvexToNonConvexContactsContinue (dgCollisionParamProxy& proxy) const;
378
379 dgInt32 CalculateConvexToConvexContacts (dgCollisionParamProxy& proxy) const;
380
381 dgInt32 CalculateConvexToNonConvexContacts (dgCollisionParamProxy& proxy) const;
382
383 //dgInt32 FilterPolygonDuplicateContacts (dgInt32 count, dgContactPoint* const contact) const;
384
385 void PopulateContacts (dgCollidingPairCollector::dgPair* const pair, dgFloat32 timestep, dgInt32 threadIndex);
386 void ProcessContacts (dgCollidingPairCollector::dgPair* const pair, dgFloat32 timestep, dgInt32 threadIndex);
387 void ProcessDeformableContacts (dgCollidingPairCollector::dgPair* const pair, dgFloat32 timestep, dgInt32 threadIndex);
388 void ProcessCachedContacts (dgContact* const contact, dgFloat32 timestep, dgInt32 threadIndex) const;
389
390 void ConvexContacts (dgCollidingPairCollector::dgPair* const pair, dgCollisionParamProxy& proxy) const;
391 void CompoundContacts (dgCollidingPairCollector::dgPair* const pair, dgCollisionParamProxy& proxy) const;
392 void DeformableContacts (dgCollidingPairCollector::dgPair* const pair, dgCollisionParamProxy& proxy) const;
393
394 void SceneContacts (dgCollidingPairCollector::dgPair* const pair, dgCollisionParamProxy& proxy) const;
395 void SceneChildContacts (dgCollidingPairCollector::dgPair* const pair, dgCollisionParamProxy& proxy) const;
396
397 dgFloat32 CalculateTimeToImpact (dgContact* const contactJoint, dgFloat32 timestep, dgInt32 threadIndex, dgVector& p, dgVector& q, dgVector& normal) const;
398 dgInt32 ClosestPoint (dgCollisionParamProxy& proxy) const;
399 //dgInt32 ClosestCompoundPoint (dgBody* const compoundConvexA, dgBody* const collisionB, dgTriplex& contactA, dgTriplex& contactB, dgTriplex& normalAB, dgInt32 threadIndex) const;
400 dgInt32 ClosestCompoundPoint (dgCollisionParamProxy& proxy) const;
401
402 bool AreBodyConnectedByJoints (dgBody* const origin, dgBody* const target);
403
404 void AddSentinelBody();
405 void InitConvexCollision ();
406 static dgUnsigned32 dgApi GetPerformanceCount ();
407
408 virtual void Execute (dgInt32 threadID);
409 virtual void TickCallback (dgInt32 threadID);
410
411
412 class dgAdressDistPair
413 {
414 public:
415 dgInt32 m_adress;
416 dgFloat32 m_dist;
417 };
418 static dgInt32 SortFaces (const dgAdressDistPair* const A, const dgAdressDistPair* const B, void* const context);
419
420
421 dgUnsigned32 m_dynamicsLru;
422 dgUnsigned32 m_inUpdate;
423 dgUnsigned32 m_solverMode;
424 dgUnsigned32 m_frictionMode;
425 dgUnsigned32 m_bodyGroupID;
426 dgUnsigned32 m_defualtBodyGroupID;
427 dgUnsigned32 m_bodiesUniqueID;
428 dgUnsigned32 m_useParallelSolver;
429 dgUnsigned32 m_genericLRUMark;
430
431 dgFloat32 m_freezeAccel2;
432 dgFloat32 m_freezeAlpha2;
433 dgFloat32 m_freezeSpeed2;
434 dgFloat32 m_freezeOmega2;
435 dgFloat32 m_frictiomTheshold;
436 dgFloat32 m_savetimestep;
437 dgFloat32 m_contactTolerance;
438
439 dgSolverSleepTherfesholds m_sleepTable[DG_SLEEP_ENTRIES];
440
441 dgBroadPhase* m_broadPhase;
442 dgDynamicBody* m_sentinelBody;
443 dgCollisionInstance* m_pointCollision;
444
445 dgAmpInstance* m_amp;
446 void* m_userData;
447 dgMemoryAllocator* m_allocator;
448 dgInt32 m_hardwaredIndex;
449 OnIslandUpdate m_islandUpdate;
450 OnGetPerformanceCountCallback m_getPerformanceCount;
451 OnCollisionInstanceDestroy m_onCollisionInstanceDestruction;
452 OnCollisionInstanceDuplicate m_onCollisionInstanceCopyConstrutor;
453
454
455 dgUnsigned32 m_perfomanceCounters[m_counterSize];
456 dgUnsigned32 m_perfomanceCountersBack[m_counterSize];
457
458 dgListenerList m_preListener;
459 dgListenerList m_postListener;
460 dgTree<void*, unsigned> m_perInstanceData;
461 dgArray<dgUnsigned8> m_islandMemory;
462 dgArray<dgUnsigned8> m_bodiesMemory;
463 dgArray<dgUnsigned8> m_jointsMemory;
464 dgArray<dgUnsigned8> m_pairMemoryBuffer;
465 dgArray<dgUnsigned8> m_solverMatrixMemory;
466 dgArray<dgUnsigned8> m_solverRightSideMemory;
467
468 static dgVector m_linearContactError2;
469 static dgVector m_angularContactError2;
470
471 friend class dgBody;
472 friend class dgBroadPhase;
473 friend class dgAmpInstance;
474 friend class dgDeformableBody;
475 friend class dgActiveContacts;
476 friend class dgUserConstraint;
477 friend class dgBodyMasterList;
478 friend class dgJacobianMemory;
479 friend class dgCollisionScene;
480 friend class dgCollisionConvex;
481 friend class dgCollisionInstance;
482 friend class dgCollisionCompound;
483 friend class dgWorldDynamicUpdate;
484 friend class dgParallelSolverClear;
485 friend class dgParallelSolverSolve;
486 friend class dgCollisionHeightField;
487 friend class dgSolverWorlkerThreads;
488 friend class dgCollisionConvexPolygon;
489 friend class dgCollidingPairCollector;
490 friend class dgCollisionDeformableMesh;
491 friend class dgParallelSolverUpdateForce;
492 friend class dgParallelSolverUpdateVeloc;
493 friend class dgParallelSolverBodyInertia;
494 friend class dgCollisionDeformableSolidMesh;
495 friend class dgBroadPhaseApplyExternalForce;
496 friend class dgParallelSolverCalculateForces;
497 friend class dgParallelSolverJointAcceleration;
498 friend class dgParallelSolverBuildJacobianRows;
499 friend class dgParallelSolverInitFeedbackUpdate;
500 friend class dgParallelSolverInitInternalForces;
501 friend class dgParallelSolverBuildJacobianMatrix;
502 friend class dgBroadPhaseMaterialCallbackWorkerThread;
503 friend class dgBroadPhaseCalculateContactsWorkerThread;
504 } DG_GCC_VECTOR_ALIGMENT ;
505
506
507 inline dgMemoryAllocator* dgWorld::GetAllocator() const
508 {
509 return m_allocator;
510 }
511
512 inline dgBroadPhase* dgWorld::GetBroadPhase() const
513 {
514 return m_broadPhase;
515 }
516
517 #endif
dgWorld::dgListener
Definition: dgWorld.h:152
OnGetPerformanceCountCallback
dgUnsigned32(dgApi * OnGetPerformanceCountCallback)()
Definition: dgTypes.h:708
dgMutexThread
Definition: dgMutexThread.h:28
dgApi
#define dgApi
Definition: dgTypes.h:263
dgInt64
long long dgInt64
Definition: dgTypes.h:222
dgCollisionCompoundFractured::OnReconstructFractureMainMeshCallBack
void(* OnReconstructFractureMainMeshCallBack)(dgBody *const body, dgConectivityGraph::dgListNode *const mainMeshNode, const dgCollisionInstance *const myInstance)
Definition: dgCollisionCompoundFractured.h:161
m_counterSize
Definition: dgWorld.h:99
dgWorld::GetAllocator
dgMemoryAllocator * GetAllocator() const
Definition: dgWorld.h:507
dgWorld::dgListenerList
Definition: dgWorld.h:179
dgContact
Definition: dgContact.h:195
dgBodyMaterialList::dgBodyMaterialList
dgBodyMaterialList(dgMemoryAllocator *const allocator)
Definition: dgWorld.h:72
m_broadPhaceTicks
Definition: dgWorld.h:86
dgCollidingPairCollector::dgPair
Definition: dgContact.h:52
dgWorld::GetBroadPhase
dgBroadPhase * GetBroadPhase() const
Definition: dgWorld.h:512
dgAmpInstance
Definition: dgAmpInstance.h:143
dgCollidingPairCollector
Definition: dgContact.h:49
dgBodyMasterList
Definition: dgBodyMasterList.h:57
dgWorld::dgListenerList::~dgListenerList
~dgListenerList()
Definition: dgWorld.h:187
dgBody
Definition: dgBody.h:44
dgThreadHive
Definition: dgThreadHive.h:37
userData
void *const userData
Definition: dgBroadPhase.h:35
dgClothPatchMaterial
Definition: dgContact.h:129
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
dgBody.h
dgUserMeshCreation
Definition: dgCollisionUserMesh.h:69
void
typedef void(dgApi *ConstraintsForceFeeback)(const dgConstraint &me
m_postUpdataListerTicks
Definition: dgWorld.h:97
dgWorld::dgListener::~dgListener
~dgListener()
Definition: dgWorld.h:164
dgJacobianMemory
Definition: dgWorldDynamicUpdate.h:242
dgDeformableBodiesUpdate.h
dgVector
Definition: dgVector.h:639
dgCorkscrewConstraint
Definition: dgCorkscrewConstraint.h:33
dgBroadPhase.h
m_worldTicks
Definition: dgWorld.h:83
dgCollisionCompoundFractured::OnEmitFractureChunkCallBack
void(* OnEmitFractureChunkCallBack)(dgBody *const body, dgConectivityGraph::dgListNode *const chunkMeshNode, const dgCollisionInstance *const myInstance)
Definition: dgCollisionCompoundFractured.h:160
dgSolverSleepTherfesholds::m_maxVeloc
dgFloat32 m_maxVeloc
Definition: dgWorld.h:110
dgAsyncThread
Definition: dgAsyncThread.h:28
m_dynamicsTicks
Definition: dgWorld.h:89
dgCollisionCompoundFractured::OnEmitNewCompundFractureCallBack
void(* OnEmitNewCompundFractureCallBack)(dgBody *const body)
Definition: dgCollisionCompoundFractured.h:159
dgWorld::dgListener::m_userData
void * m_userData
Definition: dgWorld.h:173
dgDeformableBody
Definition: dgDeformableBody.h:30
DG_CLASS_ALLOCATOR
#define DG_CLASS_ALLOCATOR(allocator)
Definition: dgMemory.h:60
dgSolverSleepTherfesholds
Definition: dgWorld.h:105
dgKinematicBody
Definition: dgKinematicBody.h:30
dgCollisionConvexPolygon
Definition: dgCollisionConvexPolygon.h:31
dgBallConstraint
Definition: dgBallConstraint.h:36
dgWorldDynamicUpdate.h
dgList
Definition: dgList.h:33
dgCollisionCompoundFractured.h
dgWorld::dgListenerList::dgListenerList
dgListenerList(dgMemoryAllocator *const allocator)
Definition: dgWorld.h:182
dgUserConstraint
Definition: dgUserConstraint.h:30
dgMeshEffect
Definition: dgMeshEffect.h:45
dgWorld::dgListener::dgListener
dgListener()
Definition: dgWorld.h:155
dgContactPoint
Definition: dgContact.h:78
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
entry
void * entry(void *arg)
Definition: self2.c:53
DG_MSC_VECTOR_ALIGMENT
#define DG_MSC_VECTOR_ALIGMENT
Definition: dgTypes.h:194
dgBodyCollisionList
Definition: dgWorld.h:60
dgPerformanceCounters
dgPerformanceCounters
Definition: dgWorld.h:81
dgBroadPhase
Definition: dgBroadPhase.h:65
dgDeserialize
void(dgApi * dgDeserialize)(void *const userData, void *buffer, size_t size)
Definition: dgTypes.h:279
dgHingeConstraint
Definition: dgHingeConstraint.h:33
m_collisionTicks
Definition: dgWorld.h:85
m_dynamicsSolveSpanningTreeTicks
Definition: dgWorld.h:91
dgInt8
char dgInt8
Definition: dgTypes.h:212
dgArray< dgUnsigned8 >
dgWorld::dgListener::m_world
dgWorld * m_world
Definition: dgWorld.h:172
dgSolverSleepTherfesholds::m_maxAccel
dgFloat32 m_maxAccel
Definition: dgWorld.h:108
DG_GCC_VECTOR_ALIGMENT
dgWorld DG_GCC_VECTOR_ALIGMENT
dgWorld::dgListener::m_onListenerDestroy
OnListenerDestroyCallback m_onListenerDestroy
Definition: dgWorld.h:175
dgWorldThreadPool::dgWorldThreadPool
dgWorldThreadPool(dgMemoryAllocator *const allocator)
Definition: dgWorld.h:119
dgCollisionInstance
Definition: dgCollisionInstance.h:30
m_preUpdataListerTicks
Definition: dgWorld.h:96
m_forceCallbackTicks
Definition: dgWorld.h:93
dgBodyCollisionList::dgBodyCollisionList
dgBodyCollisionList(dgMemoryAllocator *const allocator)
Definition: dgWorld.h:63
dgSolverSleepTherfesholds::m_maxOmega
dgFloat32 m_maxOmega
Definition: dgWorld.h:111
dgActiveContacts
Definition: dgContact.h:40
dgCollisionDeformableMesh
Definition: dgCollisionDeformableMesh.h:36
DG_SLEEP_ENTRIES
#define DG_SLEEP_ENTRIES
Definition: dgWorld.h:39
dgCollisionScene
Definition: dgCollisionScene.h:31
dgUnsigned32
unsigned dgUnsigned32
Definition: dgTypes.h:219
dgCollisionConvex
Definition: dgCollisionConvex.h:42
dgTree< const dgCollision *, dgUnsigned32 >::GetAllocator
dgMemoryAllocator * GetAllocator() const
Definition: dgTree.h:358
dgUpVectorConstraint
Definition: dgUpVectorConstraint.h:32
dgSlidingConstraint
Definition: dgSlidingConstraint.h:31
dgDeformableBodiesUpdate
Definition: dgDeformableBodiesUpdate.h:29
dgCollisionHeightField
Definition: dgCollisionHeightField.h:32
dgCollisionDeformableSolidMesh
Definition: dgCollisionDeformableSolidMesh.h:33
dgWorkerThreadTaskCallback
void(* dgWorkerThreadTaskCallback)(void *const context0, void *const context1, dgInt32 threadID)
Definition: dgThreadHive.h:35
dgContactMaterial
Definition: dgContact.h:138
threadIndex
dgFloat32 dgInt32 threadIndex
Definition: dgConstraint.h:44
timestep
dgFloat32 timestep
Definition: dgBallConstraint.h:34
dgCollision.h
dgContact.h
DG_CONSTRAINT_MAX_ROWS
#define DG_CONSTRAINT_MAX_ROWS
Definition: dgConstraint.h:35
dgWorldThreadPool
Definition: dgWorld.h:116
m_softBodyTicks
Definition: dgWorld.h:94
dgWorld::dgListener::m_onBodyDestroy
OnListenerBodyDestroyCallback m_onBodyDestroy
Definition: dgWorld.h:176
dgCollision
Definition: dgCollision.h:217
m_dynamicsBuildSpanningTreeTicks
Definition: dgWorld.h:90
dgSolverSleepTherfesholds::m_maxAlpha
dgFloat32 m_maxAlpha
Definition: dgWorld.h:109
dgMatrix
Definition: dgMatrix.h:40
dgMemoryAllocator
Definition: dgMemory.h:73
m_narrowPhaseTicks
Definition: dgWorld.h:87
dgUniversalConstraint
Definition: dgUniversalConstraint.h:33
dgBodyMaterialList
Definition: dgWorld.h:69
dgGetIdentityMatrix
const dgMatrix & dgGetIdentityMatrix()
Definition: dgMatrix.cpp:47
dgConstraint
Definition: dgConstraint.h:140
dgWorld
Definition: dgWorld.h:129
dgSolverSleepTherfesholds::m_steps
dgInt32 m_steps
Definition: dgWorld.h:112
dgCollisionScene.h
dgWorld::dgListener::m_onListenerUpdate
OnListenerUpdateCallback m_onListenerUpdate
Definition: dgWorld.h:174
dgCollisionPoint
Definition: dgCollisionSphere.h:80
dgDynamicBody
Definition: dgDynamicBody.h:40
dgTriplex
Definition: dgTypes.h:237
dgBodyMasterList.h
dgCollisionCompound
Definition: dgCollisionCompound.h:35
dgCollisionParamProxy
Definition: dgContact.h:93