box2d 3.0.0
A 2D physics engine for games
 
Loading...
Searching...
No Matches
joint_types.h
1// SPDX-FileCopyrightText: 2023 Erin Catto
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "box2d/types.h"
7
45
47static inline b2DistanceJointDef b2DefaultDistanceJointDef(void)
48{
50 def.bodyIdA = b2_nullBodyId;
51 def.bodyIdB = b2_nullBodyId;
52 def.localAnchorA = B2_LITERAL(b2Vec2){0.0f, 0.0f};
53 def.localAnchorB = B2_LITERAL(b2Vec2){0.0f, 0.0f};
54 def.length = 1.0f;
55 def.minLength = 0.0f;
56 def.maxLength = b2_huge;
57 def.hertz = 0.0f;
58 def.dampingRatio = 0.0f;
59 def.collideConnected = false;
60 return def;
61}
62
89
91static inline b2MotorJointDef b2DefaultMotorJointDef(void)
92{
94 def.bodyIdA = b2_nullBodyId;
95 def.bodyIdB = b2_nullBodyId;
96 def.linearOffset = B2_LITERAL(b2Vec2){0.0f, 0.0f};
97 def.angularOffset = 0.0f;
98 def.maxForce = 1.0f;
99 def.maxTorque = 1.0f;
100 def.correctionFactor = 0.3f;
101 return def;
102}
103
130
132static inline b2MouseJointDef b2DefaultMouseJointDef(void)
133{
135 def.bodyIdA = b2_nullBodyId;
136 def.bodyIdB = b2_nullBodyId;
137 def.target = B2_LITERAL(b2Vec2){0.0f, 0.0f};
138 def.maxForce = 0.0f;
139 def.stiffness = 0.0f;
140 def.damping = 0.0f;
141 return def;
142}
143
190
192static inline b2PrismaticJointDef b2DefaultPrismaticJointDef(void)
193{
195 def.bodyIdA = b2_nullBodyId;
196 def.bodyIdB = b2_nullBodyId;
197 def.localAnchorA = B2_LITERAL(b2Vec2){0.0f, 0.0f};
198 def.localAnchorB = B2_LITERAL(b2Vec2){0.0f, 0.0f};
199 def.localAxisA = B2_LITERAL(b2Vec2){1.0f, 0.0f};
200 def.referenceAngle = 0.0f;
201 def.enableLimit = false;
202 def.lowerTranslation = 0.0f;
203 def.upperTranslation = 0.0f;
204 def.enableMotor = false;
205 def.maxMotorForce = 0.0f;
206 def.motorSpeed = 0.0f;
207 def.collideConnected = false;
208 return def;
209}
210
264
266static inline b2RevoluteJointDef b2DefaultRevoluteJointDef(void)
267{
269 def.bodyIdA = b2_nullBodyId;
270 def.bodyIdB = b2_nullBodyId;
271 def.localAnchorA = B2_LITERAL(b2Vec2){0.0f, 0.0f};
272 def.localAnchorB = B2_LITERAL(b2Vec2){0.0f, 0.0f};
273 def.referenceAngle = 0.0f;
274 def.lowerAngle = 0.0f;
275 def.upperAngle = 0.0f;
276 def.maxMotorTorque = 0.0f;
277 def.motorSpeed = 0.0f;
278 def.enableLimit = false;
279 def.enableMotor = false;
280 def.drawSize = 0.25f;
281 def.collideConnected = false;
282 return def;
283}
284
320
321static const b2WeldJointDef b2_defaultWeldJointDef = {
322 {-1, -1, 0}, {-1, -1, 0}, {0.0f, 0.0f}, {0.0f, 0.0f}, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, false,
323};
324
326static inline b2WeldJointDef b2DefaultWeldJointDef(void)
327{
329 def.bodyIdA = b2_nullBodyId;
330 def.bodyIdB = b2_nullBodyId;
331 def.localAnchorA = B2_LITERAL(b2Vec2){0.0f, 0.0f};
332 def.localAnchorB = B2_LITERAL(b2Vec2){0.0f, 0.0f};
333 def.referenceAngle = 0.0f;
334 def.linearHertz = 0.0f;
335 def.angularHertz = 0.0f;
336 def.linearDampingRatio = 1.0f;
337 def.angularDampingRatio = 1.0f;
338 def.collideConnected = false;
339 return def;
340}
341
392
394static inline b2WheelJointDef b2DefaultWheelJointDef(void)
395{
397 def.bodyIdA = b2_nullBodyId;
398 def.bodyIdB = b2_nullBodyId;
399 def.localAnchorA = B2_LITERAL(b2Vec2){0.0f, 0.0f};
400 def.localAnchorB = B2_LITERAL(b2Vec2){0.0f, 0.0f};
401 def.localAxisA = B2_LITERAL(b2Vec2){1.0f, 0.0f};
402 def.enableLimit = false;
403 def.lowerTranslation = 0.0f;
404 def.upperTranslation = 0.0f;
405 def.enableMotor = false;
406 def.maxMotorTorque = 0.0f;
407 def.motorSpeed = 0.0f;
408 def.stiffness = 0.0f;
409 def.damping = 0.0f;
410 def.collideConnected = false;
411 return def;
412}
#define b2_huge
Definition constants.h:77
Body identitifier.
Definition id.h:23
Definition joint_types.h:13
float length
The rest length of this joint. Clamped to a stable minimum value.
Definition joint_types.h:27
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition joint_types.h:21
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition joint_types.h:42
float dampingRatio
The linear damping ratio (non-dimensional)
Definition joint_types.h:39
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition joint_types.h:24
b2BodyId bodyIdB
The second attached body.
Definition joint_types.h:18
b2BodyId bodyIdA
The first attached body.
Definition joint_types.h:15
float minLength
Minimum length. Clamped to a stable minimum value.
Definition joint_types.h:30
float maxLength
Maximum length. Must be greater than or equal to the minimum length.
Definition joint_types.h:33
float hertz
The linear stiffness hertz (cycles per second)
Definition joint_types.h:36
Definition joint_types.h:67
float maxForce
The maximum motor force in N.
Definition joint_types.h:81
float correctionFactor
Position correction factor in the range [0,1].
Definition joint_types.h:87
b2Vec2 linearOffset
Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.
Definition joint_types.h:75
float angularOffset
The bodyB angle minus bodyA angle in radians.
Definition joint_types.h:78
b2BodyId bodyIdB
The second attached body.
Definition joint_types.h:72
b2BodyId bodyIdA
The first attached body.
Definition joint_types.h:69
float maxTorque
The maximum motor torque in N-m.
Definition joint_types.h:84
Definition joint_types.h:109
float damping
The linear damping in N*s/m.
Definition joint_types.h:128
b2BodyId bodyIdB
The second attached body.
Definition joint_types.h:114
float maxForce
Definition joint_types.h:122
b2Vec2 target
The initial target point in world space.
Definition joint_types.h:117
float stiffness
The linear stiffness in N/m.
Definition joint_types.h:125
b2BodyId bodyIdA
The first attached body.
Definition joint_types.h:111
Definition joint_types.h:150
float lowerTranslation
The lower translation limit, usually in meters.
Definition joint_types.h:173
bool enableMotor
Enable/disable the joint motor.
Definition joint_types.h:179
float motorSpeed
The desired motor speed in radians per second.
Definition joint_types.h:185
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition joint_types.h:161
b2BodyId bodyIdA
The first attached body.
Definition joint_types.h:152
float upperTranslation
The upper translation limit, usually in meters.
Definition joint_types.h:176
bool enableLimit
Enable/disable the joint limit.
Definition joint_types.h:170
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition joint_types.h:158
float referenceAngle
The constrained angle between the bodies: bodyB_angle - bodyA_angle.
Definition joint_types.h:167
b2BodyId bodyIdB
The second attached body.
Definition joint_types.h:155
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition joint_types.h:188
b2Vec2 localAxisA
The local translation unit axis in bodyA.
Definition joint_types.h:164
float maxMotorForce
The maximum motor force, usually in N.
Definition joint_types.h:182
Definition joint_types.h:222
float lowerAngle
The lower angle for the joint limit (radians).
Definition joint_types.h:243
bool enableLimit
A flag to enable joint limits.
Definition joint_types.h:240
float motorSpeed
The desired motor speed. Usually in radians per second.
Definition joint_types.h:252
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition joint_types.h:233
float upperAngle
The upper angle for the joint limit (radians).
Definition joint_types.h:246
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition joint_types.h:230
float referenceAngle
Definition joint_types.h:237
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition joint_types.h:262
b2BodyId bodyIdA
The first attached body.
Definition joint_types.h:224
bool enableMotor
A flag to enable the joint motor.
Definition joint_types.h:249
b2BodyId bodyIdB
The second attached body.
Definition joint_types.h:227
float maxMotorTorque
Definition joint_types.h:256
float drawSize
Scale the debug draw.
Definition joint_types.h:259
Definition joint_types.h:289
float linearHertz
Linear stiffness expressed as hertz (oscillations per second). Use zero for maximum stiffness.
Definition joint_types.h:306
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition joint_types.h:297
b2BodyId bodyIdB
The second attached body.
Definition joint_types.h:294
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition joint_types.h:300
float referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians).
Definition joint_types.h:303
b2BodyId bodyIdA
The first attached body.
Definition joint_types.h:291
float angularHertz
Angular stiffness as hertz (oscillations per second). Use zero for maximum stiffness.
Definition joint_types.h:309
float angularDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition joint_types.h:315
float linearDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition joint_types.h:312
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition joint_types.h:318
Definition joint_types.h:349
float motorSpeed
The desired motor speed in radians per second.
Definition joint_types.h:381
bool enableLimit
Enable/disable the joint limit.
Definition joint_types.h:366
float stiffness
The linear stiffness in N/m.
Definition joint_types.h:384
float upperTranslation
The upper translation limit, usually in meters.
Definition joint_types.h:372
float lowerTranslation
The lower translation limit, usually in meters.
Definition joint_types.h:369
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition joint_types.h:390
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition joint_types.h:360
b2BodyId bodyIdB
The second attached body.
Definition joint_types.h:354
bool enableMotor
Enable/disable the joint motor.
Definition joint_types.h:375
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition joint_types.h:357
b2BodyId bodyIdA
The first attached body.
Definition joint_types.h:351
float damping
The linear damping in N*s/m.
Definition joint_types.h:387
float maxMotorTorque
The maximum motor torque, usually in N-m.
Definition joint_types.h:378
b2Vec2 localAxisA
The local translation unit axis in bodyA.
Definition joint_types.h:363
types used by the Box2D API
#define B2_LITERAL(T)
Used for C literals like (b2Vec2){1.0f, 2.0f} where C++ requires b2Vec2{1.0f, 2.0f}.
Definition types.h:29
#define B2_ZERO_INIT
Used for C zero initialization, such as b2Vec2 v = {0} where C++ requires b2Vec2 v = {}.
Definition types.h:32
Definition types.h:47