ScummVM API documentation
dgBilateralConstraint.h
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 #if !defined(AFX_DGBILATERALCONSTRAINT_H__7C9E1F9A_5EC6_48BE_8C9F_FB90132C6619__INCLUDED_)
23 #define AFX_DGBILATERALCONSTRAINT_H__7C9E1F9A_5EC6_48BE_8C9F_FB90132C6619__INCLUDED_
24 
25 #include "dgConstraint.h"
26 
27 
29 
30 public:
31  virtual void SetDestructorCallback(OnConstraintDestroy destructor);
32 
33 protected:
35  virtual ~dgBilateralConstraint();
36 
37  virtual void Init() {
38  NEWTON_ASSERT(0);
39  }
40  virtual void Remove(dgWorld *world) {
41  NEWTON_ASSERT(0);
42  }
43  virtual bool IsBilateral() const;
44 
45  virtual dgFloat32 GetStiffness() const;
46  virtual void SetStiffness(dgFloat32 stiffness);
47 
48  void SetPivotAndPinDir(const dgVector &pivot, const dgVector &pinDirection);
49  void SetPivotAndPinDir(const dgVector &pivot, const dgVector &pinDirection0, const dgVector &pinDirection1);
50  dgVector CalculateGlobalMatrixAndAngle(dgMatrix &globalMatrix0, dgMatrix &globalMatrix1) const;
51  void CalculateMatrixOffset(const dgVector &pivot, const dgVector &dir, dgMatrix &matrix0, dgMatrix &matrix1);
52 
53 
54  virtual void JointAccelerations(const dgJointAccelerationDecriptor &params);
55  virtual void JointAccelerationsSimd(const dgJointAccelerationDecriptor &params);
56  virtual void JointVelocityCorrection(const dgJointAccelerationDecriptor &params);
57 
58 
59  void SetMotorAcceleration(dgInt32 index, dgFloat32 accelration, dgContraintDescritor &desc);
60  void SetJacobianDerivative(dgInt32 index, dgContraintDescritor &desc, const dgFloat32 *jacobianA, const dgFloat32 *jacobianB, dgFloat32 *jointForce);
61  void CalculatePointDerivative(dgInt32 index, dgContraintDescritor &desc, const dgVector &normalGlobal, const dgPointParam &param, dgFloat32 *jointForce);
62  void CalculateAngularDerivative(dgInt32 index, dgContraintDescritor &desc, const dgVector &normalGlobal, dgFloat32 stiffness, dgFloat32 jointAngle, dgFloat32 *jointForce);
63  dgFloat32 CalculateSpringDamperAcceleration(dgInt32 index, const dgContraintDescritor &desc, dgFloat32 jointAngle, const dgVector &p0Global, const dgVector &p1Global, dgFloat32 springK, dgFloat32 springD);
64 
65 
66  dgMatrix m_localMatrix0;
67  dgMatrix m_localMatrix1;
68  dgFloat32 m_stiffness;
69  dgFloat32 m_jointForce[32];
70  dgInt32 m_rowIsMotor[32];
71  dgFloat32 m_motorAcceleration[32];
72 
73 
74  OnConstraintDestroy m_destructor;
75 };
76 
77 #endif // !defined(AFX_DGBILATERALCONSTRAINT_H__7C9E1F9A_5EC6_48BE_8C9F_FB90132C6619__INCLUDED_)
78 
Definition: dgVector.h:86
Definition: dgConstraint.h:137
Definition: dgBilateralConstraint.h:28
Definition: dgConstraint.h:191
Definition: dgMatrix.h:41
Definition: dgConstraint.h:169
Definition: dgWorld.h:118
Definition: dgConstraint.h:116