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

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
21 #include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
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
36 class btGearConstraint : public btTypedConstraint
37 {
38 protected:
39 btVector3 m_axisInA;
40 btVector3 m_axisInB;
41 bool m_useFrameA;
42 btScalar m_ratio;
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 }
74 btScalar getRatio() const
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
107 struct btGearConstraintFloatData
108 {
109 btTypedConstraintFloatData m_typeConstraintData;
110
111 btVector3FloatData m_axisInA;
112 btVector3FloatData m_axisInB;
113
114 float m_ratio;
115 char m_padding[4];
116 };
117
118 struct btGearConstraintDoubleData
119 {
120 btTypedConstraintDoubleData m_typeConstraintData;
121
122 btVector3DoubleData m_axisInA;
123 btVector3DoubleData m_axisInB;
124
125 double m_ratio;
126 };
127
128 SIMD_FORCE_INLINE int btGearConstraint::calculateSerializeBufferSize() const
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
144 return btGearConstraintDataName;
145 }
146
147
148
149
150
151
152 #endif //BT_GEAR_CONSTRAINT_H
btGearConstraint::setParam
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...
Definition: btGearConstraint.h:80
btGearConstraintDoubleData::m_typeConstraintData
btTypedConstraintDoubleData m_typeConstraintData
Definition: btGearConstraint.h:120
btTypedConstraint::btConstraintInfo2
Definition: btTypedConstraint.h:126
btGearConstraint::getAxisB
const btVector3 & getAxisB() const
Definition: btGearConstraint.h:70
btGearConstraintFloatData::m_ratio
float m_ratio
Definition: btGearConstraint.h:114
btGearConstraint
The btGeatConstraint will couple the angular velocity for two bodies around given local axis and rati...
Definition: btGearConstraint.h:36
btGearConstraint::setRatio
void setRatio(btScalar ratio)
Definition: btGearConstraint.h:62
btAssert
#define btAssert(x)
Definition: btScalar.h:113
btGearConstraint::getInfo1
virtual void getInfo1(btConstraintInfo1 *info)
internal method used by the constraint solver, don&#39;t use them directly
Definition: btGearConstraint.cpp:32
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:63
btGearConstraintDataName
#define btGearConstraintDataName
Definition: btGearConstraint.h:29
btGearConstraintDoubleData::m_axisInB
btVector3DoubleData m_axisInB
Definition: btGearConstraint.h:123
btGearConstraint::getParam
virtual btScalar getParam(int num, int axis=-1) const
return the local value of parameter
Definition: btGearConstraint.h:89
btGearConstraintFloatData::m_axisInB
btVector3FloatData m_axisInB
Definition: btGearConstraint.h:112
btGearConstraint::setAxisA
void setAxisA(btVector3 &axisA)
Definition: btGearConstraint.h:54
btSerializer
Definition: btSerializer.h:68
btGearConstraint::m_useFrameA
bool m_useFrameA
Definition: btGearConstraint.h:41
btTypedConstraint.h
btGearConstraint::getInfo2
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don&#39;t use them directly
Definition: btGearConstraint.cpp:38
btGearConstraint::setAxisB
void setAxisB(btVector3 &axisB)
Definition: btGearConstraint.h:58
btGearConstraintData
#define btGearConstraintData
Definition: btGearConstraint.h:28
btGearConstraint::~btGearConstraint
virtual ~btGearConstraint()
Definition: btGearConstraint.cpp:28
btGearConstraintFloatData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btGearConstraint.h:107
btGearConstraintDoubleData
Definition: btGearConstraint.h:118
btVector3::serialize
void serialize(struct btVector3Data &dataOut) const
Definition: btVector3.h:1340
btTypedConstraintDoubleData
Definition: btTypedConstraint.h:421
btRigidBody
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:62
btGearConstraint::getRatio
btScalar getRatio() const
Definition: btGearConstraint.h:74
btGearConstraintFloatData::m_typeConstraintData
btTypedConstraintFloatData m_typeConstraintData
Definition: btGearConstraint.h:109
btGearConstraint::m_ratio
btScalar m_ratio
Definition: btGearConstraint.h:42
btGearConstraintDoubleData::m_axisInA
btVector3DoubleData m_axisInA
Definition: btGearConstraint.h:122
btGearConstraintFloatData::m_axisInA
btVector3FloatData m_axisInA
Definition: btGearConstraint.h:111
btGearConstraint::serialize
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Definition: btGearConstraint.h:134
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
btGearConstraint::getAxisA
const btVector3 & getAxisA() const
Definition: btGearConstraint.h:66
btTypedConstraint
TypedConstraint is the baseclass for Bullet constraints and vehicles.
Definition: btTypedConstraint.h:78
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:110
btGearConstraint::m_axisInA
btVector3 m_axisInA
Definition: btGearConstraint.h:39
btGearConstraintDoubleData::m_ratio
double m_ratio
Definition: btGearConstraint.h:125
btVector3FloatData
Definition: btVector3.h:1301
btGearConstraint::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition: btGearConstraint.h:128
btTypedConstraint::btConstraintInfo1
Definition: btTypedConstraint.h:120
btGearConstraint::btGearConstraint
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.
Definition: btGearConstraint.cpp:20
btTypedConstraintFloatData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 ...
Definition: btTypedConstraint.h:371
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:278
btVector3DoubleData
Definition: btVector3.h:1306
btGearConstraint::m_axisInB
btVector3 m_axisInB
Definition: btGearConstraint.h:40