Bullet Collision Detection & Physics Library
btGearConstraint.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2012 Advanced Micro Devices, Inc. http://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_GEAR_CONSTRAINT_H
17#define BT_GEAR_CONSTRAINT_H
18
20
21#ifdef BT_USE_DOUBLE_PRECISION
22#define btGearConstraintData btGearConstraintDoubleData
23#define btGearConstraintDataName "btGearConstraintDoubleData"
24#else
25#define btGearConstraintData btGearConstraintFloatData
26#define btGearConstraintDataName "btGearConstraintFloatData"
27#endif //BT_USE_DOUBLE_PRECISION
28
32{
33protected:
38
39public:
40 btGearConstraint(btRigidBody& rbA, btRigidBody& rbB, const btVector3& axisInA, const btVector3& axisInB, btScalar ratio = 1.f);
41 virtual ~btGearConstraint();
42
44 virtual void getInfo1(btConstraintInfo1* info);
45
47 virtual void getInfo2(btConstraintInfo2* info);
48
49 void setAxisA(btVector3& axisA)
50 {
51 m_axisInA = axisA;
52 }
53 void setAxisB(btVector3& axisB)
54 {
55 m_axisInB = axisB;
56 }
57 void setRatio(btScalar ratio)
58 {
59 m_ratio = ratio;
60 }
61 const btVector3& getAxisA() const
62 {
63 return m_axisInA;
64 }
65 const btVector3& getAxisB() const
66 {
67 return m_axisInB;
68 }
70 {
71 return m_ratio;
72 }
73
74 virtual void setParam(int num, btScalar value, int axis = -1)
75 {
76 (void)num;
77 (void)value;
78 (void)axis;
79 btAssert(0);
80 }
81
83 virtual btScalar getParam(int num, int axis = -1) const
84 {
85 (void)num;
86 (void)axis;
87 btAssert(0);
88 return 0.f;
89 }
90
91 virtual int calculateSerializeBufferSize() const;
92
94 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
95};
96
99{
101
104
105 float m_ratio;
106 char m_padding[4];
107};
108
110{
112
115
116 double m_ratio;
117};
118
120{
121 return sizeof(btGearConstraintData);
122}
123
125SIMD_FORCE_INLINE const char* btGearConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
126{
127 btGearConstraintData* gear = (btGearConstraintData*)dataBuffer;
128 btTypedConstraint::serialize(&gear->m_typeConstraintData, serializer);
129
130 m_axisInA.serialize(gear->m_axisInA);
131 m_axisInB.serialize(gear->m_axisInB);
132
133 gear->m_ratio = m_ratio;
134
135 // Fill padding with zeros to appease msan.
136#ifndef BT_USE_DOUBLE_PRECISION
137 gear->m_padding[0] = 0;
138 gear->m_padding[1] = 0;
139 gear->m_padding[2] = 0;
140 gear->m_padding[3] = 0;
141#endif
142
144}
145
146#endif //BT_GEAR_CONSTRAINT_H
#define btGearConstraintData
#define btGearConstraintDataName
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define SIMD_FORCE_INLINE
Definition: btScalar.h:98
#define btAssert(x)
Definition: btScalar.h:153
The btGeatConstraint will couple the angular velocity for two bodies around given local axis and rati...
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
virtual ~btGearConstraint()
const btVector3 & getAxisB() const
virtual btScalar getParam(int num, int axis=-1) const
return the local value of parameter
virtual void setParam(int num, btScalar value, int axis=-1)
override the default global value of a parameter (such as ERP or CFM), optionally provide the axis (0...
void setRatio(btScalar ratio)
void setAxisA(btVector3 &axisA)
void setAxisB(btVector3 &axisB)
virtual int calculateSerializeBufferSize() const
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don't use them directly
btGearConstraint(btRigidBody &rbA, btRigidBody &rbB, const btVector3 &axisInA, const btVector3 &axisInB, btScalar ratio=1.f)
Implemented by Erwin Coumans. The idea for the constraint comes from Dimitris Papavasiliou.
const btVector3 & getAxisA() const
btScalar getRatio() const
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:60
TypedConstraint is the baseclass for Bullet constraints and vehicles.
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
void serialize(struct btVector3Data &dataOut) const
Definition: btVector3.h:1317
btVector3DoubleData m_axisInA
btTypedConstraintDoubleData m_typeConstraintData
btVector3DoubleData m_axisInB
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
btTypedConstraintFloatData m_typeConstraintData
btVector3FloatData m_axisInB
btVector3FloatData m_axisInA
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64