Box2D 3.0.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
114
118
136
142typedef struct b2BodyDef
143{
146
151
153 float angle;
154
157
160
167
173
176
179
181 void* userData;
182
185
188
191
197
200
204
207} b2BodyDef;
208
212
216typedef struct b2Filter
217{
230 uint32_t categoryBits;
231
239 uint32_t maskBits;
240
247 int32_t groupIndex;
248} b2Filter;
249
253
258typedef struct b2QueryFilter
259{
261 uint32_t categoryBits;
262
265 uint32_t maskBits;
267
271
294
300typedef struct b2ShapeDef
301{
303 void* userData;
304
306 float friction;
307
310
312 float density;
313
316
319
322
325
328
332
337
340} b2ShapeDef;
341
345
361typedef struct b2ChainDef
362{
364 void* userData;
365
368
370 int32_t count;
371
373 float friction;
374
377
380
382 bool isLoop;
383
386} b2ChainDef;
387
391
394typedef struct b2Profile
395{
396 float step;
397 float pairs;
398 float collide;
399 float solve;
400 float buildIslands;
401 float solveConstraints;
402 float prepareTasks;
403 float solverTasks;
404 float prepareConstraints;
405 float integrateVelocities;
406 float warmStart;
407 float solveVelocities;
408 float integratePositions;
409 float relaxVelocities;
410 float applyRestitution;
411 float storeImpulses;
412 float finalizeBodies;
413 float splitIslands;
414 float sleepIslands;
415 float hitEvents;
416 float broadphase;
417 float continuous;
418} b2Profile;
419
421typedef struct b2Counters
422{
423 int32_t staticBodyCount;
424 int32_t bodyCount;
425 int32_t shapeCount;
426 int32_t contactCount;
427 int32_t jointCount;
428 int32_t islandCount;
429 int32_t stackUsed;
430 int32_t staticTreeHeight;
431 int32_t treeHeight;
432 int32_t byteCount;
433 int32_t taskCount;
434 int32_t colorCounts[12];
435} b2Counters;
437
443typedef enum b2JointType
444{
445 b2_distanceJoint,
446 b2_motorJoint,
447 b2_mouseJoint,
448 b2_prismaticJoint,
449 b2_revoluteJoint,
450 b2_weldJoint,
451 b2_wheelJoint,
453
461typedef struct b2DistanceJointDef
462{
465
468
471
474
476 float length;
477
481
483 float hertz;
484
487
490
493
496
499
502
505
508
510 void* userData;
511
515
519
556
560
566typedef struct b2MouseJointDef
567{
570
573
576
578 float hertz;
579
582
584 float maxForce;
585
588
590 void* userData;
591
595
599
663
666B2_API b2PrismaticJointDef b2DefaultPrismaticJointDef();
667
737
741
786
790
851
855
882
892
910
920
930
949
973
984typedef struct b2BodyMoveEvent
985{
986 b2Transform transform;
987 b2BodyId bodyId;
988 void* userData;
989 bool fellAsleep;
991
1003
1007typedef struct b2ContactData
1008{
1009 b2ShapeId shapeIdA;
1010 b2ShapeId shapeIdB;
1011 b2Manifold manifold;
1013
1027typedef bool b2CustomFilterFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, void* context);
1028
1042typedef bool b2PreSolveFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold* manifold, void* context);
1043
1049typedef bool b2OverlapResultFcn(b2ShapeId shapeId, void* context);
1050
1066typedef float b2CastResultFcn(b2ShapeId shapeId, b2Vec2 point, b2Vec2 normal, float fraction, void* context);
1067
1069typedef enum b2HexColor
1070{
1071 b2_colorAliceBlue = 0xf0f8ff,
1072 b2_colorAntiqueWhite = 0xfaebd7,
1073 b2_colorAqua = 0x00ffff,
1074 b2_colorAquamarine = 0x7fffd4,
1075 b2_colorAzure = 0xf0ffff,
1076 b2_colorBeige = 0xf5f5dc,
1077 b2_colorBisque = 0xffe4c4,
1078 b2_colorBlack = 0x000000,
1079 b2_colorBlanchedAlmond = 0xffebcd,
1080 b2_colorBlue = 0x0000ff,
1081 b2_colorBlueViolet = 0x8a2be2,
1082 b2_colorBrown = 0xa52a2a,
1083 b2_colorBurlywood = 0xdeb887,
1084 b2_colorCadetBlue = 0x5f9ea0,
1085 b2_colorChartreuse = 0x7fff00,
1086 b2_colorChocolate = 0xd2691e,
1087 b2_colorCoral = 0xff7f50,
1088 b2_colorCornflowerBlue = 0x6495ed,
1089 b2_colorCornsilk = 0xfff8dc,
1090 b2_colorCrimson = 0xdc143c,
1091 b2_colorCyan = 0x00ffff,
1092 b2_colorDarkBlue = 0x00008b,
1093 b2_colorDarkCyan = 0x008b8b,
1094 b2_colorDarkGoldenrod = 0xb8860b,
1095 b2_colorDarkGray = 0xa9a9a9,
1096 b2_colorDarkGreen = 0x006400,
1097 b2_colorDarkKhaki = 0xbdb76b,
1098 b2_colorDarkMagenta = 0x8b008b,
1099 b2_colorDarkOliveGreen = 0x556b2f,
1100 b2_colorDarkOrange = 0xff8c00,
1101 b2_colorDarkOrchid = 0x9932cc,
1102 b2_colorDarkRed = 0x8b0000,
1103 b2_colorDarkSalmon = 0xe9967a,
1104 b2_colorDarkSeaGreen = 0x8fbc8f,
1105 b2_colorDarkSlateBlue = 0x483d8b,
1106 b2_colorDarkSlateGray = 0x2f4f4f,
1107 b2_colorDarkTurquoise = 0x00ced1,
1108 b2_colorDarkViolet = 0x9400d3,
1109 b2_colorDeepPink = 0xff1493,
1110 b2_colorDeepSkyBlue = 0x00bfff,
1111 b2_colorDimGray = 0x696969,
1112 b2_colorDodgerBlue = 0x1e90ff,
1113 b2_colorFirebrick = 0xb22222,
1114 b2_colorFloralWhite = 0xfffaf0,
1115 b2_colorForestGreen = 0x228b22,
1116 b2_colorFuchsia = 0xff00ff,
1117 b2_colorGainsboro = 0xdcdcdc,
1118 b2_colorGhostWhite = 0xf8f8ff,
1119 b2_colorGold = 0xffd700,
1120 b2_colorGoldenrod = 0xdaa520,
1121 b2_colorGray = 0xbebebe,
1122 b2_colorGray1 = 0x1a1a1a,
1123 b2_colorGray2 = 0x333333,
1124 b2_colorGray3 = 0x4d4d4d,
1125 b2_colorGray4 = 0x666666,
1126 b2_colorGray5 = 0x7f7f7f,
1127 b2_colorGray6 = 0x999999,
1128 b2_colorGray7 = 0xb3b3b3,
1129 b2_colorGray8 = 0xcccccc,
1130 b2_colorGray9 = 0xe5e5e5,
1131 b2_colorGreen = 0x00ff00,
1132 b2_colorGreenYellow = 0xadff2f,
1133 b2_colorHoneydew = 0xf0fff0,
1134 b2_colorHotPink = 0xff69b4,
1135 b2_colorIndianRed = 0xcd5c5c,
1136 b2_colorIndigo = 0x4b0082,
1137 b2_colorIvory = 0xfffff0,
1138 b2_colorKhaki = 0xf0e68c,
1139 b2_colorLavender = 0xe6e6fa,
1140 b2_colorLavenderBlush = 0xfff0f5,
1141 b2_colorLawnGreen = 0x7cfc00,
1142 b2_colorLemonChiffon = 0xfffacd,
1143 b2_colorLightBlue = 0xadd8e6,
1144 b2_colorLightCoral = 0xf08080,
1145 b2_colorLightCyan = 0xe0ffff,
1146 b2_colorLightGoldenrod = 0xeedd82,
1147 b2_colorLightGoldenrodYellow = 0xfafad2,
1148 b2_colorLightGray = 0xd3d3d3,
1149 b2_colorLightGreen = 0x90ee90,
1150 b2_colorLightPink = 0xffb6c1,
1151 b2_colorLightSalmon = 0xffa07a,
1152 b2_colorLightSeaGreen = 0x20b2aa,
1153 b2_colorLightSkyBlue = 0x87cefa,
1154 b2_colorLightSlateBlue = 0x8470ff,
1155 b2_colorLightSlateGray = 0x778899,
1156 b2_colorLightSteelBlue = 0xb0c4de,
1157 b2_colorLightYellow = 0xffffe0,
1158 b2_colorLime = 0x00ff00,
1159 b2_colorLimeGreen = 0x32cd32,
1160 b2_colorLinen = 0xfaf0e6,
1161 b2_colorMagenta = 0xff00ff,
1162 b2_colorMaroon = 0xb03060,
1163 b2_colorMediumAquamarine = 0x66cdaa,
1164 b2_colorMediumBlue = 0x0000cd,
1165 b2_colorMediumOrchid = 0xba55d3,
1166 b2_colorMediumPurple = 0x9370db,
1167 b2_colorMediumSeaGreen = 0x3cb371,
1168 b2_colorMediumSlateBlue = 0x7b68ee,
1169 b2_colorMediumSpringGreen = 0x00fa9a,
1170 b2_colorMediumTurquoise = 0x48d1cc,
1171 b2_colorMediumVioletRed = 0xc71585,
1172 b2_colorMidnightBlue = 0x191970,
1173 b2_colorMintCream = 0xf5fffa,
1174 b2_colorMistyRose = 0xffe4e1,
1175 b2_colorMoccasin = 0xffe4b5,
1176 b2_colorNavajoWhite = 0xffdead,
1177 b2_colorNavy = 0x000080,
1178 b2_colorNavyBlue = 0x000080,
1179 b2_colorOldLace = 0xfdf5e6,
1180 b2_colorOlive = 0x808000,
1181 b2_colorOliveDrab = 0x6b8e23,
1182 b2_colorOrange = 0xffa500,
1183 b2_colorOrangeRed = 0xff4500,
1184 b2_colorOrchid = 0xda70d6,
1185 b2_colorPaleGoldenrod = 0xeee8aa,
1186 b2_colorPaleGreen = 0x98fb98,
1187 b2_colorPaleTurquoise = 0xafeeee,
1188 b2_colorPaleVioletRed = 0xdb7093,
1189 b2_colorPapayaWhip = 0xffefd5,
1190 b2_colorPeachPuff = 0xffdab9,
1191 b2_colorPeru = 0xcd853f,
1192 b2_colorPink = 0xffc0cb,
1193 b2_colorPlum = 0xdda0dd,
1194 b2_colorPowderBlue = 0xb0e0e6,
1195 b2_colorPurple = 0xa020f0,
1196 b2_colorRebeccaPurple = 0x663399,
1197 b2_colorRed = 0xff0000,
1198 b2_colorRosyBrown = 0xbc8f8f,
1199 b2_colorRoyalBlue = 0x4169e1,
1200 b2_colorSaddleBrown = 0x8b4513,
1201 b2_colorSalmon = 0xfa8072,
1202 b2_colorSandyBrown = 0xf4a460,
1203 b2_colorSeaGreen = 0x2e8b57,
1204 b2_colorSeashell = 0xfff5ee,
1205 b2_colorSienna = 0xa0522d,
1206 b2_colorSilver = 0xc0c0c0,
1207 b2_colorSkyBlue = 0x87ceeb,
1208 b2_colorSlateBlue = 0x6a5acd,
1209 b2_colorSlateGray = 0x708090,
1210 b2_colorSnow = 0xfffafa,
1211 b2_colorSpringGreen = 0x00ff7f,
1212 b2_colorSteelBlue = 0x4682b4,
1213 b2_colorTan = 0xd2b48c,
1214 b2_colorTeal = 0x008080,
1215 b2_colorThistle = 0xd8bfd8,
1216 b2_colorTomato = 0xff6347,
1217 b2_colorTurquoise = 0x40e0d0,
1218 b2_colorViolet = 0xee82ee,
1219 b2_colorVioletRed = 0xd02090,
1220 b2_colorWheat = 0xf5deb3,
1221 b2_colorWhite = 0xffffff,
1222 b2_colorWhiteSmoke = 0xf5f5f5,
1223 b2_colorYellow = 0xffff00,
1224 b2_colorYellowGreen = 0x9acd32,
1225} b2HexColor;
1226
1229typedef struct b2DebugDraw
1230{
1232 void (*DrawPolygon)(const b2Vec2* vertices, int vertexCount, b2HexColor color, void* context);
1233
1235 void (*DrawSolidPolygon)(b2Transform transform, const b2Vec2* vertices, int vertexCount, float radius, b2HexColor color,
1236 void* context);
1237
1239 void (*DrawCircle)(b2Vec2 center, float radius, b2HexColor color, void* context);
1240
1242 void (*DrawSolidCircle)(b2Transform transform, float radius, b2HexColor color, void* context);
1243
1245 void (*DrawCapsule)(b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void* context);
1246
1248 void (*DrawSolidCapsule)(b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void* context);
1249
1251 void (*DrawSegment)(b2Vec2 p1, b2Vec2 p2, b2HexColor color, void* context);
1252
1254 void (*DrawTransform)(b2Transform transform, void* context);
1255
1257 void (*DrawPoint)(b2Vec2 p, float size, b2HexColor color, void* context);
1258
1260 void (*DrawString)(b2Vec2 p, const char* s, void* context);
1261
1264
1267
1270
1273
1276
1279
1282
1285
1288
1291
1294
1297
1299 void* context;
1300} b2DebugDraw;
float sleepThreshold
Sleep velocity threshold, default is 0.05 meter per second.
Definition types.h:178
bool automaticMass
Automatically compute mass and related properties on this body from shapes.
Definition types.h:203
b2Vec2 linearVelocity
The initial linear velocity of the body's origin. Typically in meters per second.
Definition types.h:156
bool fixedRotation
Should this body be prevented from rotating? Useful for characters.
Definition types.h:190
b2Vec2 position
The initial world position of the body.
Definition types.h:150
bool isEnabled
Used to disable a body. A disabled body does not move or collide.
Definition types.h:199
b2BodyType type
The body type: static, kinematic, or dynamic.
Definition types.h:145
float linearDamping
Linear damping is use to reduce the linear velocity.
Definition types.h:166
float angularVelocity
The initial angular velocity of the body. Typically in meters per second.
Definition types.h:159
float angle
The initial world angle of the body in radians.
Definition types.h:153
float gravityScale
Scale the gravity applied to this body. Non-dimensional.
Definition types.h:175
void * userData
Use this to store application specific body data.
Definition types.h:181
bool isBullet
Treat this body as high speed object that performs continuous collision detection against dynamic and...
Definition types.h:196
bool isAwake
Is this body initially awake or sleeping?
Definition types.h:187
bool enableSleep
Set this flag to false if this body should never fall asleep.
Definition types.h:184
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:206
float angularDamping
Angular damping is use to reduce the angular velocity.
Definition types.h:172
b2BodyType
The body simulation type.
Definition types.h:123
b2BodyDef b2DefaultBodyDef()
Use this to initialize your body definition.
@ b2_staticBody
zero mass, zero velocity, may be manually moved
Definition types.h:125
@ b2_kinematicBody
zero mass, velocity set by user, moved by solver
Definition types.h:128
@ b2_dynamicBody
positive mass, velocity determined by forces, moved by solver
Definition types.h:131
@ b2_bodyTypeCount
number of body types
Definition types.h:134
A body definition holds all the data needed to construct a rigid body.
Definition types.h:143
A contact manifold describes the contact points between colliding shapes.
Definition collision.h:492
float length
The rest length of this joint. Clamped to a stable minimum value.
Definition types.h:476
bool enableLimit
Enable/disable the joint limit.
Definition types.h:489
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:470
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:507
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:513
float dampingRatio
The spring linear damping ratio, non-dimensional.
Definition types.h:486
float maxMotorForce
The maximum motor force, usually in newtons.
Definition types.h:501
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:473
b2BodyId bodyIdB
The second attached body.
Definition types.h:467
void * userData
User data pointer.
Definition types.h:510
b2BodyId bodyIdA
The first attached body.
Definition types.h:464
bool enableSpring
Enable the distance constraint to behave like a spring.
Definition types.h:480
float minLength
Minimum length. Clamped to a stable minimum value.
Definition types.h:492
bool enableMotor
Enable/disable the joint motor.
Definition types.h:498
float maxLength
Maximum length. Must be greater than or equal to the minimum length.
Definition types.h:495
float hertz
The spring linear stiffness Hertz, cycles per second.
Definition types.h:483
float motorSpeed
The desired motor speed, usually in meters per second.
Definition types.h:504
b2DistanceJointDef b2DefaultDistanceJointDef()
Use this to initialize your joint definition.
Distance joint definition.
Definition types.h:462
int32_t moveCount
Number of move events.
Definition types.h:1001
b2ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:877
b2ContactBeginTouchEvent * beginEvents
Array of begin touch events.
Definition types.h:956
float approachSpeed
The speed the shapes are approaching. Always positive. Typically in meters per second.
Definition types.h:947
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:928
int32_t endCount
Number of end touch events.
Definition types.h:968
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:915
b2BodyMoveEvent * moveEvents
Array of move events.
Definition types.h:998
b2Vec2 normal
Normal vector pointing from shape A to shape B.
Definition types.h:944
b2ContactHitEvent * hitEvents
Array of hit events.
Definition types.h:962
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:918
b2SensorEndTouchEvent * endEvents
Array of sensor end touch events.
Definition types.h:902
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:925
int32_t endCount
The number of end touch events.
Definition types.h:908
b2ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:887
int32_t beginCount
Number of begin touch events.
Definition types.h:965
b2ShapeId visitorShapeId
The id of the dynamic shape that stopped touching the sensor shape.
Definition types.h:890
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:938
b2ContactEndTouchEvent * endEvents
Array of end touch events.
Definition types.h:959
b2Vec2 point
Point where the shapes hit.
Definition types.h:941
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:935
int32_t beginCount
The number of begin touch events.
Definition types.h:905
int32_t hitCount
Number of hit events.
Definition types.h:971
b2ShapeId visitorShapeId
The id of the dynamic shape that began touching the sensor shape.
Definition types.h:880
b2SensorBeginTouchEvent * beginEvents
Array of sensor begin touch events.
Definition types.h:899
Body events are buffered in the Box2D world and are available as event arrays after the time step is ...
Definition types.h:996
Body move events triggered when a body moves.
Definition types.h:985
A begin touch event is generated when two shapes begin touching.
Definition types.h:913
The contact data for two shapes.
Definition types.h:1008
An end touch event is generated when two shapes stop touching.
Definition types.h:923
Contact events are buffered in the Box2D world and are available as event arrays after the time step ...
Definition types.h:954
A hit touch event is generated when two shapes collide with a speed faster than the hit speed thresho...
Definition types.h:933
A begin touch event is generated when a shape starts to overlap a sensor shape.
Definition types.h:875
An end touch event is generated when a shape stops overlapping a sensor shape.
Definition types.h:885
Sensor events are buffered in the Box2D world and are available as begin/end overlap event arrays aft...
Definition types.h:897
Body id references a body instance. This should be treated as an opaque handle.
Definition id.h:44
Shape id references a shape instance. This should be treated as an opaque handle.
Definition id.h:52
b2JointType
Joint type enumeration.
Definition types.h:444
Axis-aligned bounding box.
Definition math_functions.h:52
A 2D rigid transform.
Definition math_functions.h:38
2D vector This can be used to represent a point or free vector
Definition math_functions.h:23
float maxForce
The maximum motor force in newtons.
Definition types.h:539
float correctionFactor
Position correction factor in the range [0,1].
Definition types.h:545
b2Vec2 linearOffset
Position of bodyB minus the position of bodyA, in bodyA's frame.
Definition types.h:533
float angularOffset
The bodyB angle minus bodyA angle in radians.
Definition types.h:536
b2BodyId bodyIdB
The second attached body.
Definition types.h:530
void * userData
User data pointer.
Definition types.h:551
b2BodyId bodyIdA
The first attached body.
Definition types.h:527
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:554
float maxTorque
The maximum motor torque in newton-meters.
Definition types.h:542
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:548
b2MotorJointDef b2DefaultMotorJointDef()
Use this to initialize your joint definition.
A motor joint is used to control the relative motion between two bodies.
Definition types.h:525
void * userData
User data pointer.
Definition types.h:590
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:587
b2BodyId bodyIdB
The second attached body.
Definition types.h:572
float maxForce
Maximum force, typically in newtons.
Definition types.h:584
float hertz
Stiffness in hertz.
Definition types.h:578
b2Vec2 target
The initial target point in world space.
Definition types.h:575
float dampingRatio
Damping ratio, non-dimensional.
Definition types.h:581
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:593
b2BodyId bodyIdA
The first attached body.
Definition types.h:569
b2MouseJointDef b2DefaultMouseJointDef()
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:567
void * userData
User data pointer.
Definition types.h:658
float lowerTranslation
The lower translation limit.
Definition types.h:640
bool enableMotor
Enable/disable the joint motor.
Definition types.h:646
float motorSpeed
The desired motor speed, typically in meters per second.
Definition types.h:652
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:619
b2BodyId bodyIdA
The first attached body.
Definition types.h:610
bool enableSpring
Enable a linear spring along the prismatic joint axis.
Definition types.h:628
float upperTranslation
The upper translation limit.
Definition types.h:643
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:634
bool enableLimit
Enable/disable the joint limit.
Definition types.h:637
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:631
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:616
float referenceAngle
The constrained angle between the bodies: bodyB_angle - bodyA_angle.
Definition types.h:625
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:661
b2BodyId bodyIdB
The second attached body.
Definition types.h:613
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:655
b2Vec2 localAxisA
The local translation unit axis in bodyA.
Definition types.h:622
float maxMotorForce
The maximum motor force, typically in newtons.
Definition types.h:649
Prismatic joint definition.
Definition types.h:608
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:705
float lowerAngle
The lower angle for the joint limit in radians.
Definition types.h:711
bool enableLimit
A flag to enable joint limits.
Definition types.h:708
float motorSpeed
The desired motor speed in radians per second.
Definition types.h:723
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:692
void * userData
User data pointer.
Definition types.h:732
float upperAngle
The upper angle for the joint limit in radians.
Definition types.h:714
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:689
float referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians).
Definition types.h:696
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:729
bool enableSpring
Enable a rotational spring on the revolute hinge axis.
Definition types.h:699
b2BodyId bodyIdA
The first attached body.
Definition types.h:683
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:702
bool enableMotor
A flag to enable the joint motor.
Definition types.h:717
b2BodyId bodyIdB
The second attached body.
Definition types.h:686
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:735
float maxMotorTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:720
float drawSize
Scale the debug draw.
Definition types.h:726
b2RevoluteJointDef b2DefaultRevoluteJointDef()
Use this to initialize your joint definition.
Revolute joint definition.
Definition types.h:681
b2Filter filter
Contact filtering data.
Definition types.h:379
bool isLoop
Indicates a closed chain formed by connecting the first and last points.
Definition types.h:382
float restitution
The restitution (bounce) usually in the range [0,1].
Definition types.h:309
uint32_t categoryBits
The collision category bits of this query. Normally you would just set one bit.
Definition types.h:261
void * userData
Use this to store application specific shape data.
Definition types.h:364
bool enablePreSolveEvents
Enable pre-solve contact events for this shape.
Definition types.h:331
float friction
The Coulomb (dry) friction coefficient, usually in the range [0,1].
Definition types.h:306
int32_t groupIndex
Collision groups allow a certain group of objects to never collide (negative) or always collide (posi...
Definition types.h:247
uint32_t maskBits
The collision mask bits.
Definition types.h:239
bool isSensor
A sensor shape generates overlap events but never generates a collision response.
Definition types.h:318
void * userData
Use this to store application specific shape data.
Definition types.h:303
uint32_t categoryBits
The collision category bits.
Definition types.h:230
const b2Vec2 * points
An array of at least 4 points. These are cloned and may be temporary.
Definition types.h:367
bool enableContactEvents
Enable contact events for this shape. Only applies to kinematic and dynamic bodies....
Definition types.h:324
float restitution
The restitution (elasticity) usually in the range [0,1].
Definition types.h:376
float friction
The friction coefficient, usually in the range [0,1].
Definition types.h:373
bool forceContactCreation
Normally shapes on static bodies don't invoke contact creation when they are added to the world.
Definition types.h:336
bool enableHitEvents
Enable hit events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors.
Definition types.h:327
b2Filter filter
Collision filtering data.
Definition types.h:315
float density
The density, usually in kg/m^2.
Definition types.h:312
uint32_t maskBits
The collision mask bits.
Definition types.h:265
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:339
bool enableSensorEvents
Enable sensor events for this shape. Only applies to kinematic and dynamic bodies....
Definition types.h:321
int32_t count
The point count, must be 4 or more.
Definition types.h:370
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:385
b2ShapeDef b2DefaultShapeDef()
Use this to initialize your shape definition.
b2ChainDef b2DefaultChainDef()
Use this to initialize your chain definition.
b2ShapeType
Shape type.
Definition types.h:275
b2Filter b2DefaultFilter()
Use this to initialize your filter.
b2QueryFilter b2DefaultQueryFilter()
Use this to initialize your query filter.
@ b2_shapeTypeCount
The number of shape types.
Definition types.h:292
@ b2_polygonShape
A convex polygon.
Definition types.h:286
@ b2_smoothSegmentShape
A smooth segment owned by a chain shape.
Definition types.h:289
@ b2_circleShape
A circle with an offset.
Definition types.h:277
@ b2_segmentShape
A line segment.
Definition types.h:283
@ b2_capsuleShape
A capsule is an extruded circle.
Definition types.h:280
Used to create a chain of edges.
Definition types.h:362
This is used to filter collision on shapes.
Definition types.h:217
The query filter is used to filter collisions between queries and shapes.
Definition types.h:259
Used to create a shape.
Definition types.h:301
float linearHertz
Linear stiffness expressed as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:766
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:757
b2BodyId bodyIdB
The second attached body.
Definition types.h:754
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:760
void * userData
User data pointer.
Definition types.h:781
float referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians)
Definition types.h:763
b2BodyId bodyIdA
The first attached body.
Definition types.h:751
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:784
float angularHertz
Angular stiffness as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:769
float angularDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:775
float linearDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:772
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:778
b2WeldJointDef b2DefaultWeldJointDef()
Use this to initialize your joint definition.
Weld joint definition.
Definition types.h:749
bool enableSpring
Enable a linear spring along the local axis.
Definition types.h:816
float hertz
Spring stiffness in Hertz.
Definition types.h:819
float motorSpeed
The desired motor speed in radians per second.
Definition types.h:840
bool enableLimit
Enable/disable the joint linear limit.
Definition types.h:825
float upperTranslation
The upper translation limit.
Definition types.h:831
float lowerTranslation
The lower translation limit.
Definition types.h:828
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:843
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:849
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:810
float dampingRatio
Spring damping ratio, non-dimensional.
Definition types.h:822
b2BodyId bodyIdB
The second attached body.
Definition types.h:804
bool enableMotor
Enable/disable the joint rotational motor.
Definition types.h:834
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:807
b2BodyId bodyIdA
The first attached body.
Definition types.h:801
void * userData
User data pointer.
Definition types.h:846
float maxMotorTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:837
b2Vec2 localAxisA
The local translation unit axis in bodyA.
Definition types.h:813
b2WheelJointDef b2DefaultWheelJointDef()
Use this to initialize your joint definition.
Wheel joint definition.
Definition types.h:799
float contactHertz
Contact stiffness. Cycles per second.
Definition types.h:80
float contactDampingRatio
Contact bounciness. Non-dimensional.
Definition types.h:83
bool enableContinous
Enable continuous collision.
Definition types.h:95
b2FinishTaskCallback * finishTask
Function to finish a task.
Definition types.h:106
void * userTaskContext
User context that is provided to enqueueTask and finishTask.
Definition types.h:109
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 enableSleep
Can bodies go to sleep to improve performance.
Definition types.h:92
float restitutionThreshold
Restitution velocity threshold, usually in m/s.
Definition types.h:71
int32_t workerCount
Number of workers to use with the provided task system.
Definition types.h:100
float contactPushoutVelocity
This parameter controls how fast overlap is resolved and has units of meters per second.
Definition types.h:74
float jointHertz
Joint stiffness. Cycles per second.
Definition types.h:86
int32_t internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:112
b2EnqueueTaskCallback * enqueueTask
Function to spawn tasks.
Definition types.h:103
float jointDampingRatio
Joint bounciness. Non-dimensional.
Definition types.h:89
bool b2OverlapResultFcn(b2ShapeId shapeId, void *context)
Prototype callback for overlap queries.
Definition types.h:1049
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
b2WorldDef b2DefaultWorldDef()
Use this to initialize your world definition.
bool b2PreSolveFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold *manifold, void *context)
Prototype for a pre-solve callback.
Definition types.h:1042
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:1066
bool b2CustomFilterFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, void *context)
Prototype for a contact filter callback.
Definition types.h:1027
void b2FinishTaskCallback(void *userTask, void *userContext)
Finishes a user task object that wraps a Box2D task.
Definition types.h:48
Result from b2World_RayCastClosest.
Definition types.h:53
World definition used to create a simulation world.
Definition types.h:65
This struct holds callbacks you can implement to draw a Box2D world.
Definition types.h:1230
b2AABB drawingBounds
Bounds to use if restricting drawing to a rectangular region.
Definition types.h:1263
bool drawJoints
Option to draw joints.
Definition types.h:1272
bool drawFrictionImpulses
Option to draw contact friction impulses.
Definition types.h:1296
void(* DrawSegment)(b2Vec2 p1, b2Vec2 p2, b2HexColor color, void *context)
Draw a line segment.
Definition types.h:1251
bool drawContactImpulses
Option to draw contact normal impulses.
Definition types.h:1293
bool drawContacts
Option to draw contact points.
Definition types.h:1284
void(* DrawSolidCircle)(b2Transform transform, float radius, b2HexColor color, void *context)
Draw a solid circle.
Definition types.h:1242
void * context
User context that is passed as an argument to drawing callback functions.
Definition types.h:1299
void(* DrawSolidCapsule)(b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void *context)
Draw a solid capsule.
Definition types.h:1248
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:1235
bool drawShapes
Option to draw shapes.
Definition types.h:1269
bool drawJointExtras
Option to draw additional information for joints.
Definition types.h:1275
void(* DrawString)(b2Vec2 p, const char *s, void *context)
Draw a string.
Definition types.h:1260
void(* DrawCapsule)(b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void *context)
Draw a capsule.
Definition types.h:1245
bool drawAABBs
Option to draw the bounding boxes for shapes.
Definition types.h:1278
bool drawGraphColors
Option to visualize the graph coloring used for contacts and joints.
Definition types.h:1287
bool drawContactNormals
Option to draw contact normals.
Definition types.h:1290
void(* DrawPoint)(b2Vec2 p, float size, b2HexColor color, void *context)
Draw a point.
Definition types.h:1257
bool useDrawingBounds
Option to restrict drawing to a rectangular region. May suffer from unstable depth sorting.
Definition types.h:1266
void(* DrawTransform)(b2Transform transform, void *context)
Draw a transform. Choose your own length scale.
Definition types.h:1254
bool drawMass
Option to draw the mass and center of mass of dynamic bodies.
Definition types.h:1281
void(* DrawCircle)(b2Vec2 center, float radius, b2HexColor color, void *context)
Draw a circle.
Definition types.h:1239
void(* DrawPolygon)(const b2Vec2 *vertices, int vertexCount, b2HexColor color, void *context)
Draw a closed polygon provided in CCW order.
Definition types.h:1232