Main Page
Namespaces
Classes
Files
File List
File Members
externals
Box2D
Box2D
Dynamics
Joints
b2Joint.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006-2007 Erin Catto http://www.box2d.org
3
*
4
* This software is provided 'as-is', without any express or implied
5
* warranty. In no event will the authors be held liable for any damages
6
* 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
9
* freely, subject to the following restrictions:
10
* 1. The origin of this software must not be misrepresented; you must not
11
* claim that you wrote the original software. If you use this software
12
* in a product, an acknowledgment in the product documentation would be
13
* appreciated but is not required.
14
* 2. Altered source versions must be plainly marked as such, and must not be
15
* misrepresented as being the original software.
16
* 3. This notice may not be removed or altered from any source distribution.
17
*/
18
19
#ifndef B2_JOINT_H
20
#define B2_JOINT_H
21
22
#include <
Box2D/Common/b2Math.h
>
23
24
class
b2Body
;
25
class
b2Joint
;
26
struct
b2SolverData
;
27
class
b2BlockAllocator
;
28
29
enum
b2JointType
30
{
31
e_unknownJoint
,
32
e_revoluteJoint
,
33
e_prismaticJoint
,
34
e_distanceJoint
,
35
e_pulleyJoint
,
36
e_mouseJoint
,
37
e_gearJoint
,
38
e_wheelJoint
,
39
e_weldJoint
,
40
e_frictionJoint
,
41
e_ropeJoint
,
42
e_motorJoint
43
};
44
45
enum
b2LimitState
46
{
47
e_inactiveLimit
,
48
e_atLowerLimit
,
49
e_atUpperLimit
,
50
e_equalLimits
51
};
52
53
struct
b2Jacobian
54
{
55
b2Vec2
linear
;
56
float32
angularA
;
57
float32
angularB
;
58
};
59
65
struct
b2JointEdge
66
{
67
b2Body
*
other
;
68
b2Joint
*
joint
;
69
b2JointEdge
*
prev
;
70
b2JointEdge
*
next
;
71
};
72
74
struct
b2JointDef
75
{
76
b2JointDef
()
77
{
78
type =
e_unknownJoint
;
79
userData = NULL;
80
bodyA = NULL;
81
bodyB = NULL;
82
collideConnected =
false
;
83
}
84
86
b2JointType
type
;
87
89
void
*
userData
;
90
92
b2Body
*
bodyA
;
93
95
b2Body
*
bodyB
;
96
98
bool
collideConnected
;
99
};
100
103
class
b2Joint
104
{
105
public
:
106
108
b2JointType
GetType()
const
;
109
111
b2Body
* GetBodyA();
112
114
b2Body
* GetBodyB();
115
117
virtual
b2Vec2
GetAnchorA()
const
= 0;
118
120
virtual
b2Vec2
GetAnchorB()
const
= 0;
121
123
virtual
b2Vec2
GetReactionForce(
float32
inv_dt)
const
= 0;
124
126
virtual
float32
GetReactionTorque(
float32
inv_dt)
const
= 0;
127
129
b2Joint
* GetNext();
130
const
b2Joint
* GetNext()
const
;
131
133
void
* GetUserData()
const
;
134
136
void
SetUserData(
void
* data);
137
139
bool
IsActive()
const
;
140
144
bool
GetCollideConnected()
const
;
145
147
virtual
void
Dump
() {
b2Log
(
"// Dump is not supported for this joint type.\n"
); }
148
150
virtual
void
ShiftOrigin
(
const
b2Vec2
& newOrigin) {
B2_NOT_USED
(newOrigin); }
151
152
protected
:
153
friend
class
b2World
;
154
friend
class
b2Body
;
155
friend
class
b2Island
;
156
friend
class
b2GearJoint
;
157
158
static
b2Joint
*
Create
(
const
b2JointDef
* def,
b2BlockAllocator
* allocator);
159
static
void
Destroy
(
b2Joint
* joint,
b2BlockAllocator
* allocator);
160
161
b2Joint
(
const
b2JointDef
* def);
162
virtual
~b2Joint
() {}
163
164
virtual
void
InitVelocityConstraints
(
const
b2SolverData
& data) = 0;
165
virtual
void
SolveVelocityConstraints
(
const
b2SolverData
& data) = 0;
166
167
// This returns true if the position errors are within tolerance.
168
virtual
bool
SolvePositionConstraints
(
const
b2SolverData
& data) = 0;
169
170
b2JointType
m_type
;
171
b2Joint
*
m_prev
;
172
b2Joint
*
m_next
;
173
b2JointEdge
m_edgeA
;
174
b2JointEdge
m_edgeB
;
175
b2Body
*
m_bodyA
;
176
b2Body
*
m_bodyB
;
177
178
int32
m_index
;
179
180
bool
m_islandFlag
;
181
bool
m_collideConnected
;
182
183
void
*
m_userData
;
184
};
185
186
inline
b2JointType
b2Joint::GetType
()
const
187
{
188
return
m_type
;
189
}
190
191
inline
b2Body
*
b2Joint::GetBodyA
()
192
{
193
return
m_bodyA
;
194
}
195
196
inline
b2Body
*
b2Joint::GetBodyB
()
197
{
198
return
m_bodyB
;
199
}
200
201
inline
b2Joint
*
b2Joint::GetNext
()
202
{
203
return
m_next
;
204
}
205
206
inline
const
b2Joint
*
b2Joint::GetNext
()
const
207
{
208
return
m_next
;
209
}
210
211
inline
void
*
b2Joint::GetUserData
()
const
212
{
213
return
m_userData
;
214
}
215
216
inline
void
b2Joint::SetUserData
(
void
* data)
217
{
218
m_userData
= data;
219
}
220
221
inline
bool
b2Joint::GetCollideConnected
()
const
222
{
223
return
m_collideConnected
;
224
}
225
226
#endif
e_atLowerLimit
Definition:
b2Joint.h:48
b2Island
This is an internal class.
Definition:
b2Island.h:34
e_gearJoint
Definition:
b2Joint.h:37
b2Log
void b2Log(const char *string,...)
Logging function.
Definition:
b2Settings.cpp:38
b2Math.h
e_distanceJoint
Definition:
b2Joint.h:34
b2Joint::Destroy
static void Destroy(b2Joint *joint, b2BlockAllocator *allocator)
Definition:
b2Joint.cpp:128
e_frictionJoint
Definition:
b2Joint.h:40
b2JointDef
Joint definitions are used to construct joints.
Definition:
b2Joint.h:74
b2Joint::GetBodyA
b2Body * GetBodyA()
Get the first body attached to this joint.
Definition:
b2Joint.h:191
b2GearJoint::SolvePositionConstraints
bool SolvePositionConstraints(const b2SolverData &data)
Definition:
b2GearJoint.cpp:271
e_pulleyJoint
Definition:
b2Joint.h:35
b2LimitState
b2LimitState
Definition:
b2Joint.h:45
b2GearJoint::SolveVelocityConstraints
void SolveVelocityConstraints(const b2SolverData &data)
Definition:
b2GearJoint.cpp:235
b2Joint::GetType
b2JointType GetType() const
Get the type of the concrete joint.
Definition:
b2Joint.h:186
b2JointEdge::prev
b2JointEdge * prev
the previous joint edge in the body's joint list
Definition:
b2Joint.h:69
b2Joint::m_collideConnected
bool m_collideConnected
Definition:
b2Joint.h:181
B2_NOT_USED
#define B2_NOT_USED(x)
Definition:
b2Settings.h:26
b2JointDef::b2JointDef
b2JointDef()
Definition:
b2Joint.h:76
b2GearJoint
Definition:
b2GearJoint.h:56
b2Joint::GetNext
b2Joint * GetNext()
Get the next joint the world joint list.
Definition:
b2Joint.h:201
b2SolverData
Solver Data.
Definition:
b2TimeStep.h:63
b2Joint::m_index
int32 m_index
Definition:
b2Joint.h:178
b2Vec2
A 2D column vector.
Definition:
b2Math.h:53
b2Joint::m_prev
b2Joint * m_prev
Definition:
b2Joint.h:171
b2JointEdge::other
b2Body * other
provides quick access to the other body attached.
Definition:
b2Joint.h:67
e_unknownJoint
Definition:
b2Joint.h:31
b2Joint::GetBodyB
b2Body * GetBodyB()
Get the second body attached to this joint.
Definition:
b2Joint.h:196
b2Joint::m_edgeB
b2JointEdge m_edgeB
Definition:
b2Joint.h:174
int32
signed int int32
Definition:
b2Settings.h:31
b2JointEdge::joint
b2Joint * joint
the joint
Definition:
b2Joint.h:68
e_revoluteJoint
Definition:
b2Joint.h:32
e_equalLimits
Definition:
b2Joint.h:50
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition:
b2Body.h:126
b2Joint::m_next
b2Joint * m_next
Definition:
b2Joint.h:172
b2Jacobian::angularA
float32 angularA
Definition:
b2Joint.h:56
b2Jacobian::angularB
float32 angularB
Definition:
b2Joint.h:57
b2JointDef::collideConnected
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition:
b2Joint.h:98
e_mouseJoint
Definition:
b2Joint.h:36
b2JointType
b2JointType
Definition:
b2Joint.h:29
b2JointDef::userData
void * userData
Use this to attach application specific data to your joints.
Definition:
b2Joint.h:89
b2GearJoint::b2Joint
friend class b2Joint
Definition:
b2GearJoint.h:80
b2Joint::m_type
b2JointType m_type
Definition:
b2Joint.h:170
b2Joint::m_userData
void * m_userData
Definition:
b2Joint.h:183
b2Joint::m_bodyA
b2Body * m_bodyA
Definition:
b2Joint.h:175
b2BlockAllocator
Definition:
b2BlockAllocator.h:35
b2Joint::Dump
virtual void Dump()
Dump this joint to the log file.
Definition:
b2Joint.h:147
b2JointEdge
Definition:
b2Joint.h:65
b2Jacobian::linear
b2Vec2 linear
Definition:
b2Joint.h:55
b2Joint
Definition:
b2Joint.h:103
b2JointDef::type
b2JointType type
The joint type is set automatically for concrete joint types.
Definition:
b2Joint.h:86
b2Joint::~b2Joint
virtual ~b2Joint()
Definition:
b2Joint.h:162
b2Joint::ShiftOrigin
virtual void ShiftOrigin(const b2Vec2 &newOrigin)
Shift the origin for any points stored in world coordinates.
Definition:
b2Joint.h:150
b2Jacobian
Definition:
b2Joint.h:53
b2Joint::GetUserData
void * GetUserData() const
Get the user data pointer.
Definition:
b2Joint.h:211
e_motorJoint
Definition:
b2Joint.h:42
e_weldJoint
Definition:
b2Joint.h:39
e_atUpperLimit
Definition:
b2Joint.h:49
b2JointDef::bodyA
b2Body * bodyA
The first attached body.
Definition:
b2Joint.h:92
b2Joint::Create
static b2Joint * Create(const b2JointDef *def, b2BlockAllocator *allocator)
Definition:
b2Joint.cpp:37
e_wheelJoint
Definition:
b2Joint.h:38
b2Joint::SetUserData
void SetUserData(void *data)
Set the user data pointer.
Definition:
b2Joint.h:216
e_inactiveLimit
Definition:
b2Joint.h:47
e_prismaticJoint
Definition:
b2Joint.h:33
b2Joint::GetCollideConnected
bool GetCollideConnected() const
Definition:
b2Joint.h:221
b2Joint::m_edgeA
b2JointEdge m_edgeA
Definition:
b2Joint.h:173
b2JointDef::bodyB
b2Body * bodyB
The second attached body.
Definition:
b2Joint.h:95
b2JointEdge::next
b2JointEdge * next
the next joint edge in the body's joint list
Definition:
b2Joint.h:70
b2Joint::m_bodyB
b2Body * m_bodyB
Definition:
b2Joint.h:176
b2World
Definition:
b2World.h:41
float32
float float32
Definition:
b2Settings.h:35
b2GearJoint::InitVelocityConstraints
void InitVelocityConstraints(const b2SolverData &data)
Definition:
b2GearJoint.cpp:131
e_ropeJoint
Definition:
b2Joint.h:41
b2Joint::m_islandFlag
bool m_islandFlag
Definition:
b2Joint.h:180
mvsim
Author(s):
autogenerated on Thu Jun 6 2019 19:36:40