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