Bullet Collision Detection & Physics Library: btPoint2PointConstraint.h Source File

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 btPoint2PointConstraintData2 btPoint2PointConstraintDoubleData2
28 #define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData2"
29 #else
30 #define btPoint2PointConstraintData2 btPoint2PointConstraintFloatData
31 #define btPoint2PointConstraintDataName "btPoint2PointConstraintFloatData"
32 #endif //BT_USE_DOUBLE_PRECISION
33
34 struct btConstraintSetting
35 {
36 btConstraintSetting() :
37 m_tau(btScalar(0.3)),
38 m_damping(btScalar(1.)),
39 m_impulseClamp(btScalar(0.))
40 {
41 }
42 btScalar m_tau;
43 btScalar m_damping;
44 btScalar m_impulseClamp;
45 };
46
47 enum btPoint2PointFlags
48 {
49 BT_P2P_FLAGS_ERP = 1,
50 BT_P2P_FLAGS_CFM = 2
51 };
52
54 ATTRIBUTE_ALIGNED16(class) btPoint2PointConstraint : public btTypedConstraint
55 {
56 #ifdef IN_PARALLELL_SOLVER
57 public:
58 #endif
59 btJacobianEntry m_jac[3]; //3 orthogonal linear constraints
60
61 btVector3 m_pivotInA;
62 btVector3 m_pivotInB;
63
64 int m_flags;
65 btScalar m_erp;
66 btScalar m_cfm;
67
68 public:
69
70 BT_DECLARE_ALIGNED_ALLOCATOR();
71
73 bool m_useSolveConstraintObsolete;
74
75 btConstraintSetting m_setting;
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 getFlags() const
121 {
122 return m_flags;
123 }
124
125 virtual int calculateSerializeBufferSize() const;
126
128 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
129
130
131 };
132
134 struct btPoint2PointConstraintFloatData
135 {
136 btTypedConstraintData m_typeConstraintData;
137 btVector3FloatData m_pivotInA;
138 btVector3FloatData m_pivotInB;
139 };
140
142 struct btPoint2PointConstraintDoubleData2
143 {
144 btTypedConstraintDoubleData m_typeConstraintData;
145 btVector3DoubleData m_pivotInA;
146 btVector3DoubleData m_pivotInB;
147 };
148
149 #ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION
150 struct btPoint2PointConstraintDoubleData
154 {
155 btTypedConstraintData m_typeConstraintData;
156 btVector3DoubleData m_pivotInA;
157 btVector3DoubleData m_pivotInB;
158 };
159 #endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION
160
161
162 SIMD_FORCE_INLINE int btPoint2PointConstraint::calculateSerializeBufferSize() const
163 {
164 return sizeof(btPoint2PointConstraintData2);
165
166 }
167
169 SIMD_FORCE_INLINE const char* btPoint2PointConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
170 {
171 btPoint2PointConstraintData2* p2pData = (btPoint2PointConstraintData2*)dataBuffer;
172
173 btTypedConstraint::serialize(&p2pData->m_typeConstraintData,serializer);
174 m_pivotInA.serialize(p2pData->m_pivotInA);
175 m_pivotInB.serialize(p2pData->m_pivotInB);
176
177 return btPoint2PointConstraintDataName;
178 }
179
180 #endif //BT_POINT2POINTCONSTRAINT_H
btPoint2PointConstraint::m_pivotInB
btVector3 m_pivotInB
Definition: btPoint2PointConstraint.h:62
btPoint2PointConstraintDoubleData::m_pivotInA
btVector3DoubleData m_pivotInA
Definition: btPoint2PointConstraint.h:156
btPoint2PointFlags
btPoint2PointFlags
Definition: btPoint2PointConstraint.h:47
btPoint2PointConstraint::m_setting
btConstraintSetting m_setting
Definition: btPoint2PointConstraint.h:75
btPoint2PointConstraint
point to point constraint between two rigidbodies each with a pivotpoint that descibes the &#39;ballsocke...
Definition: btPoint2PointConstraint.h:54
BT_P2P_FLAGS_ERP
Definition: btPoint2PointConstraint.h:49
btConstraintSetting::btConstraintSetting
btConstraintSetting()
Definition: btPoint2PointConstraint.h:36
btPoint2PointConstraint::getPivotInA
const btVector3 & getPivotInA() const
Definition: btPoint2PointConstraint.h:104
btJacobianEntry
Jacobian entry is an abstraction that allows to describe constraints it can be used in combination wi...
Definition: btJacobianEntry.h:30
btTypedConstraint::btConstraintInfo2
Definition: btTypedConstraint.h:126
btPoint2PointConstraintDoubleData2::m_typeConstraintData
btTypedConstraintDoubleData m_typeConstraintData
Definition: btPoint2PointConstraint.h:144
btVector3.h
btPoint2PointConstraint::getPivotInB
const btVector3 & getPivotInB() const
Definition: btPoint2PointConstraint.h:109
btPoint2PointConstraintDoubleData::m_typeConstraintData
btTypedConstraintData m_typeConstraintData
Definition: btPoint2PointConstraint.h:155
btPoint2PointConstraint::m_useSolveConstraintObsolete
bool m_useSolveConstraintObsolete
for backwards compatibility during the transition to &#39;getInfo/getInfo2&#39;
Definition: btPoint2PointConstraint.h:73
btConstraintSetting::m_impulseClamp
btScalar m_impulseClamp
Definition: btPoint2PointConstraint.h:44
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:81
btPoint2PointConstraintFloatData::m_pivotInA
btVector3FloatData m_pivotInA
Definition: btPoint2PointConstraint.h:137
btPoint2PointConstraint::m_flags
int m_flags
Definition: btPoint2PointConstraint.h:64
btSerializer
Definition: btSerializer.h:68
btPoint2PointConstraint::setPivotB
void setPivotB(const btVector3 &pivotB)
Definition: btPoint2PointConstraint.h:99
btPoint2PointConstraintFloatData::m_typeConstraintData
btTypedConstraintData m_typeConstraintData
Definition: btPoint2PointConstraint.h:136
btPoint2PointConstraintDoubleData2
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btPoint2PointConstraint.h:142
btTypedConstraint.h
btPoint2PointConstraintDoubleData2::m_pivotInA
btVector3DoubleData m_pivotInA
Definition: btPoint2PointConstraint.h:145
btConstraintSetting
Definition: btPoint2PointConstraint.h:34
btPoint2PointConstraintFloatData::m_pivotInB
btVector3FloatData m_pivotInB
Definition: btPoint2PointConstraint.h:138
btTypedConstraintDoubleData
Definition: btTypedConstraint.h:416
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:62
btTypedConstraintData
this structure is not used, except for loading pre-2.82 .bullet files
Definition: btTypedConstraint.h:393
btConstraintSetting::m_tau
btScalar m_tau
Definition: btPoint2PointConstraint.h:42
btJacobianEntry.h
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:82
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
btVector3::serialize
void serialize(struct btVector3Data &dataOut) const
Definition: btVector3.h:1351
btPoint2PointConstraintData2
#define btPoint2PointConstraintData2
Definition: btPoint2PointConstraint.h:30
btPoint2PointConstraint::serialize
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btPoint2PointConstraint.h:169
btTypedConstraint::serialize
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btTypedConstraint.cpp:110
btPoint2PointConstraint::m_cfm
btScalar m_cfm
Definition: btPoint2PointConstraint.h:66
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:78
btPoint2PointConstraint::m_pivotInA
btVector3 m_pivotInA
Definition: btPoint2PointConstraint.h:61
btConstraintSetting::m_damping
btScalar m_damping
Definition: btPoint2PointConstraint.h:43
btPoint2PointConstraintDoubleData::m_pivotInB
btVector3DoubleData m_pivotInB
Definition: btPoint2PointConstraint.h:157
BT_DECLARE_ALIGNED_ALLOCATOR
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:403
btPoint2PointConstraint::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btPoint2PointConstraint.h:162
btPoint2PointConstraint::setPivotA
void setPivotA(const btVector3 &pivotA)
Definition: btPoint2PointConstraint.h:94
btPoint2PointConstraint::getFlags
virtual int getFlags() const
Definition: btPoint2PointConstraint.h:120
btVector3FloatData
Definition: btVector3.h:1312
BT_P2P_FLAGS_CFM
Definition: btPoint2PointConstraint.h:50
btPoint2PointConstraintDoubleData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 th...
Definition: btPoint2PointConstraint.h:153
btTypedConstraint::btConstraintInfo1
Definition: btTypedConstraint.h:120
btPoint2PointConstraintFloatData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btPoint2PointConstraint.h:134
btPoint2PointConstraintDataName
#define btPoint2PointConstraintDataName
Definition: btPoint2PointConstraint.h:31
btPoint2PointConstraint::m_erp
btScalar m_erp
Definition: btPoint2PointConstraint.h:65
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
btVector3DoubleData
Definition: btVector3.h:1317
btPoint2PointConstraintDoubleData2::m_pivotInB
btVector3DoubleData m_pivotInB
Definition: btPoint2PointConstraint.h:146