22 #if !defined(AFX_DGCONSTRAINT_H__F9EC24E0_6E0F_4CD5_909E_A5F5E1AC7C0B__INCLUDED_) 23 #define AFX_DGCONSTRAINT_H__F9EC24E0_6E0F_4CD5_909E_A5F5E1AC7C0B__INCLUDED_ 25 #define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0]))) 27 #include "dgBodyMasterList.h" 29 #define DG_MAX_BOUND dgFloat32 (1.0e15f) 30 #define DG_MIN_BOUND (-DG_MAX_BOUND) 33 #define DG_BILATERAL_CONSTRAINT -1 34 #define DG_NORMAL_CONSTRAINT -2 35 #define DG_BILATERAL_FRICTION_CONSTRAINT -3 37 #define DG_CONSTRAINT_MAX_ROWS (3 * 16) 39 #define MIN_JOINT_PIN_LENGTH dgFloat32 (16.0f) 46 typedef void(dgApi *ConstraintsForceFeedback)(
const NewtonJoint *
const userJoint, dFloat timestep, int32 threadIndex);
53 dgFloat32 m_minLinearDof[3];
54 dgFloat32 m_maxLinearDof[3];
55 dgFloat32 m_minAngularDof[3];
56 dgFloat32 m_maxAngularDof[3];
59 dgFloat32 m_extraParameters[16];
60 dgInt32 m_collideCollisionOn;
61 char m_discriptionType[16];
64 m_attachMatrix_0 = dgGetZeroMatrix();
65 m_attachMatrix_1 = dgGetZeroMatrix();
66 for (
unsigned i = 0; i <
ARRAYSIZE(m_minLinearDof); i++)
67 m_minLinearDof[i] = dgFloat32(0.0);
68 for (
unsigned i = 0; i <
ARRAYSIZE(m_maxLinearDof); i++)
69 m_maxLinearDof[i] = dgFloat32(0.0);
70 for (
unsigned i = 0; i <
ARRAYSIZE(m_minAngularDof); i++)
71 m_minAngularDof[i] = dgFloat32(0.0);
72 for (
unsigned i = 0; i <
ARRAYSIZE(m_maxAngularDof); i++)
73 m_maxAngularDof[i] = dgFloat32(0.0);
74 m_attachBody_0 =
nullptr;
75 m_attachBody_1 =
nullptr;
76 for (
unsigned i = 0; i <
ARRAYSIZE(m_extraParameters); i++)
77 m_extraParameters[i] = dgFloat32(0.0);
78 m_collideCollisionOn = dgInt32(0);
79 for (
unsigned i = 0; i <
ARRAYSIZE(m_discriptionType); i++)
80 m_discriptionType[i] = 0;
88 dgFloat32 m_minFriction;
89 dgFloat32 m_maxFriction;
98 dgInt32 m_normalIndex;
99 dgFloat32 *m_jointForce;
102 DG_MSC_VECTOR_ALIGMENT
107 } DG_GCC_VECTOR_ALIGMENT;
109 DG_MSC_VECTOR_ALIGMENT
114 } DG_GCC_VECTOR_ALIGMENT;
119 dgFloat32 m_timeStep;
120 dgFloat32 m_invTimeStep;
121 dgFloat32 m_firstPassCoefFlag;
124 dgFloat32 *m_penetration;
125 dgFloat32 *m_coordenateAccel;
127 const dgFloat32 *m_restitution;
128 const dgInt32 *m_accelIsMotor;
129 const dgInt32 *m_normalForceIndex;
130 const dgFloat32 *m_externAccelaration;
131 const dgFloat32 *m_penetrationStiffness;
136 DG_MSC_VECTOR_ALIGMENT
141 dgFloat32 m_jointAccel[DG_CONSTRAINT_MAX_ROWS];
142 dgFloat32 m_jointStiffness[DG_CONSTRAINT_MAX_ROWS];
143 dgFloat32 m_restitution[DG_CONSTRAINT_MAX_ROWS];
144 dgFloat32 m_penetration[DG_CONSTRAINT_MAX_ROWS];
145 dgFloat32 m_penetrationStiffness[DG_CONSTRAINT_MAX_ROWS];
146 dgUnsigned32 m_isMotor[DG_CONSTRAINT_MAX_ROWS];
148 dgInt32 m_threadIndex;
149 dgFloat32 m_timestep;
150 dgFloat32 m_invTimestep;
151 } DG_GCC_VECTOR_ALIGMENT;
153 enum dgConstraintID {
156 dgSliderConstraintId,
157 dgContactConstraintId,
158 dgUpVectorConstraintId,
159 dgUniversalConstraintId,
160 dgCorkscrewConstraintId,
161 dgPointToCurveConstraintId,
163 dgUnknownConstraintId
166 typedef void(dgApi *OnConstraintDestroy)(
const NewtonJoint *
const me);
168 DG_MSC_VECTOR_ALIGMENT
171 DG_CLASS_ALLOCATOR(allocator)
173 dgUnsigned32 GetId()
const;
176 dgBodyMasterListRow::dgListNode *GetLink0()
const;
177 dgBodyMasterListRow::dgListNode *GetLink1()
const;
178 void *GetUserData()
const;
179 bool IsCollidable()
const;
182 dgInt32 GetMaxDOF()
const;
183 void SetUserData(
void *userData);
184 void SetCollidable(
bool state);
185 virtual void SetDestructorCallback(OnConstraintDestroy destructor) = 0;
187 virtual dgFloat32 GetStiffness()
const;
188 virtual void SetStiffness(dgFloat32 stiffness);
201 dgFloat32 m_stiffness;
209 virtual bool IsBilateral()
const;
218 void SetUpdateFeedbackFunction(ConstraintsForceFeedback
function);
227 dgBodyMasterListRow::dgListNode *m_link0;
228 dgBodyMasterListRow::dgListNode *m_link1;
229 ConstraintsForceFeedback m_updaFeedbackCallback;
230 dgUnsigned32 m_dynamicsLru;
232 dgUnsigned32 m_index : 16;
233 dgUnsigned32 m_maxDOF : 6;
234 dgUnsigned32 m_constId : 6;
235 dgUnsigned32 m_enableCollision : 1;
236 dgUnsigned32 m_isUnilateral : 1;
246 } DG_GCC_VECTOR_ALIGMENT;
248 inline dgConstraint::dgConstraint() {
249 NEWTON_ASSERT((((dgUnsigned64)
this) & 15) == 0);
259 m_isUnilateral =
false;
260 m_enableCollision =
false;
261 m_constId = dgUnknownConstraintId;
262 m_updaFeedbackCallback = NULL;
265 inline dgConstraint::~dgConstraint() {
268 inline void dgConstraint::SetUpdateFeedbackFunction(ConstraintsForceFeedback
function) {
269 m_updaFeedbackCallback =
function;
272 inline bool dgConstraint::IsCollidable()
const {
273 return m_enableCollision ? true :
false;
276 inline void dgConstraint::SetCollidable(
bool state) {
277 m_enableCollision = dgUnsigned32(state);
280 inline dgUnsigned32 dgConstraint::GetId()
const {
284 inline dgBody *dgConstraint::GetBody0()
const {
288 inline dgBody *dgConstraint::GetBody1()
const {
292 inline dgBodyMasterListRow::dgListNode *dgConstraint::GetLink0()
const {
295 inline dgBodyMasterListRow::dgListNode *dgConstraint::GetLink1()
const {
300 inline dgFloat32 dgConstraint::GetStiffness()
const {
301 return dgFloat32(1.0f);
304 inline void dgConstraint::SetStiffness(dgFloat32 stiffness) {
307 inline dgInt32 dgConstraint::GetMaxDOF()
const {
308 return dgInt32(m_maxDOF);
311 #endif // !defined(AFX_DGCONSTRAINT_H__F9EC24E0_6E0F_4CD5_909E_A5F5E1AC7C0B__INCLUDED_) #define ARRAYSIZE(x)
Definition: util.h:91
Definition: dgWorldDynamicUpdate.h:143
Definition: dgBodyMasterList.h:56
Definition: dgWorldDynamicUpdate.h:282
Definition: dgVector.h:86
Definition: dgConstraint.h:137
Definition: dgWorldDynamicUpdate.h:203
Definition: dgConstraint.h:48
Definition: dgBroadPhaseCollision.h:158
Definition: dgWorldDynamicUpdate.h:342
Definition: dgConstraint.h:85
Definition: dgWorldDynamicUpdate.h:188
Definition: dgConstraint.h:103
Definition: dgConstraint.h:110
Definition: dgConstraint.h:191
Definition: dgConstraint.h:94
Definition: dgMatrix.h:41
Definition: dgConstraint.h:169
Definition: dgWorld.h:118
Definition: dgConstraint.h:116