Blender  V3.3
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 #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 {
33 protected:
38 
39 public:
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 
125 SIMD_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
btFixedConstraint btRigidBody & rbB
#define btGearConstraintData
#define btGearConstraintDataName
virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const
Data buffer MUST be 16 byte aligned.
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:280
#define btAssert(x)
Definition: btScalar.h:295
btTypedConstraint(btTypedConstraintType type, btRigidBody &rbA)
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
Definition: btVector3.h:82
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
virtual ~btGearConstraint()
virtual btScalar getParam(int num, int axis=-1) const
return the local value of parameter
virtual int calculateSerializeBufferSize() const
virtual void setParam(int num, btScalar value, int axis=-1)
const btVector3 & getAxisA() const
void setRatio(btScalar ratio)
void setAxisA(btVector3 &axisA)
void setAxisB(btVector3 &axisB)
const btVector3 & getAxisB() 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.
btScalar getRatio() const
SyclQueue void void size_t num_bytes void
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