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

Bullet Collision Detection & Physics Library

btPoint2PointConstraint.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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
23class btRigidBody;
24
25#ifdef BT_USE_DOUBLE_PRECISION
26#define btPoint2PointConstraintData2 btPoint2PointConstraintDoubleData2
27#define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData2"
28#else
29#define btPoint2PointConstraintData2 btPoint2PointConstraintFloatData
30#define btPoint2PointConstraintDataName "btPoint2PointConstraintFloatData"
31#endif //BT_USE_DOUBLE_PRECISION
32
33 struct btConstraintSetting
34{
35 btConstraintSetting() : m_tau(btScalar(0.3)),
36 m_damping(btScalar(1.)),
37 m_impulseClamp(btScalar(0.))
38 {
39 }
40 btScalar m_tau;
41 btScalar m_damping;
42 btScalar m_impulseClamp;
43};
44
45 enum btPoint2PointFlags
46{
47 BT_P2P_FLAGS_ERP = 1,
48 BT_P2P_FLAGS_CFM = 2
49};
50
52 ATTRIBUTE_ALIGNED16(class)
53 btPoint2PointConstraint : public btTypedConstraint
54{
55#ifdef IN_PARALLELL_SOLVER
56public:
57#endif
58 btJacobianEntry m_jac[3]; //3 orthogonal linear constraints
59
60 btVector3 m_pivotInA;
61 btVector3 m_pivotInB;
62
63 int m_flags;
64 btScalar m_erp;
65 btScalar m_cfm;
66
67public:
68 BT_DECLARE_ALIGNED_ALLOCATOR();
69
71 bool m_useSolveConstraintObsolete;
72
73 btConstraintSetting m_setting;
74
75 btPoint2PointConstraint(btRigidBody & rbA, btRigidBody & rbB, const btVector3& pivotInA, const btVector3& pivotInB);
76
77 btPoint2PointConstraint(btRigidBody & rbA, const btVector3& pivotInA);
78
79 virtual void buildJacobian();
80
81 virtual void getInfo1(btConstraintInfo1 * info);
82
83 void getInfo1NonVirtual(btConstraintInfo1 * info);
84
85 virtual void getInfo2(btConstraintInfo2 * info);
86
87 void getInfo2NonVirtual(btConstraintInfo2 * info, const btTransform& body0_trans, const btTransform& body1_trans);
88
89 void updateRHS(btScalar timeStep);
90
91 void setPivotA(const btVector3& pivotA)
92 {
93 m_pivotInA = pivotA;
94 }
95
96 void setPivotB(const btVector3& pivotB)
97 {
98 m_pivotInB = pivotB;
99 }
100
101 const btVector3& getPivotInA() const
102 {
103 return m_pivotInA;
104 }
105
106 const btVector3& getPivotInB() const
107 {
108 return m_pivotInB;
109 }
110
113 virtual void setParam(int num, btScalar value, int axis = -1);
115 virtual btScalar getParam(int num, int axis = -1) const;
116
117 virtual int getFlags() const
118 {
119 return m_flags;
120 }
121
122 virtual int calculateSerializeBufferSize() const;
123
125 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
126};
127
129 struct btPoint2PointConstraintFloatData
130{
131 btTypedConstraintData m_typeConstraintData;
132 btVector3FloatData m_pivotInA;
133 btVector3FloatData m_pivotInB;
134};
135
137 struct btPoint2PointConstraintDoubleData2
138{
139 btTypedConstraintDoubleData m_typeConstraintData;
140 btVector3DoubleData m_pivotInA;
141 btVector3DoubleData m_pivotInB;
142};
143
144#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION
148 struct btPoint2PointConstraintDoubleData
149{
150 btTypedConstraintData m_typeConstraintData;
151 btVector3DoubleData m_pivotInA;
152 btVector3DoubleData m_pivotInB;
153};
154#endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION
155
156 SIMD_FORCE_INLINE int btPoint2PointConstraint::calculateSerializeBufferSize() const
157{
158 return sizeof(btPoint2PointConstraintData2);
159}
160
162 SIMD_FORCE_INLINE const char* btPoint2PointConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
163{
164 btPoint2PointConstraintData2* p2pData = (btPoint2PointConstraintData2*)dataBuffer;
165
166 btTypedConstraint::serialize(&p2pData->m_typeConstraintData, serializer);
167 m_pivotInA.serialize(p2pData->m_pivotInA);
168 m_pivotInB.serialize(p2pData->m_pivotInB);
169
170 return btPoint2PointConstraintDataName;
171}
172
173#endif //BT_POINT2POINTCONSTRAINT_H
btJacobianEntry.h
btPoint2PointConstraintData2
#define btPoint2PointConstraintData2
Definition btPoint2PointConstraint.h:29
btPoint2PointFlags
btPoint2PointFlags
Definition btPoint2PointConstraint.h:46
BT_P2P_FLAGS_CFM
@ BT_P2P_FLAGS_CFM
Definition btPoint2PointConstraint.h:48
BT_P2P_FLAGS_ERP
@ BT_P2P_FLAGS_ERP
Definition btPoint2PointConstraint.h:47
btPoint2PointConstraintDataName
#define btPoint2PointConstraintDataName
Definition btPoint2PointConstraint.h:30
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition btScalar.h:99
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition btScalar.h:98
btTypedConstraint.h
btVector3.h
btJacobianEntry
Jacobian entry is an abstraction that allows to describe constraints it can be used in combination wi...
Definition btJacobianEntry.h:31
btPoint2PointConstraint::btPoint2PointConstraint
btPoint2PointConstraint(btRigidBody &rbA, btRigidBody &rbB, const btVector3 &pivotInA, const btVector3 &pivotInB)
Definition btPoint2PointConstraint.cpp:20
btPoint2PointConstraint::setPivotB
void setPivotB(const btVector3 &pivotB)
Definition btPoint2PointConstraint.h:96
btPoint2PointConstraint::buildJacobian
virtual void buildJacobian()
internal method used by the constraint solver, don't use them directly
Definition btPoint2PointConstraint.cpp:30
btPoint2PointConstraint::getInfo1
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don't use them directly
Definition btPoint2PointConstraint.cpp:56
btPoint2PointConstraint::m_flags
int m_flags
Definition btPoint2PointConstraint.h:63
btPoint2PointConstraint::getInfo1NonVirtual
void getInfo1NonVirtual(btConstraintInfo1 *info)
Definition btPoint2PointConstraint.cpp:61
btPoint2PointConstraint::updateRHS
void updateRHS(btScalar timeStep)
Definition btPoint2PointConstraint.cpp:145
btPoint2PointConstraint::m_cfm
btScalar m_cfm
Definition btPoint2PointConstraint.h:65
btPoint2PointConstraint::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition btPoint2PointConstraint.h:156
btPoint2PointConstraint::getFlags
virtual int getFlags() const
Definition btPoint2PointConstraint.h:117
btPoint2PointConstraint::getInfo2NonVirtual
void getInfo2NonVirtual(btConstraintInfo2 *info, const btTransform &body0_trans, const btTransform &body1_trans)
Definition btPoint2PointConstraint.cpp:80
btPoint2PointConstraint::getPivotInB
const btVector3 & getPivotInB() const
Definition btPoint2PointConstraint.h:106
btPoint2PointConstraint::setPivotA
void setPivotA(const btVector3 &pivotA)
Definition btPoint2PointConstraint.h:91
btPoint2PointConstraint::BT_DECLARE_ALIGNED_ALLOCATOR
BT_DECLARE_ALIGNED_ALLOCATOR()
btPoint2PointConstraint::m_pivotInA
btVector3 m_pivotInA
Definition btPoint2PointConstraint.h:60
btPoint2PointConstraint::m_pivotInB
btVector3 m_pivotInB
Definition btPoint2PointConstraint.h:61
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:162
btPoint2PointConstraint::m_useSolveConstraintObsolete
bool m_useSolveConstraintObsolete
for backwards compatibility during the transition to 'getInfo/getInfo2'
Definition btPoint2PointConstraint.h:71
btPoint2PointConstraint::m_jac
btJacobianEntry m_jac[3]
Definition btPoint2PointConstraint.h:58
btPoint2PointConstraint::getPivotInA
const btVector3 & getPivotInA() const
Definition btPoint2PointConstraint.h:101
btPoint2PointConstraint::m_setting
btConstraintSetting m_setting
Definition btPoint2PointConstraint.h:73
btPoint2PointConstraint::getInfo2
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
Definition btPoint2PointConstraint.cpp:75
btPoint2PointConstraint::m_erp
btScalar m_erp
Definition btPoint2PointConstraint.h:64
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition btRigidBody.h:60
btSerializer
Definition btSerializer.h:66
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition btTransform.h:30
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:104
btTypedConstraint::btTypedConstraint
btTypedConstraint(btTypedConstraintType type, btRigidBody &rbA)
Definition btTypedConstraint.cpp:22
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:82
btConstraintSetting
Definition btPoint2PointConstraint.h:34
btConstraintSetting::m_impulseClamp
btScalar m_impulseClamp
Definition btPoint2PointConstraint.h:42
btConstraintSetting::m_tau
btScalar m_tau
Definition btPoint2PointConstraint.h:40
btConstraintSetting::btConstraintSetting
btConstraintSetting()
Definition btPoint2PointConstraint.h:35
btConstraintSetting::m_damping
btScalar m_damping
Definition btPoint2PointConstraint.h:41
btPoint2PointConstraintDoubleData2
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition btPoint2PointConstraint.h:138
btPoint2PointConstraintDoubleData2::m_pivotInB
btVector3DoubleData m_pivotInB
Definition btPoint2PointConstraint.h:141
btPoint2PointConstraintDoubleData2::m_typeConstraintData
btTypedConstraintDoubleData m_typeConstraintData
Definition btPoint2PointConstraint.h:139
btPoint2PointConstraintDoubleData2::m_pivotInA
btVector3DoubleData m_pivotInA
Definition btPoint2PointConstraint.h:140
btPoint2PointConstraintDoubleData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 th...
Definition btPoint2PointConstraint.h:149
btPoint2PointConstraintDoubleData::m_typeConstraintData
btTypedConstraintData m_typeConstraintData
Definition btPoint2PointConstraint.h:150
btPoint2PointConstraintDoubleData::m_pivotInA
btVector3DoubleData m_pivotInA
Definition btPoint2PointConstraint.h:151
btPoint2PointConstraintDoubleData::m_pivotInB
btVector3DoubleData m_pivotInB
Definition btPoint2PointConstraint.h:152
btPoint2PointConstraintFloatData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition btPoint2PointConstraint.h:130
btPoint2PointConstraintFloatData::m_typeConstraintData
btTypedConstraintData m_typeConstraintData
Definition btPoint2PointConstraint.h:131
btPoint2PointConstraintFloatData::m_pivotInB
btVector3FloatData m_pivotInB
Definition btPoint2PointConstraint.h:133
btPoint2PointConstraintFloatData::m_pivotInA
btVector3FloatData m_pivotInA
Definition btPoint2PointConstraint.h:132
btTypedConstraintData
this structure is not used, except for loading pre-2.82 .bullet files
Definition btTypedConstraint.h:388
btTypedConstraintDoubleData
Definition btTypedConstraint.h:411
btTypedConstraint::btConstraintInfo1
Definition btTypedConstraint.h:114
btTypedConstraint::btConstraintInfo2
Definition btTypedConstraint.h:121
btVector3DoubleData
Definition btVector3.h:1287
btVector3FloatData
Definition btVector3.h:1282