Box2D 3.1.0
A 2D physics engine for games
Loading...
Searching...
No Matches
types.h
1// SPDX-FileCopyrightText: 2023 Erin Catto
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "base.h"
7#include "collision.h"
8#include "id.h"
9#include "math_functions.h"
10
11#include <stdbool.h>
12#include <stdint.h>
13
30typedef void b2TaskCallback( int32_t startIndex, int32_t endIndex, uint32_t workerIndex, void* taskContext );
31
43typedef void* b2EnqueueTaskCallback( b2TaskCallback* task, int32_t itemCount, int32_t minRange, void* taskContext,
44 void* userContext );
45
48typedef void b2FinishTaskCallback( void* userTask, void* userContext );
49
52typedef struct b2RayResult
53{
54 b2ShapeId shapeId;
55 b2Vec2 point;
56 b2Vec2 normal;
57 float fraction;
58 bool hit;
60
117
121
139
145typedef struct b2BodyDef
146{
149
154
157
160
163
170
176
179
182
184 void* userData;
185
188
191
194
200
203
207
211
214} b2BodyDef;
215
219
223typedef struct b2Filter
224{
237 uint64_t categoryBits;
238
246 uint64_t maskBits;
247
254 int32_t groupIndex;
255} b2Filter;
256
260
265typedef struct b2QueryFilter
266{
268 uint64_t categoryBits;
269
272 uint64_t maskBits;
274
278
301
307typedef struct b2ShapeDef
308{
310 void* userData;
311
313 float friction;
314
317
319 float density;
320
323
325 uint32_t customColor;
326
331
334
337
340
344
350
353} b2ShapeDef;
354
358
374typedef struct b2ChainDef
375{
377 void* userData;
378
381
383 int32_t count;
384
386 float friction;
387
390
393
395 bool isLoop;
396
399} b2ChainDef;
400
404
407typedef struct b2Profile
408{
409 float step;
410 float pairs;
411 float collide;
412 float solve;
413 float buildIslands;
414 float solveConstraints;
415 float prepareTasks;
416 float solverTasks;
417 float prepareConstraints;
418 float integrateVelocities;
419 float warmStart;
420 float solveVelocities;
421 float integratePositions;
422 float relaxVelocities;
423 float applyRestitution;
424 float storeImpulses;
425 float finalizeBodies;
426 float splitIslands;
427 float sleepIslands;
428 float hitEvents;
429 float broadphase;
430 float continuous;
431} b2Profile;
432
434typedef struct b2Counters
435{
436 int32_t staticBodyCount;
437 int32_t bodyCount;
438 int32_t shapeCount;
439 int32_t contactCount;
440 int32_t jointCount;
441 int32_t islandCount;
442 int32_t stackUsed;
443 int32_t staticTreeHeight;
444 int32_t treeHeight;
445 int32_t byteCount;
446 int32_t taskCount;
447 int32_t colorCounts[12];
448} b2Counters;
450
456typedef enum b2JointType
457{
458 b2_distanceJoint,
459 b2_motorJoint,
460 b2_mouseJoint,
461 b2_prismaticJoint,
462 b2_revoluteJoint,
463 b2_weldJoint,
464 b2_wheelJoint,
466
474typedef struct b2DistanceJointDef
475{
478
481
484
487
489 float length;
490
494
496 float hertz;
497
500
503
506
509
512
515
518
521
523 void* userData;
524
528
532
569
573
579typedef struct b2MouseJointDef
580{
583
586
589
591 float hertz;
592
595
597 float maxForce;
598
601
603 void* userData;
604
608
612
676
679B2_API b2PrismaticJointDef b2DefaultPrismaticJointDef( void );
680
750
754
799
803
864
868
895
905
923
933
943
962
986
997typedef struct b2BodyMoveEvent
998{
999 b2Transform transform;
1000 b2BodyId bodyId;
1001 void* userData;
1002 bool fellAsleep;
1004
1008typedef struct b2BodyEvents
1009{
1012
1014 int32_t moveCount;
1015} b2BodyEvents;
1016
1020typedef struct b2ContactData
1021{
1022 b2ShapeId shapeIdA;
1023 b2ShapeId shapeIdB;
1024 b2Manifold manifold;
1026
1040typedef bool b2CustomFilterFcn( b2ShapeId shapeIdA, b2ShapeId shapeIdB, void* context );
1041
1055typedef bool b2PreSolveFcn( b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold* manifold, void* context );
1056
1062typedef bool b2OverlapResultFcn( b2ShapeId shapeId, void* context );
1063
1079typedef float b2CastResultFcn( b2ShapeId shapeId, b2Vec2 point, b2Vec2 normal, float fraction, void* context );
1080
1083typedef enum b2HexColor
1084{
1085 b2_colorAliceBlue = 0xf0f8ff,
1086 b2_colorAntiqueWhite = 0xfaebd7,
1087 b2_colorAquamarine = 0x7fffd4,
1088 b2_colorAzure = 0xf0ffff,
1089 b2_colorBeige = 0xf5f5dc,
1090 b2_colorBisque = 0xffe4c4,
1091 b2_colorBlack = 0x000000,
1092 b2_colorBlanchedAlmond = 0xffebcd,
1093 b2_colorBlue = 0x0000ff,
1094 b2_colorBlueViolet = 0x8a2be2,
1095 b2_colorBrown = 0xa52a2a,
1096 b2_colorBurlywood = 0xdeb887,
1097 b2_colorCadetBlue = 0x5f9ea0,
1098 b2_colorChartreuse = 0x7fff00,
1099 b2_colorChocolate = 0xd2691e,
1100 b2_colorCoral = 0xff7f50,
1101 b2_colorCornflowerBlue = 0x6495ed,
1102 b2_colorCornsilk = 0xfff8dc,
1103 b2_colorCrimson = 0xdc143c,
1104 b2_colorCyan = 0x00ffff,
1105 b2_colorDarkBlue = 0x00008b,
1106 b2_colorDarkCyan = 0x008b8b,
1107 b2_colorDarkGoldenrod = 0xb8860b,
1108 b2_colorDarkGray = 0xa9a9a9,
1109 b2_colorDarkGreen = 0x006400,
1110 b2_colorDarkKhaki = 0xbdb76b,
1111 b2_colorDarkMagenta = 0x8b008b,
1112 b2_colorDarkOliveGreen = 0x556b2f,
1113 b2_colorDarkOrange = 0xff8c00,
1114 b2_colorDarkOrchid = 0x9932cc,
1115 b2_colorDarkRed = 0x8b0000,
1116 b2_colorDarkSalmon = 0xe9967a,
1117 b2_colorDarkSeaGreen = 0x8fbc8f,
1118 b2_colorDarkSlateBlue = 0x483d8b,
1119 b2_colorDarkSlateGray = 0x2f4f4f,
1120 b2_colorDarkTurquoise = 0x00ced1,
1121 b2_colorDarkViolet = 0x9400d3,
1122 b2_colorDeepPink = 0xff1493,
1123 b2_colorDeepSkyBlue = 0x00bfff,
1124 b2_colorDimGray = 0x696969,
1125 b2_colorDodgerBlue = 0x1e90ff,
1126 b2_colorFirebrick = 0xb22222,
1127 b2_colorFloralWhite = 0xfffaf0,
1128 b2_colorForestGreen = 0x228b22,
1129 b2_colorGainsboro = 0xdcdcdc,
1130 b2_colorGhostWhite = 0xf8f8ff,
1131 b2_colorGold = 0xffd700,
1132 b2_colorGoldenrod = 0xdaa520,
1133 b2_colorGray = 0xbebebe,
1134 b2_colorGray1 = 0x1a1a1a,
1135 b2_colorGray2 = 0x333333,
1136 b2_colorGray3 = 0x4d4d4d,
1137 b2_colorGray4 = 0x666666,
1138 b2_colorGray5 = 0x7f7f7f,
1139 b2_colorGray6 = 0x999999,
1140 b2_colorGray7 = 0xb3b3b3,
1141 b2_colorGray8 = 0xcccccc,
1142 b2_colorGray9 = 0xe5e5e5,
1143 b2_colorGreen = 0x00ff00,
1144 b2_colorGreenYellow = 0xadff2f,
1145 b2_colorHoneydew = 0xf0fff0,
1146 b2_colorHotPink = 0xff69b4,
1147 b2_colorIndianRed = 0xcd5c5c,
1148 b2_colorIndigo = 0x4b0082,
1149 b2_colorIvory = 0xfffff0,
1150 b2_colorKhaki = 0xf0e68c,
1151 b2_colorLavender = 0xe6e6fa,
1152 b2_colorLavenderBlush = 0xfff0f5,
1153 b2_colorLawnGreen = 0x7cfc00,
1154 b2_colorLemonChiffon = 0xfffacd,
1155 b2_colorLightBlue = 0xadd8e6,
1156 b2_colorLightCoral = 0xf08080,
1157 b2_colorLightCyan = 0xe0ffff,
1158 b2_colorLightGoldenrod = 0xeedd82,
1159 b2_colorLightGoldenrodYellow = 0xfafad2,
1160 b2_colorLightGray = 0xd3d3d3,
1161 b2_colorLightGreen = 0x90ee90,
1162 b2_colorLightPink = 0xffb6c1,
1163 b2_colorLightSalmon = 0xffa07a,
1164 b2_colorLightSeaGreen = 0x20b2aa,
1165 b2_colorLightSkyBlue = 0x87cefa,
1166 b2_colorLightSlateBlue = 0x8470ff,
1167 b2_colorLightSlateGray = 0x778899,
1168 b2_colorLightSteelBlue = 0xb0c4de,
1169 b2_colorLightYellow = 0xffffe0,
1170 b2_colorLimeGreen = 0x32cd32,
1171 b2_colorLinen = 0xfaf0e6,
1172 b2_colorMagenta = 0xff00ff,
1173 b2_colorMaroon = 0xb03060,
1174 b2_colorMediumAquamarine = 0x66cdaa,
1175 b2_colorMediumBlue = 0x0000cd,
1176 b2_colorMediumOrchid = 0xba55d3,
1177 b2_colorMediumPurple = 0x9370db,
1178 b2_colorMediumSeaGreen = 0x3cb371,
1179 b2_colorMediumSlateBlue = 0x7b68ee,
1180 b2_colorMediumSpringGreen = 0x00fa9a,
1181 b2_colorMediumTurquoise = 0x48d1cc,
1182 b2_colorMediumVioletRed = 0xc71585,
1183 b2_colorMidnightBlue = 0x191970,
1184 b2_colorMintCream = 0xf5fffa,
1185 b2_colorMistyRose = 0xffe4e1,
1186 b2_colorMoccasin = 0xffe4b5,
1187 b2_colorNavajoWhite = 0xffdead,
1188 b2_colorNavyBlue = 0x000080,
1189 b2_colorOldLace = 0xfdf5e6,
1190 b2_colorOlive = 0x808000,
1191 b2_colorOliveDrab = 0x6b8e23,
1192 b2_colorOrange = 0xffa500,
1193 b2_colorOrangeRed = 0xff4500,
1194 b2_colorOrchid = 0xda70d6,
1195 b2_colorPaleGoldenrod = 0xeee8aa,
1196 b2_colorPaleGreen = 0x98fb98,
1197 b2_colorPaleTurquoise = 0xafeeee,
1198 b2_colorPaleVioletRed = 0xdb7093,
1199 b2_colorPapayaWhip = 0xffefd5,
1200 b2_colorPeachPuff = 0xffdab9,
1201 b2_colorPeru = 0xcd853f,
1202 b2_colorPink = 0xffc0cb,
1203 b2_colorPlum = 0xdda0dd,
1204 b2_colorPowderBlue = 0xb0e0e6,
1205 b2_colorPurple = 0xa020f0,
1206 b2_colorRebeccaPurple = 0x663399,
1207 b2_colorRed = 0xff0000,
1208 b2_colorRosyBrown = 0xbc8f8f,
1209 b2_colorRoyalBlue = 0x4169e1,
1210 b2_colorSaddleBrown = 0x8b4513,
1211 b2_colorSalmon = 0xfa8072,
1212 b2_colorSandyBrown = 0xf4a460,
1213 b2_colorSeaGreen = 0x2e8b57,
1214 b2_colorSeashell = 0xfff5ee,
1215 b2_colorSienna = 0xa0522d,
1216 b2_colorSilver = 0xc0c0c0,
1217 b2_colorSkyBlue = 0x87ceeb,
1218 b2_colorSlateBlue = 0x6a5acd,
1219 b2_colorSlateGray = 0x708090,
1220 b2_colorSnow = 0xfffafa,
1221 b2_colorSpringGreen = 0x00ff7f,
1222 b2_colorSteelBlue = 0x4682b4,
1223 b2_colorTan = 0xd2b48c,
1224 b2_colorTeal = 0x008080,
1225 b2_colorThistle = 0xd8bfd8,
1226 b2_colorTomato = 0xff6347,
1227 b2_colorTurquoise = 0x40e0d0,
1228 b2_colorViolet = 0xee82ee,
1229 b2_colorVioletRed = 0xd02090,
1230 b2_colorWheat = 0xf5deb3,
1231 b2_colorWhite = 0xffffff,
1232 b2_colorWhiteSmoke = 0xf5f5f5,
1233 b2_colorYellow = 0xffff00,
1234 b2_colorYellowGreen = 0x9acd32,
1235 b2_colorBox2DRed = 0xdc3132,
1236 b2_colorBox2DBlue = 0x30aebf,
1237 b2_colorBox2DGreen = 0x8cc924,
1238 b2_colorBox2DYellow = 0xffee8c
1239} b2HexColor;
1240
1244typedef struct b2DebugDraw
1245{
1247 void ( *DrawPolygon )( const b2Vec2* vertices, int vertexCount, b2HexColor color, void* context );
1248
1250 void ( *DrawSolidPolygon )( b2Transform transform, const b2Vec2* vertices, int vertexCount, float radius, b2HexColor color,
1251 void* context );
1252
1254 void ( *DrawCircle )( b2Vec2 center, float radius, b2HexColor color, void* context );
1255
1257 void ( *DrawSolidCircle )( b2Transform transform, float radius, b2HexColor color, void* context );
1258
1260 void ( *DrawCapsule )( b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void* context );
1261
1263 void ( *DrawSolidCapsule )( b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void* context );
1264
1266 void ( *DrawSegment )( b2Vec2 p1, b2Vec2 p2, b2HexColor color, void* context );
1267
1269 void ( *DrawTransform )( b2Transform transform, void* context );
1270
1272 void ( *DrawPoint )( b2Vec2 p, float size, b2HexColor color, void* context );
1273
1275 void ( *DrawString )( b2Vec2 p, const char* s, void* context );
1276
1279
1282
1285
1288
1291
1294
1297
1300
1303
1306
1309
1312
1314 void* context;
1315} b2DebugDraw;
1316
1319B2_API b2DebugDraw b2DefaultDebugDraw( void );
float sleepThreshold
Sleep velocity threshold, default is 0.05 meter per second.
Definition types.h:181
bool automaticMass
Automatically compute mass and related properties on this body from shapes.
Definition types.h:206
b2Vec2 linearVelocity
The initial linear velocity of the body's origin. Typically in meters per second.
Definition types.h:159
bool fixedRotation
Should this body be prevented from rotating? Useful for characters.
Definition types.h:193
b2Vec2 position
The initial world position of the body.
Definition types.h:153
b2Rot rotation
The initial world rotation of the body. Use b2MakeRot() if you have an angle.
Definition types.h:156
bool allowFastRotation
This allows this body to bypass rotational speed limits.
Definition types.h:210
bool isEnabled
Used to disable a body. A disabled body does not move or collide.
Definition types.h:202
b2BodyType type
The body type: static, kinematic, or dynamic.
Definition types.h:148
float linearDamping
Linear damping is use to reduce the linear velocity.
Definition types.h:169
float angularVelocity
The initial angular velocity of the body. Radians per second.
Definition types.h:162
float gravityScale
Scale the gravity applied to this body. Non-dimensional.
Definition types.h:178
void * userData
Use this to store application specific body data.
Definition types.h:184
bool isBullet
Treat this body as high speed object that performs continuous collision detection against dynamic and...
Definition types.h:199
bool isAwake
Is this body initially awake or sleeping?
Definition types.h:190
bool enableSleep
Set this flag to false if this body should never fall asleep.
Definition types.h:187
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:213
float angularDamping
Angular damping is use to reduce the angular velocity.
Definition types.h:175
b2BodyType
The body simulation type.
Definition types.h:126
b2BodyDef b2DefaultBodyDef(void)
Use this to initialize your body definition.
@ b2_staticBody
zero mass, zero velocity, may be manually moved
Definition types.h:128
@ b2_kinematicBody
zero mass, velocity set by user, moved by solver
Definition types.h:131
@ b2_dynamicBody
positive mass, velocity determined by forces, moved by solver
Definition types.h:134
@ b2_bodyTypeCount
number of body types
Definition types.h:137
A body definition holds all the data needed to construct a rigid body.
Definition types.h:146
A contact manifold describes the contact points between colliding shapes.
Definition collision.h:513
float length
The rest length of this joint. Clamped to a stable minimum value.
Definition types.h:489
bool enableLimit
Enable/disable the joint limit.
Definition types.h:502
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:483
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:520
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:526
float dampingRatio
The spring linear damping ratio, non-dimensional.
Definition types.h:499
float maxMotorForce
The maximum motor force, usually in newtons.
Definition types.h:514
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:486
b2BodyId bodyIdB
The second attached body.
Definition types.h:480
void * userData
User data pointer.
Definition types.h:523
b2BodyId bodyIdA
The first attached body.
Definition types.h:477
bool enableSpring
Enable the distance constraint to behave like a spring.
Definition types.h:493
float minLength
Minimum length. Clamped to a stable minimum value.
Definition types.h:505
bool enableMotor
Enable/disable the joint motor.
Definition types.h:511
float maxLength
Maximum length. Must be greater than or equal to the minimum length.
Definition types.h:508
float hertz
The spring linear stiffness Hertz, cycles per second.
Definition types.h:496
float motorSpeed
The desired motor speed, usually in meters per second.
Definition types.h:517
b2DistanceJointDef b2DefaultDistanceJointDef(void)
Use this to initialize your joint definition.
Distance joint definition.
Definition types.h:475
int32_t moveCount
Number of move events.
Definition types.h:1014
b2ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:890
b2ContactBeginTouchEvent * beginEvents
Array of begin touch events.
Definition types.h:969
float approachSpeed
The speed the shapes are approaching. Always positive. Typically in meters per second.
Definition types.h:960
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:941
int32_t endCount
Number of end touch events.
Definition types.h:981
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:928
b2BodyMoveEvent * moveEvents
Array of move events.
Definition types.h:1011
b2Vec2 normal
Normal vector pointing from shape A to shape B.
Definition types.h:957
b2ContactHitEvent * hitEvents
Array of hit events.
Definition types.h:975
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:931
b2SensorEndTouchEvent * endEvents
Array of sensor end touch events.
Definition types.h:915
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:938
int32_t endCount
The number of end touch events.
Definition types.h:921
b2ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:900
int32_t beginCount
Number of begin touch events.
Definition types.h:978
b2ShapeId visitorShapeId
The id of the dynamic shape that stopped touching the sensor shape.
Definition types.h:903
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:951
b2ContactEndTouchEvent * endEvents
Array of end touch events.
Definition types.h:972
b2Vec2 point
Point where the shapes hit.
Definition types.h:954
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:948
int32_t beginCount
The number of begin touch events.
Definition types.h:918
int32_t hitCount
Number of hit events.
Definition types.h:984
b2ShapeId visitorShapeId
The id of the dynamic shape that began touching the sensor shape.
Definition types.h:893
b2SensorBeginTouchEvent * beginEvents
Array of sensor begin touch events.
Definition types.h:912
Body events are buffered in the Box2D world and are available as event arrays after the time step is ...
Definition types.h:1009
Body move events triggered when a body moves.
Definition types.h:998
A begin touch event is generated when two shapes begin touching.
Definition types.h:926
The contact data for two shapes.
Definition types.h:1021
An end touch event is generated when two shapes stop touching.
Definition types.h:936
Contact events are buffered in the Box2D world and are available as event arrays after the time step ...
Definition types.h:967
A hit touch event is generated when two shapes collide with a speed faster than the hit speed thresho...
Definition types.h:946
A begin touch event is generated when a shape starts to overlap a sensor shape.
Definition types.h:888
An end touch event is generated when a shape stops overlapping a sensor shape.
Definition types.h:898
Sensor events are buffered in the Box2D world and are available as begin/end overlap event arrays aft...
Definition types.h:910
Body id references a body instance. This should be treated as an opaque handle.
Definition id.h:45
Shape id references a shape instance. This should be treated as an opaque handle.
Definition id.h:53
b2JointType
Joint type enumeration.
Definition types.h:457
Axis-aligned bounding box.
Definition math_functions.h:53
2D rotation This is similar to using a complex number for rotation
Definition math_functions.h:32
A 2D rigid transform.
Definition math_functions.h:39
2D vector This can be used to represent a point or free vector
Definition math_functions.h:24
float maxForce
The maximum motor force in newtons.
Definition types.h:552
float correctionFactor
Position correction factor in the range [0,1].
Definition types.h:558
b2Vec2 linearOffset
Position of bodyB minus the position of bodyA, in bodyA's frame.
Definition types.h:546
float angularOffset
The bodyB angle minus bodyA angle in radians.
Definition types.h:549
b2BodyId bodyIdB
The second attached body.
Definition types.h:543
void * userData
User data pointer.
Definition types.h:564
b2BodyId bodyIdA
The first attached body.
Definition types.h:540
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:567
float maxTorque
The maximum motor torque in newton-meters.
Definition types.h:555
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:561
b2MotorJointDef b2DefaultMotorJointDef(void)
Use this to initialize your joint definition.
A motor joint is used to control the relative motion between two bodies.
Definition types.h:538
void * userData
User data pointer.
Definition types.h:603
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:600
b2BodyId bodyIdB
The second attached body.
Definition types.h:585
float maxForce
Maximum force, typically in newtons.
Definition types.h:597
float hertz
Stiffness in hertz.
Definition types.h:591
b2Vec2 target
The initial target point in world space.
Definition types.h:588
float dampingRatio
Damping ratio, non-dimensional.
Definition types.h:594
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:606
b2BodyId bodyIdA
The first attached body.
Definition types.h:582
b2MouseJointDef b2DefaultMouseJointDef(void)
Use this to initialize your joint definition.
A mouse joint is used to make a point on a body track a specified world point.
Definition types.h:580
void * userData
User data pointer.
Definition types.h:671
float lowerTranslation
The lower translation limit.
Definition types.h:653
bool enableMotor
Enable/disable the joint motor.
Definition types.h:659
float motorSpeed
The desired motor speed, typically in meters per second.
Definition types.h:665
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:632
b2BodyId bodyIdA
The first attached body.
Definition types.h:623
bool enableSpring
Enable a linear spring along the prismatic joint axis.
Definition types.h:641
float upperTranslation
The upper translation limit.
Definition types.h:656
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:647
bool enableLimit
Enable/disable the joint limit.
Definition types.h:650
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:644
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:629
float referenceAngle
The constrained angle between the bodies: bodyB_angle - bodyA_angle.
Definition types.h:638
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:674
b2BodyId bodyIdB
The second attached body.
Definition types.h:626
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:668
b2Vec2 localAxisA
The local translation unit axis in bodyA.
Definition types.h:635
float maxMotorForce
The maximum motor force, typically in newtons.
Definition types.h:662
Prismatic joint definition.
Definition types.h:621
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:718
float lowerAngle
The lower angle for the joint limit in radians.
Definition types.h:724
bool enableLimit
A flag to enable joint limits.
Definition types.h:721
float motorSpeed
The desired motor speed in radians per second.
Definition types.h:736
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:705
void * userData
User data pointer.
Definition types.h:745
float upperAngle
The upper angle for the joint limit in radians.
Definition types.h:727
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:702
float referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians).
Definition types.h:709
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:742
bool enableSpring
Enable a rotational spring on the revolute hinge axis.
Definition types.h:712
b2BodyId bodyIdA
The first attached body.
Definition types.h:696
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:715
bool enableMotor
A flag to enable the joint motor.
Definition types.h:730
b2BodyId bodyIdB
The second attached body.
Definition types.h:699
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:748
float maxMotorTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:733
float drawSize
Scale the debug draw.
Definition types.h:739
b2RevoluteJointDef b2DefaultRevoluteJointDef(void)
Use this to initialize your joint definition.
Revolute joint definition.
Definition types.h:694
b2Filter filter
Contact filtering data.
Definition types.h:392
bool isLoop
Indicates a closed chain formed by connecting the first and last points.
Definition types.h:395
float restitution
The restitution (bounce) usually in the range [0,1].
Definition types.h:316
uint64_t maskBits
The collision mask bits.
Definition types.h:272
void * userData
Use this to store application specific shape data.
Definition types.h:377
bool enablePreSolveEvents
Enable pre-solve contact events for this shape.
Definition types.h:343
float friction
The Coulomb (dry) friction coefficient, usually in the range [0,1].
Definition types.h:313
int32_t groupIndex
Collision groups allow a certain group of objects to never collide (negative) or always collide (posi...
Definition types.h:254
bool isSensor
A sensor shape generates overlap events but never generates a collision response.
Definition types.h:330
void * userData
Use this to store application specific shape data.
Definition types.h:310
uint64_t maskBits
The collision mask bits.
Definition types.h:246
const b2Vec2 * points
An array of at least 4 points. These are cloned and may be temporary.
Definition types.h:380
bool enableContactEvents
Enable contact events for this shape. Only applies to kinematic and dynamic bodies....
Definition types.h:336
float restitution
The restitution (elasticity) usually in the range [0,1].
Definition types.h:389
float friction
The friction coefficient, usually in the range [0,1].
Definition types.h:386
uint64_t categoryBits
The collision category bits.
Definition types.h:237
bool forceContactCreation
Normally shapes on static bodies don't invoke contact creation when they are added to the world.
Definition types.h:349
bool enableHitEvents
Enable hit events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors.
Definition types.h:339
b2Filter filter
Collision filtering data.
Definition types.h:322
float density
The density, usually in kg/m^2.
Definition types.h:319
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:352
bool enableSensorEvents
Enable sensor events for this shape. Only applies to kinematic and dynamic bodies....
Definition types.h:333
int32_t count
The point count, must be 4 or more.
Definition types.h:383
uint64_t categoryBits
The collision category bits of this query. Normally you would just set one bit.
Definition types.h:268
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:398
uint32_t customColor
Custom debug draw color.
Definition types.h:325
b2QueryFilter b2DefaultQueryFilter(void)
Use this to initialize your query filter.
b2ChainDef b2DefaultChainDef(void)
Use this to initialize your chain definition.
b2Filter b2DefaultFilter(void)
Use this to initialize your filter.
b2ShapeType
Shape type.
Definition types.h:282
b2ShapeDef b2DefaultShapeDef(void)
Use this to initialize your shape definition.
@ b2_shapeTypeCount
The number of shape types.
Definition types.h:299
@ b2_polygonShape
A convex polygon.
Definition types.h:293
@ b2_circleShape
A circle with an offset.
Definition types.h:284
@ b2_segmentShape
A line segment.
Definition types.h:290
@ b2_chainSegmentShape
A line segment owned by a chain shape.
Definition types.h:296
@ b2_capsuleShape
A capsule is an extruded circle.
Definition types.h:287
Used to create a chain of line segments.
Definition types.h:375
This is used to filter collision on shapes.
Definition types.h:224
The query filter is used to filter collisions between queries and shapes.
Definition types.h:266
Used to create a shape.
Definition types.h:308
float linearHertz
Linear stiffness expressed as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:779
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:770
b2BodyId bodyIdB
The second attached body.
Definition types.h:767
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:773
void * userData
User data pointer.
Definition types.h:794
float referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians)
Definition types.h:776
b2BodyId bodyIdA
The first attached body.
Definition types.h:764
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:797
float angularHertz
Angular stiffness as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:782
float angularDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:788
float linearDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:785
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:791
b2WeldJointDef b2DefaultWeldJointDef(void)
Use this to initialize your joint definition.
Weld joint definition.
Definition types.h:762
bool enableSpring
Enable a linear spring along the local axis.
Definition types.h:829
float hertz
Spring stiffness in Hertz.
Definition types.h:832
float motorSpeed
The desired motor speed in radians per second.
Definition types.h:853
bool enableLimit
Enable/disable the joint linear limit.
Definition types.h:838
float upperTranslation
The upper translation limit.
Definition types.h:844
float lowerTranslation
The lower translation limit.
Definition types.h:841
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:856
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:862
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:823
float dampingRatio
Spring damping ratio, non-dimensional.
Definition types.h:835
b2BodyId bodyIdB
The second attached body.
Definition types.h:817
bool enableMotor
Enable/disable the joint rotational motor.
Definition types.h:847
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:820
b2BodyId bodyIdA
The first attached body.
Definition types.h:814
void * userData
User data pointer.
Definition types.h:859
float maxMotorTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:850
b2Vec2 localAxisA
The local translation unit axis in bodyA.
Definition types.h:826
b2WheelJointDef b2DefaultWheelJointDef(void)
Use this to initialize your joint definition.
Wheel joint definition.
Definition types.h:812
b2AABB drawingBounds
Bounds to use if restricting drawing to a rectangular region.
Definition types.h:1278
bool drawJoints
Option to draw joints.
Definition types.h:1287
bool drawFrictionImpulses
Option to draw contact friction impulses.
Definition types.h:1311
void(* DrawSegment)(b2Vec2 p1, b2Vec2 p2, b2HexColor color, void *context)
Draw a line segment.
Definition types.h:1266
bool drawContactImpulses
Option to draw contact normal impulses.
Definition types.h:1308
bool drawContacts
Option to draw contact points.
Definition types.h:1299
void(* DrawSolidCircle)(b2Transform transform, float radius, b2HexColor color, void *context)
Draw a solid circle.
Definition types.h:1257
void * context
User context that is passed as an argument to drawing callback functions.
Definition types.h:1314
void(* DrawSolidCapsule)(b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void *context)
Draw a solid capsule.
Definition types.h:1263
void(* DrawSolidPolygon)(b2Transform transform, const b2Vec2 *vertices, int vertexCount, float radius, b2HexColor color, void *context)
Draw a solid closed polygon provided in CCW order.
Definition types.h:1250
float contactHertz
Contact stiffness. Cycles per second.
Definition types.h:80
bool drawShapes
Option to draw shapes.
Definition types.h:1284
bool drawJointExtras
Option to draw additional information for joints.
Definition types.h:1290
float contactDampingRatio
Contact bounciness. Non-dimensional.
Definition types.h:83
void(* DrawString)(b2Vec2 p, const char *s, void *context)
Draw a string.
Definition types.h:1275
void(* DrawCapsule)(b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void *context)
Draw a capsule.
Definition types.h:1260
b2FinishTaskCallback * finishTask
Function to finish a task.
Definition types.h:109
void * userTaskContext
User context that is provided to enqueueTask and finishTask.
Definition types.h:112
float hitEventThreshold
Threshold velocity for hit events. Usually meters per second.
Definition types.h:77
b2Vec2 gravity
Gravity vector. Box2D has no up-vector defined.
Definition types.h:67
bool drawAABBs
Option to draw the bounding boxes for shapes.
Definition types.h:1293
bool enableSleep
Can bodies go to sleep to improve performance.
Definition types.h:95
bool drawGraphColors
Option to visualize the graph coloring used for contacts and joints.
Definition types.h:1302
bool enableContinuous
Enable continuous collision.
Definition types.h:98
float restitutionThreshold
Restitution velocity threshold, usually in m/s.
Definition types.h:71
bool drawContactNormals
Option to draw contact normals.
Definition types.h:1305
void(* DrawPoint)(b2Vec2 p, float size, b2HexColor color, void *context)
Draw a point.
Definition types.h:1272
bool useDrawingBounds
Option to restrict drawing to a rectangular region. May suffer from unstable depth sorting.
Definition types.h:1281
void(* DrawTransform)(b2Transform transform, void *context)
Draw a transform. Choose your own length scale.
Definition types.h:1269
int32_t workerCount
Number of workers to use with the provided task system.
Definition types.h:103
float contactPushoutVelocity
This parameter controls how fast overlap is resolved and has units of meters per second.
Definition types.h:74
bool drawMass
Option to draw the mass and center of mass of dynamic bodies.
Definition types.h:1296
float jointHertz
Joint stiffness. Cycles per second.
Definition types.h:86
void(* DrawCircle)(b2Vec2 center, float radius, b2HexColor color, void *context)
Draw a circle.
Definition types.h:1254
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:115
void(* DrawPolygon)(const b2Vec2 *vertices, int vertexCount, b2HexColor color, void *context)
Draw a closed polygon provided in CCW order.
Definition types.h:1247
b2EnqueueTaskCallback * enqueueTask
Function to spawn tasks.
Definition types.h:106
float maximumLinearVelocity
Maximum linear velocity. Usually meters per second.
Definition types.h:92
float jointDampingRatio
Joint bounciness. Non-dimensional.
Definition types.h:89
bool b2OverlapResultFcn(b2ShapeId shapeId, void *context)
Prototype callback for overlap queries.
Definition types.h:1062
void b2TaskCallback(int32_t startIndex, int32_t endIndex, uint32_t workerIndex, void *taskContext)
Task interface This is prototype for a Box2D task.
Definition types.h:30
bool b2PreSolveFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold *manifold, void *context)
Prototype for a pre-solve callback.
Definition types.h:1055
void * b2EnqueueTaskCallback(b2TaskCallback *task, int32_t itemCount, int32_t minRange, void *taskContext, void *userContext)
These functions can be provided to Box2D to invoke a task system.
Definition types.h:43
float b2CastResultFcn(b2ShapeId shapeId, b2Vec2 point, b2Vec2 normal, float fraction, void *context)
Prototype callback for ray casts.
Definition types.h:1079
bool b2CustomFilterFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, void *context)
Prototype for a contact filter callback.
Definition types.h:1040
b2WorldDef b2DefaultWorldDef(void)
Use this to initialize your world definition.
void b2FinishTaskCallback(void *userTask, void *userContext)
Finishes a user task object that wraps a Box2D task.
Definition types.h:48
This struct holds callbacks you can implement to draw a Box2D world.
Definition types.h:1245
Result from b2World_RayCastClosest.
Definition types.h:53
World definition used to create a simulation world.
Definition types.h:65