22 #ifndef __ND_BODY_DYNAMIC_BODY_H__
23 #define __ND_BODY_DYNAMIC_BODY_H__
25 #include "ndNewtonStdafx.h"
27 #define D_MAX_SPEED_ATT ndFloat32(0.02f)
28 #define D_FREEZE_ACCEL ndFloat32(1.0f)
30 #define D_FREEZE_SPEED ndFloat32(0.032f)
32 #define D_FREEZE_ACCEL2 (D_FREEZE_ACCEL * D_FREEZE_ACCEL)
33 #define D_FREEZE_SPEED2 (D_FREEZE_SPEED * D_FREEZE_SPEED)
35 #define D_FREEZE_MAG D_FREEZE_ACCEL
36 #define D_FREEZE_MAG2 (D_FREEZE_MAG * D_FREEZE_MAG)
38 #define D_ERR_TOLERANCE ndFloat32(1.0e-2f)
39 #define D_ERR_TOLERANCE2 (D_ERR_TOLERANCE * D_ERR_TOLERANCE)
50 D_NEWTON_API
virtual ndBodyDynamic* GetAsBodyDynamic() {
return this; }
51 D_NEWTON_API
virtual void ApplyExternalForces(ndInt32 threadIndex, ndFloat32 timestep);
52 D_NEWTON_API
virtual void AddDampingAcceleration(ndFloat32 timestep);
53 D_NEWTON_API
virtual void IntegrateVelocity(ndFloat32 timestep);
57 D_NEWTON_API
void SetForce(
const ndVector& force);
58 D_NEWTON_API
void SetTorque(
const ndVector& torque);
60 D_NEWTON_API
void AddImpulse(
const ndVector& pointVeloc,
const ndVector& pointPosit, ndFloat32 timestep);
61 D_NEWTON_API
void ApplyImpulsePair(
const ndVector& linearImpulse,
const ndVector& angularImpulse, ndFloat32 timestep);
62 D_NEWTON_API
void ApplyImpulsesAtPoint(ndInt32 count,
const ndVector*
const impulseArray,
const ndVector*
const pointArray, ndFloat32 timestep);
64 D_NEWTON_API ndFloat32 GetLinearDamping()
const;
65 D_NEWTON_API
void SetLinearDamping(ndFloat32 linearDamp);
67 D_NEWTON_API
ndVector GetCachedDamping()
const;
68 D_NEWTON_API
ndVector GetAngularDamping()
const;
69 D_NEWTON_API
void SetAngularDamping(
const ndVector& angularDamp);
75 void SaveExternalForces();
76 D_NEWTON_API
virtual void IntegrateGyroSubstep(
const ndVector& timestep);
78 D_NEWTON_API
virtual void EvaluateSleepState(ndFloat32 freezeSpeed2, ndFloat32 freezeAccel2);
88 ndFloat32 m_cachedTimeStep;
95 } D_GCC_NEWTON_ALIGN_32 ;
97 inline ndVector ndBodyDynamic::GetForce()
const
99 return m_externalForce;
102 inline ndVector ndBodyDynamic::GetTorque()
const
104 return m_externalTorque;
107 inline void ndBodyDynamic::SaveExternalForces()
109 m_savedExternalForce = m_externalForce;
110 m_savedExternalTorque = m_externalTorque;
113 inline ndVector ndBodyDynamic::GetCachedDamping()
const
115 return m_cachedDampCoef;