Bullet Collision Detection & Physics Library
btGearConstraint.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2012 Advanced Micro Devices, Inc. http://bulletphysics.org
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 
17 
18 #ifndef BT_GEAR_CONSTRAINT_H
19 #define BT_GEAR_CONSTRAINT_H
20 
22 
23 
24 #ifdef BT_USE_DOUBLE_PRECISION
25 #define btGearConstraintData btGearConstraintDoubleData
26 #define btGearConstraintDataName "btGearConstraintDoubleData"
27 #else
28 #define btGearConstraintData btGearConstraintFloatData
29 #define btGearConstraintDataName "btGearConstraintFloatData"
30 #endif //BT_USE_DOUBLE_PRECISION
31 
32 
33 
37 {
38 protected:
43 
44 public:
45  btGearConstraint(btRigidBody& rbA, btRigidBody& rbB, const btVector3& axisInA,const btVector3& axisInB, btScalar ratio=1.f);
46  virtual ~btGearConstraint ();
47 
49  virtual void getInfo1 (btConstraintInfo1* info);
50 
52  virtual void getInfo2 (btConstraintInfo2* info);
53 
54  void setAxisA(btVector3& axisA)
55  {
56  m_axisInA = axisA;
57  }
58  void setAxisB(btVector3& axisB)
59  {
60  m_axisInB = axisB;
61  }
62  void setRatio(btScalar ratio)
63  {
64  m_ratio = ratio;
65  }
66  const btVector3& getAxisA() const
67  {
68  return m_axisInA;
69  }
70  const btVector3& getAxisB() const
71  {
72  return m_axisInB;
73  }
75  {
76  return m_ratio;
77  }
78 
79 
80  virtual void setParam(int num, btScalar value, int axis = -1)
81  {
82  (void) num;
83  (void) value;
84  (void) axis;
85  btAssert(0);
86  }
87 
89  virtual btScalar getParam(int num, int axis = -1) const
90  {
91  (void) num;
92  (void) axis;
93  btAssert(0);
94  return 0.f;
95  }
96 
97  virtual int calculateSerializeBufferSize() const;
98 
100  virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
101 };
102 
103 
104 
105 
108 {
110 
113 
114  float m_ratio;
115  char m_padding[4];
116 };
117 
119 {
121 
124 
125  double m_ratio;
126 };
127 
129 {
130  return sizeof(btGearConstraintData);
131 }
132 
134 SIMD_FORCE_INLINE const char* btGearConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
135 {
136  btGearConstraintData* gear = (btGearConstraintData*)dataBuffer;
137  btTypedConstraint::serialize(&gear->m_typeConstraintData,serializer);
138 
139  m_axisInA.serialize( gear->m_axisInA );
140  m_axisInB.serialize( gear->m_axisInB );
141 
142  gear->m_ratio = m_ratio;
143 
145 }
146 
147 
148 
149 
150 
151 
152 #endif //BT_GEAR_CONSTRAINT_H
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...
btTypedConstraintDoubleData m_typeConstraintData
const btVector3 & getAxisB() const
The btGeatConstraint will couple the angular velocity for two bodies around given local axis and rati...
void setRatio(btScalar ratio)
#define btAssert(x)
Definition: btScalar.h:101
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don't use them directly
#define SIMD_FORCE_INLINE
Definition: btScalar.h:58
#define btGearConstraintDataName
btVector3DoubleData m_axisInB
virtual btScalar getParam(int num, int axis=-1) const
return the local value of parameter
btVector3FloatData m_axisInB
void setAxisA(btVector3 &axisA)
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
void setAxisB(btVector3 &axisB)
#define btGearConstraintData
virtual ~btGearConstraint()
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
void serialize(struct btVector3Data &dataOut) const
Definition: btVector3.h:1339
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:59
btScalar getRatio() const
btTypedConstraintFloatData m_typeConstraintData
btVector3DoubleData m_axisInA
btVector3FloatData m_axisInA
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:83
const btVector3 & getAxisA() const
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)
virtual int calculateSerializeBufferSize() const
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.
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:266