Bullet Collision Detection & Physics Library
btPoint2PointConstraint.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
16 #ifndef BT_POINT2POINTCONSTRAINT_H
17 #define BT_POINT2POINTCONSTRAINT_H
18 
19 #include "LinearMath/btVector3.h"
20 #include "btJacobianEntry.h"
21 #include "btTypedConstraint.h"
22 
23 class btRigidBody;
24 
25 
26 #ifdef BT_USE_DOUBLE_PRECISION
27 #define btPoint2PointConstraintData btPoint2PointConstraintDoubleData
28 #define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData"
29 #else
30 #define btPoint2PointConstraintData btPoint2PointConstraintFloatData
31 #define btPoint2PointConstraintDataName "btPoint2PointConstraintFloatData"
32 #endif //BT_USE_DOUBLE_PRECISION
33 
35 {
37  m_tau(btScalar(0.3)),
38  m_damping(btScalar(1.)),
40  {
41  }
45 };
46 
48 {
51 };
52 
55 {
56 #ifdef IN_PARALLELL_SOLVER
57 public:
58 #endif
59  btJacobianEntry m_jac[3]; //3 orthogonal linear constraints
60 
63 
64  int m_flags;
67 
68 public:
69 
71 
74 
76 
77  btPoint2PointConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB);
78 
79  btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA);
80 
81 
82  virtual void buildJacobian();
83 
84  virtual void getInfo1 (btConstraintInfo1* info);
85 
86  void getInfo1NonVirtual (btConstraintInfo1* info);
87 
88  virtual void getInfo2 (btConstraintInfo2* info);
89 
90  void getInfo2NonVirtual (btConstraintInfo2* info, const btTransform& body0_trans, const btTransform& body1_trans);
91 
92  void updateRHS(btScalar timeStep);
93 
94  void setPivotA(const btVector3& pivotA)
95  {
96  m_pivotInA = pivotA;
97  }
98 
99  void setPivotB(const btVector3& pivotB)
100  {
101  m_pivotInB = pivotB;
102  }
103 
104  const btVector3& getPivotInA() const
105  {
106  return m_pivotInA;
107  }
108 
109  const btVector3& getPivotInB() const
110  {
111  return m_pivotInB;
112  }
113 
116  virtual void setParam(int num, btScalar value, int axis = -1);
118  virtual btScalar getParam(int num, int axis = -1) const;
119 
120  virtual int calculateSerializeBufferSize() const;
121 
123  virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
124 
125 
126 };
127 
130 {
134 };
135 
138 {
142 };
143 
144 
146 {
147  return sizeof(btPoint2PointConstraintData);
148 
149 }
150 
152 SIMD_FORCE_INLINE const char* btPoint2PointConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
153 {
155 
156  btTypedConstraint::serialize(&p2pData->m_typeConstraintData,serializer);
157  m_pivotInA.serialize(p2pData->m_pivotInA);
158  m_pivotInB.serialize(p2pData->m_pivotInB);
159 
161 }
162 
163 #endif //BT_POINT2POINTCONSTRAINT_H