22 #if !defined(AFX_DYNAMIC_UPDATE_H__EC18C699_D48D_448F_A510_A865B2CC0789__INCLUDED_) 23 #define AFX_DYNAMIC_UPDATE_H__EC18C699_D48D_448F_A510_A865B2CC0789__INCLUDED_ 26 #include "dgPhysicsStdafx.h" 30 #define DG_PSD_DAMP_TOL dgFloat32 (1.0e-3f) 34 #define LINEAR_SOLVER_SUB_STEPS 4 48 dgInt32 m_strideInByte;
66 m_pool[m_firstIndex] = info;
68 if (m_firstIndex >= m_mod) {
71 NEWTON_ASSERT(m_firstIndex != m_lastIndex);
75 NEWTON_ASSERT(m_firstIndex != m_lastIndex);
77 T element = m_pool[m_lastIndex];
79 if (m_lastIndex >= m_mod) {
87 m_lastIndex = m_firstIndex;
90 bool IsEmpty()
const {
91 return (m_firstIndex == m_lastIndex);
103 virtual void ThreadExecute();
108 dgInt32 m_solverMode;
109 dgFloat32 m_timestep;
119 virtual void ThreadExecute();
124 const dgBodyInfo *m_bodyArray;
131 virtual void ThreadExecute();
140 const dgJointInfo *m_constraintArray;
145 virtual void ThreadExecute();
148 dgInt32 m_hasJointFeeback;
151 dgFloat32 m_timestep;
153 dgFloat32 **m_jointForceFeeback;
154 const dgJointInfo *m_constraintArray;
160 virtual void ThreadExecute();
165 dgBodyInfo *m_bodyArray;
170 virtual void ThreadExecute();
177 dgFloat32 *m_diagDamp;
178 dgFloat32 *m_deltaAccel;
179 dgFloat32 *m_invDJMinvJt;
180 dgFloat32 *m_coordenateAccel;
181 dgFloat32 **m_jointFeebackForce;
184 dgBodyInfo *m_bodyArray;
185 dgJointInfo *m_constraintArray;
190 virtual void ThreadExecute();
194 dgInt32 m_jointSolved;
195 dgInt32 *m_rowsCount;
196 dgFloat32 m_timestep;
197 dgFloat32 m_invTimestep;
200 dgJointInfo *m_constraintArray;
205 virtual void ThreadExecute();
209 dgInt32 m_jointStart;
211 dgFloat32 m_timeStep;
212 dgFloat32 m_invTimeStep;
213 dgFloat32 m_firstPassCoef;
215 dgFloat32 *m_penetration;
216 const dgFloat32 *m_restitution;
217 const dgFloat32 *m_externAccel;
218 dgFloat32 *m_coordenateAccel;
219 const dgInt32 *m_accelIsMortor;
220 const dgInt32 *m_normalForceIndex;
221 const dgFloat32 *m_penetrationStiffness;
222 const dgJointInfo *m_constraintArray;
228 virtual void ThreadExecute();
233 dgFloat32 m_timeStep;
236 const dgBodyInfo *m_bodyArray;
241 virtual void ThreadExecute();
248 dgFloat32 m_invTimeStep;
249 dgFloat32 m_maxAccNorm2;
251 const dgBodyInfo *m_bodyArray;
259 virtual void ThreadExecute();
269 const dgFloat32 *m_diagDamp;
270 const dgInt32 *m_normalForceIndex;
271 const dgFloat32 *m_invDJMinvJt;
272 const dgFloat32 *m_coordenateAccel;
273 const dgFloat32 *m_lowerFrictionCoef;
274 const dgFloat32 *m_upperFrictionCoef;
277 const dgJointInfo *m_constraintArray;
286 dgInt32 m_jointCount;
287 dgInt32 m_maxBodiesCount;
288 dgInt32 m_maxJacobiansCount;
289 dgInt32 m_threadIndex;
290 dgFloat32 m_timeStep;
291 dgFloat32 m_invTimeStep;
293 dgInt32 *m_treadLocks;
296 dgJointInfo *m_constraintArray;
301 dgFloat32 *m_deltaAccel;
302 dgFloat32 *m_deltaForce;
303 dgFloat32 *m_diagDamp;
304 dgFloat32 *m_invDJMinvJt;
305 dgFloat32 *m_restitution;
306 dgFloat32 *m_penetration;
307 dgFloat32 *m_coordenateAccel;
308 dgFloat32 *m_penetrationStiffness;
309 dgFloat32 *m_lowerBoundFrictionCoefficent;
310 dgFloat32 *m_upperBoundFrictionCoefficent;
311 dgFloat32 **m_jointFeebackForce;
312 dgBodyInfo *m_bodyArray;
313 dgInt32 *m_normalForceIndex;
314 dgInt32 *m_accelIsMotor;
316 void SwapRows(dgInt32 i, dgInt32 j)
const;
317 void SwapRowsSimd(dgInt32 i, dgInt32 j)
const;
319 void CalculateReactionsForces(dgInt32 solverMode, dgFloat32 maxAccNorm)
const;
320 void CalculateReactionsForcesSimd(dgInt32 solverMode, dgFloat32 maxAccNorm)
const;
322 void ApplyExternalForcesAndAcceleration(dgFloat32 maxAccNorm)
const;
323 void ApplyExternalForcesAndAccelerationSimd(dgFloat32 maxAccNorm)
const;
325 void CalculateSimpleBodyReactionsForces(dgFloat32 maxAccNorm)
const;
326 void CalculateSimpleBodyReactionsForcesSimd(dgFloat32 maxAccNorm)
const;
328 dgFloat32 CalculateJointForces(dgInt32 joint, dgFloat32 *forceStep, dgFloat32 maxAccNorm)
const;
329 dgFloat32 CalculateJointForcesSimd(dgInt32 joint, dgFloat32 *forceStep, dgFloat32 maxAccNorm)
const;
331 void CalculateForcesSimulationMode(dgFloat32 maxAccNorm)
const;
332 void CalculateForcesSimulationModeSimd(dgFloat32 maxAccNorm)
const;
334 void CalculateForcesGameMode(dgInt32 itertions, dgFloat32 maxAccNorm)
const;
335 void CalculateForcesGameModeSimd(dgInt32 itertions, dgFloat32 maxAccNorm)
const;
337 void CalculateForcesGameModeParallel(dgInt32 itertions, dgFloat32 maxAccNorm, dgInt32 archModel)
const;
338 void CalculateReactionsForcesParallel(dgInt32 solverMode, dgFloat32 maxAccNorm, dgInt32 archModel)
const;
345 void UpdateDynamics(
dgWorld *
const world, dgInt32 archMode, dgFloat32 timestep);
349 void BuildIsland(
dgQueue<dgBody *> &queue, dgInt32 jountCount, dgInt32 hasUnilateralJoints, dgInt32 isContinueCollisionIsland);
351 void SpanningTree(
dgBody *
const body);
352 void ReallocBodyMemory(dgInt32 count);
353 void ReallocJointsMemory(dgInt32 count);
354 void ReallocIslandMemory(dgInt32 count);
358 void BuildJacobianMatrix(
const dgIsland &island, dgInt32 threadIndex, dgFloat32 timestep);
359 void BuildJacobianMatrixSimd(
const dgIsland &island, dgInt32 threadIndex, dgFloat32 timestep);
360 dgInt32 GetJacobialDerivatives(
const dgIsland &island, dgInt32 threadIndex,
bool bitMode, dgInt32 rowCount, dgFloat32 timestep);
363 void BuildJacobianMatrixParallel(
const dgIsland &island, dgFloat32 timestep, dgInt32 archModel);
364 dgInt32 GetJacobialDerivativesParallel(
const dgIsland &island,
bool bitMode, dgInt32 rowCount, dgFloat32 timestep);
366 void ReallocIntenalForcesMemory(dgInt32 count, dgInt32 threadIndex);
367 void ReallocJacobiansMemory(dgInt32 count, dgInt32 threadIndex);
371 void IntegrateArray(
const dgBodyInfo *body, dgInt32 count, dgFloat32 accelTolerance, dgFloat32 timestep, dgInt32 threadIndex,
bool update)
const;
377 dgInt32 m_maxJointCount;
378 dgInt32 m_maxBodiesCount;
379 dgInt32 m_maxIslandCount;
381 dgIsland *m_islandArray;
382 dgBodyInfo *m_bodyArray;
383 dgJointInfo *m_constraintArray;
408 #define DG_CHECK_ACTIVE(body) NEWTON_ASSERT (((body->m_invMass.m_w == dgFloat32 (0.0f)) && !body->m_active) || (body->m_invMass.m_w > dgFloat32 (0.0f))) Definition: dgWorldDynamicUpdate.h:226
Definition: dgWorldDynamicUpdate.h:129
Definition: dgWorldDynamicUpdate.h:101
Definition: dgWorldDynamicUpdate.h:143
Definition: dgWorldDynamicUpdate.h:239
Definition: dgWorldDynamicUpdate.h:282
Definition: dgWorldDynamicUpdate.h:158
Definition: dgThreads.h:28
Definition: dgWorldDynamicUpdate.h:203
Definition: dgWorldDynamicUpdate.h:168
Definition: dgWorldDynamicUpdate.h:342
Definition: dgWorldDynamicUpdate.h:117
Definition: dgWorldDynamicUpdate.h:188
Definition: dgConstraint.h:103
Definition: dgConstraint.h:110
Definition: dgWorldDynamicUpdate.h:257
Definition: dgWorldDynamicUpdate.h:44
Definition: dgWorldDynamicUpdate.h:55
Definition: dgWorld.h:118