Box2D 3.2.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_types.h"
10
11#include <stdbool.h>
12#include <stdint.h>
13
16#define B2_DEFAULT_CATEGORY_BITS 1
17
20#define B2_DEFAULT_MASK_BITS UINT64_MAX
21
26typedef void b2TaskCallbackFcn( void* taskContext );
27
32typedef void* b2EnqueueTaskCallbackFcn( b2TaskCallbackFcn* task, void* taskContext,
33 void* userContext );
34
37typedef void b2FinishTaskCallbackFcn( void* userTask, void* userContext );
38
43typedef float b2FrictionCallbackFcn( float frictionA, uint64_t userMaterialIdA, float frictionB,
44 uint64_t userMaterialIdB );
45
50typedef float b2RestitutionCallbackFcn( float restitutionA, uint64_t userMaterialIdA,
51 float restitutionB, uint64_t userMaterialIdB );
52
56typedef struct b2RayResult
57{
60
63
66
68 float fraction;
69
72
75
77 bool hit;
79
103
181
185
203
206typedef struct b2MotionLocks
207{
210
213
217
313
317
321typedef struct b2Filter
322{
335 uint64_t categoryBits;
336
343 uint64_t maskBits;
344
351} b2Filter;
352
356
361typedef struct b2QueryFilter
362{
364 uint64_t categoryBits;
365
368 uint64_t maskBits;
370
374
397
401typedef struct b2SurfaceMaterial
402{
404 float friction;
405
409
412
415
419
421 uint32_t customColor;
423
427
488
492
548
552
555typedef struct b2Profile
556{
557 float step;
558 float pairs;
559 float collide;
560 float solve;
561 float solverSetup;
562 float constraints;
563 float prepareConstraints;
564 float integrateVelocities;
565 float warmStart;
566 float solveImpulses;
567 float integratePositions;
568 float relaxImpulses;
569 float restitution;
570 float storeImpulses;
571 float splitIslands;
572 float transforms;
573 float sensorHits;
574 float jointEvents;
575 float hitEvents;
576 float refit;
577 float bullets;
578 float sleepIslands;
579 float sensors;
580} b2Profile;
581
584typedef struct b2Counters
585{
586 size_t byteCount;
587 int bodyCount;
588 int shapeCount;
589 int contactCount;
590 int jointCount;
591 int islandCount;
592 int stackUsed;
593 int staticTreeHeight;
594 int treeHeight;
595 int taskCount;
596 int colorCounts[24];
597
600
603
604} b2Counters;
605
623
665
669typedef struct b2DistanceJointDef
670{
673
675 float length;
676
680
683
686
688 float hertz;
689
692
695
698
701
704
707
710
714
718
730
734
776
780
798
802
805typedef struct b2PogoJointDef
806{
809
812
814 float hertz;
815
818
821
824
827
830 float impulse;
831
834 float velocity;
835
839
843
887
891
895typedef struct b2RevoluteJointDef
896{
899
902
905
907 float hertz;
908
911
914
917
920
923
926
929
933
937
962
966
970typedef struct b2WheelJointDef
971{
974
977
979 float hertz;
980
983
986
989
992
995
998
1001
1005
1009
1013typedef struct b2ExplosionDef
1014{
1016 uint64_t maskBits;
1017
1020
1022 float radius;
1023
1025 float falloff;
1026
1032
1036
1054
1064
1083
1101
1115
1136
1164
1187
1211
1222
1225typedef struct b2JointEvent
1226{
1229
1232} b2JointEvent;
1233
1244
1246
1266
1277typedef bool b2CustomFilterCallbackFcn( b2ShapeId shapeIdA, b2ShapeId shapeIdB, void* context );
1278
1290typedef void b2PreSolveCallbackFcn( b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold* manifold,
1291 void* context );
1292
1303typedef bool b2PreContinuousCallbackFcn( b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Pos point,
1304 b2Vec2 normal, void* context );
1305
1310typedef bool b2OverlapResultCallbackFcn( b2ShapeId shapeId, void* context );
1311
1329typedef float b2CastResultCallbackFcn( b2ShapeId shapeId, b2Pos point, b2Vec2 normal,
1330 float fraction, void* context );
1331
1334typedef bool b2PlaneResultCallbackFcn( b2ShapeId shapeId, const b2PlaneResult* plane,
1335 void* context );
1336
1340
1346typedef enum b2HexColor
1347{
1348 b2_colorAliceBlue = 0xF0F8FF,
1349 b2_colorAntiqueWhite = 0xFAEBD7,
1350 b2_colorAqua = 0x00FFFF,
1351 b2_colorAquamarine = 0x7FFFD4,
1352 b2_colorAzure = 0xF0FFFF,
1353 b2_colorBeige = 0xF5F5DC,
1354 b2_colorBisque = 0xFFE4C4,
1355 b2_colorBlack = 0x000000,
1356 b2_colorBlanchedAlmond = 0xFFEBCD,
1357 b2_colorBlue = 0x0000FF,
1358 b2_colorBlueViolet = 0x8A2BE2,
1359 b2_colorBrown = 0xA52A2A,
1360 b2_colorBurlywood = 0xDEB887,
1361 b2_colorCadetBlue = 0x5F9EA0,
1362 b2_colorChartreuse = 0x7FFF00,
1363 b2_colorChocolate = 0xD2691E,
1364 b2_colorCoral = 0xFF7F50,
1365 b2_colorCornflowerBlue = 0x6495ED,
1366 b2_colorCornsilk = 0xFFF8DC,
1367 b2_colorCrimson = 0xDC143C,
1368 b2_colorCyan = 0x00FFFF,
1369 b2_colorDarkBlue = 0x00008B,
1370 b2_colorDarkCyan = 0x008B8B,
1371 b2_colorDarkGoldenRod = 0xB8860B,
1372 b2_colorDarkGray = 0xA9A9A9,
1373 b2_colorDarkGreen = 0x006400,
1374 b2_colorDarkKhaki = 0xBDB76B,
1375 b2_colorDarkMagenta = 0x8B008B,
1376 b2_colorDarkOliveGreen = 0x556B2F,
1377 b2_colorDarkOrange = 0xFF8C00,
1378 b2_colorDarkOrchid = 0x9932CC,
1379 b2_colorDarkRed = 0x8B0000,
1380 b2_colorDarkSalmon = 0xE9967A,
1381 b2_colorDarkSeaGreen = 0x8FBC8F,
1382 b2_colorDarkSlateBlue = 0x483D8B,
1383 b2_colorDarkSlateGray = 0x2F4F4F,
1384 b2_colorDarkTurquoise = 0x00CED1,
1385 b2_colorDarkViolet = 0x9400D3,
1386 b2_colorDeepPink = 0xFF1493,
1387 b2_colorDeepSkyBlue = 0x00BFFF,
1388 b2_colorDimGray = 0x696969,
1389 b2_colorDodgerBlue = 0x1E90FF,
1390 b2_colorFireBrick = 0xB22222,
1391 b2_colorFloralWhite = 0xFFFAF0,
1392 b2_colorForestGreen = 0x228B22,
1393 b2_colorFuchsia = 0xFF00FF,
1394 b2_colorGainsboro = 0xDCDCDC,
1395 b2_colorGhostWhite = 0xF8F8FF,
1396 b2_colorGold = 0xFFD700,
1397 b2_colorGoldenRod = 0xDAA520,
1398 b2_colorGray = 0x808080,
1399 b2_colorGreen = 0x008000,
1400 b2_colorGreenYellow = 0xADFF2F,
1401 b2_colorHoneyDew = 0xF0FFF0,
1402 b2_colorHotPink = 0xFF69B4,
1403 b2_colorIndianRed = 0xCD5C5C,
1404 b2_colorIndigo = 0x4B0082,
1405 b2_colorIvory = 0xFFFFF0,
1406 b2_colorKhaki = 0xF0E68C,
1407 b2_colorLavender = 0xE6E6FA,
1408 b2_colorLavenderBlush = 0xFFF0F5,
1409 b2_colorLawnGreen = 0x7CFC00,
1410 b2_colorLemonChiffon = 0xFFFACD,
1411 b2_colorLightBlue = 0xADD8E6,
1412 b2_colorLightCoral = 0xF08080,
1413 b2_colorLightCyan = 0xE0FFFF,
1414 b2_colorLightGoldenRodYellow = 0xFAFAD2,
1415 b2_colorLightGray = 0xD3D3D3,
1416 b2_colorLightGreen = 0x90EE90,
1417 b2_colorLightPink = 0xFFB6C1,
1418 b2_colorLightSalmon = 0xFFA07A,
1419 b2_colorLightSeaGreen = 0x20B2AA,
1420 b2_colorLightSkyBlue = 0x87CEFA,
1421 b2_colorLightSlateGray = 0x778899,
1422 b2_colorLightSteelBlue = 0xB0C4DE,
1423 b2_colorLightYellow = 0xFFFFE0,
1424 b2_colorLime = 0x00FF00,
1425 b2_colorLimeGreen = 0x32CD32,
1426 b2_colorLinen = 0xFAF0E6,
1427 b2_colorMagenta = 0xFF00FF,
1428 b2_colorMaroon = 0x800000,
1429 b2_colorMediumAquaMarine = 0x66CDAA,
1430 b2_colorMediumBlue = 0x0000CD,
1431 b2_colorMediumOrchid = 0xBA55D3,
1432 b2_colorMediumPurple = 0x9370DB,
1433 b2_colorMediumSeaGreen = 0x3CB371,
1434 b2_colorMediumSlateBlue = 0x7B68EE,
1435 b2_colorMediumSpringGreen = 0x00FA9A,
1436 b2_colorMediumTurquoise = 0x48D1CC,
1437 b2_colorMediumVioletRed = 0xC71585,
1438 b2_colorMidnightBlue = 0x191970,
1439 b2_colorMintCream = 0xF5FFFA,
1440 b2_colorMistyRose = 0xFFE4E1,
1441 b2_colorMoccasin = 0xFFE4B5,
1442 b2_colorNavajoWhite = 0xFFDEAD,
1443 b2_colorNavy = 0x000080,
1444 b2_colorOldLace = 0xFDF5E6,
1445 b2_colorOlive = 0x808000,
1446 b2_colorOliveDrab = 0x6B8E23,
1447 b2_colorOrange = 0xFFA500,
1448 b2_colorOrangeRed = 0xFF4500,
1449 b2_colorOrchid = 0xDA70D6,
1450 b2_colorPaleGoldenRod = 0xEEE8AA,
1451 b2_colorPaleGreen = 0x98FB98,
1452 b2_colorPaleTurquoise = 0xAFEEEE,
1453 b2_colorPaleVioletRed = 0xDB7093,
1454 b2_colorPapayaWhip = 0xFFEFD5,
1455 b2_colorPeachPuff = 0xFFDAB9,
1456 b2_colorPeru = 0xCD853F,
1457 b2_colorPink = 0xFFC0CB,
1458 b2_colorPlum = 0xDDA0DD,
1459 b2_colorPowderBlue = 0xB0E0E6,
1460 b2_colorPurple = 0x800080,
1461 b2_colorRebeccaPurple = 0x663399,
1462 b2_colorRed = 0xFF0000,
1463 b2_colorRosyBrown = 0xBC8F8F,
1464 b2_colorRoyalBlue = 0x4169E1,
1465 b2_colorSaddleBrown = 0x8B4513,
1466 b2_colorSalmon = 0xFA8072,
1467 b2_colorSandyBrown = 0xF4A460,
1468 b2_colorSeaGreen = 0x2E8B57,
1469 b2_colorSeaShell = 0xFFF5EE,
1470 b2_colorSienna = 0xA0522D,
1471 b2_colorSilver = 0xC0C0C0,
1472 b2_colorSkyBlue = 0x87CEEB,
1473 b2_colorSlateBlue = 0x6A5ACD,
1474 b2_colorSlateGray = 0x708090,
1475 b2_colorSnow = 0xFFFAFA,
1476 b2_colorSpringGreen = 0x00FF7F,
1477 b2_colorSteelBlue = 0x4682B4,
1478 b2_colorTan = 0xD2B48C,
1479 b2_colorTeal = 0x008080,
1480 b2_colorThistle = 0xD8BFD8,
1481 b2_colorTomato = 0xFF6347,
1482 b2_colorTurquoise = 0x40E0D0,
1483 b2_colorViolet = 0xEE82EE,
1484 b2_colorWheat = 0xF5DEB3,
1485 b2_colorWhite = 0xFFFFFF,
1486 b2_colorWhiteSmoke = 0xF5F5F5,
1487 b2_colorYellow = 0xFFFF00,
1488 b2_colorYellowGreen = 0x9ACD32,
1489
1490 b2_colorBox2DRed = 0xDC3132,
1491 b2_colorBox2DBlue = 0x30AEBF,
1492 b2_colorBox2DGreen = 0x8CC924,
1493 b2_colorBox2DYellow = 0xFFEE8C
1494} b2HexColor;
1495
1499B2_API b2HexColor b2GetGraphColor( int index );
1500
1506typedef struct b2DebugDraw
1507{
1509 void ( *DrawPolygonFcn )( b2WorldTransform transform, const b2Vec2* vertices, int vertexCount,
1510 b2HexColor color, void* context );
1511
1513 void ( *DrawSolidPolygonFcn )( b2WorldTransform transform, const b2Vec2* vertices,
1514 int vertexCount, float radius, b2HexColor color, void* context );
1515
1517 void ( *DrawCircleFcn )( b2Pos center, float radius, b2HexColor color, void* context );
1518
1520 void ( *DrawSolidCircleFcn )( b2WorldTransform transform, b2Vec2 center, float radius,
1521 b2HexColor color, void* context );
1522
1524 void ( *DrawSolidCapsuleFcn )( b2Pos p1, b2Pos p2, float radius, b2HexColor color,
1525 void* context );
1526
1528 void ( *DrawLineFcn )( b2Pos p1, b2Pos p2, b2HexColor color, void* context );
1529
1531 void ( *DrawTransformFcn )( b2WorldTransform transform, void* context );
1532
1534 void ( *DrawPointFcn )( b2Pos p, float size, b2HexColor color, void* context );
1535
1537 void ( *DrawStringFcn )( b2Pos p, const char* s, b2HexColor color, void* context );
1538
1541 void ( *DrawBoundsFcn )( b2AABB aabb, b2HexColor color, void* context );
1542
1545
1548
1551
1554
1557
1560
1563
1566
1569
1572
1575
1578
1581
1584
1587
1590
1593
1596
1598 void* context;
1599} b2DebugDraw;
1600
1605
1608typedef struct b2Replay b2Replay;
1609
1621
1625{
1626 b2_replayQueryOverlapAABB,
1627 b2_replayQueryOverlapShape,
1628 b2_replayQueryCastRay,
1629 b2_replayQueryCastShape,
1630 b2_replayQueryCollideMover,
1631 b2_replayQueryCastRayClosest,
1632 b2_replayQueryCastMover,
1634
1646
bool linearX
Prevent translation along the x-axis.
Definition types.h:209
float sleepThreshold
Sleep speed threshold, default is 0.05 meters per second.
Definition types.h:256
b2Vec2 linearVelocity
The initial linear velocity of the body's origin. Usually in meters per second.
Definition types.h:236
const char * name
Optional body name for debugging. Up to B2_NAME_LENGTH characters.
Definition types.h:267
b2MotionLocks motionLocks
Motion locks to restrict linear and angular movement.
Definition types.h:274
bool enableContactRecycling
Enable contact recycling.
Definition types.h:308
b2Rot rotation
The initial world rotation of the body. Use b2MakeRot() if you have an angle.
Definition types.h:233
bool allowFastRotation
This allows this body to bypass rotational speed limits.
Definition types.h:304
bool isEnabled
Used to disable a body. A disabled body does not move or collide.
Definition types.h:300
b2BodyType type
The body type: static, kinematic, or dynamic.
Definition types.h:225
float linearDamping
Linear damping is used to reduce the linear velocity.
Definition types.h:245
float angularVelocity
The initial angular velocity of the body. Radians per second.
Definition types.h:239
bool angularZ
Prevent rotation around the z-axis.
Definition types.h:215
bool linearY
Prevent translation along the y-axis.
Definition types.h:212
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:311
float gravityScale
Scale the gravity applied to this body. Non-dimensional.
Definition types.h:253
b2Pos position
The initial world position of the body.
Definition types.h:230
float safetyFactor
Continuous collision safety factor.
Definition types.h:264
void * userData
Use this to store application specific body data.
Definition types.h:270
bool isBullet
Treat this dynamic body as a high speed object that performs continuous collision detection against d...
Definition types.h:297
bool isAwake
Is this body initially awake or sleeping?
Definition types.h:280
bool enableSleep
Set this flag to false if this body should never fall asleep.
Definition types.h:277
float angularDamping
Angular damping is used to reduce the angular velocity.
Definition types.h:250
b2BodyType
The body simulation type.
Definition types.h:190
b2BodyDef b2DefaultBodyDef(void)
Use this to initialize your body definition.
@ b2_staticBody
zero mass, zero velocity, may be manually moved
Definition types.h:192
@ b2_kinematicBody
zero mass, velocity set by user, moved by solver
Definition types.h:195
@ b2_dynamicBody
positive mass, velocity determined by forces, moved by solver
Definition types.h:198
@ b2_bodyTypeCount
number of body types
Definition types.h:201
A body definition holds all the data needed to construct a rigid body.
Definition types.h:223
Motion locks to restrict the body movement.
Definition types.h:207
b2Filter filter
Contact filtering data.
Definition types.h:537
const b2SurfaceMaterial * materials
One material for the whole chain or one for each segment. Cloned.
Definition types.h:531
int pointCount
The point count.
Definition types.h:520
bool isLoop
Indicates a closed chain formed by connecting the first and last point.
Definition types.h:540
void * userData
Use this to store application specific shape data.
Definition types.h:512
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:546
int materialCount
The material count. Must be 1 or the segment count.
Definition types.h:534
b2Vec2 ghost1
Leading ghost point for an open chain.
Definition types.h:524
const b2Vec2 * points
Array of chain points.
Definition types.h:516
bool enableSensorEvents
Enable sensors to detect this chain. False by default.
Definition types.h:543
b2Vec2 ghost2
Ending ghost point for an open chain.
Definition types.h:528
b2ChainDef b2DefaultChainDef(void)
Use this to initialize your chain definition.
Used to create a chain of line segments.
Definition types.h:510
bool b2PlaneResultCallbackFcn(b2ShapeId shapeId, const b2PlaneResult *plane, void *context)
Used to collect collision planes for character movers.
Definition types.h:1334
These are the collision planes returned from b2World_CollideMover.
Definition collision.h:835
A contact manifold describes the contact points between colliding shapes.
Definition collision.h:579
b2ShapeId shapeIdB
The second shape id.
Definition types.h:1261
b2ContactId contactId
The contact id.
Definition types.h:1255
b2ShapeId shapeIdA
The first shape id.
Definition types.h:1258
b2Manifold manifold
The manifold copied from the contact.
Definition types.h:1264
The contact data for two shapes.
Definition types.h:1252
b2HexColor b2GetGraphColor(int index)
Get the visualization color assigned to a constraint graph color slot.
b2HexColor
These colors are used for debug draw and mostly match the named SVG colors.
Definition types.h:1347
b2DebugDraw b2DefaultDebugDraw(void)
Use this to initialize your drawing interface.
float length
The rest length of this joint. Clamped to a stable minimum value.
Definition types.h:675
bool enableLimit
Enable/disable the joint limit.
Definition types.h:694
b2JointDef base
Base joint definition.
Definition types.h:672
float dampingRatio
The spring linear damping ratio, non-dimensional.
Definition types.h:691
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:712
float maxMotorForce
The maximum motor force, usually in newtons.
Definition types.h:706
bool enableSpring
Enable the distance constraint to behave like a spring.
Definition types.h:679
float lowerSpringForce
The lower spring force controls how much tension it can sustain.
Definition types.h:682
float minLength
Minimum length for limit. Clamped to a stable minimum value.
Definition types.h:697
float upperSpringForce
The upper spring force controls how much compression it can sustain.
Definition types.h:685
bool enableMotor
Enable/disable the joint motor.
Definition types.h:703
float maxLength
Maximum length for limit. Must be greater than or equal to the minimum length.
Definition types.h:700
float hertz
The spring linear stiffness Hertz, cycles per second.
Definition types.h:688
float motorSpeed
The desired motor speed, usually in meters per second.
Definition types.h:709
b2DistanceJointDef b2DefaultDistanceJointDef(void)
Use this to initialize your joint definition.
Distance joint definition Connects a point on body A with a point on body B by a segment.
Definition types.h:670
bool fellAsleep
Did the body fall asleep this time step?
Definition types.h:1209
b2Pos point
Point where the shapes hit.
Definition types.h:1156
int hitCount
Number of hit events.
Definition types.h:1185
b2ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:1059
int beginCount
The number of begin touch events.
Definition types.h:1096
b2ContactBeginTouchEvent * beginEvents
Array of begin touch events.
Definition types.h:1170
float approachSpeed
The speed the shapes are approaching. Always positive. Typically in meters per second.
Definition types.h:1162
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:1129
void * userData
The body user data.
Definition types.h:1200
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:1106
b2BodyId bodyId
The id of the body that moved.
Definition types.h:1206
b2ContactId contactId
Id of the contact.
Definition types.h:1134
b2ContactId contactId
The transient contact id.
Definition types.h:1113
b2JointEvent * jointEvents
Array of events.
Definition types.h:1239
b2BodyMoveEvent * moveEvents
Array of move events.
Definition types.h:1217
b2Vec2 normal
Normal vector pointing from shape A to shape B.
Definition types.h:1159
b2ContactHitEvent * hitEvents
Array of hit events.
Definition types.h:1176
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:1109
b2SensorEndTouchEvent * endEvents
Array of sensor end touch events.
Definition types.h:1093
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:1124
b2ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:1075
b2ShapeId visitorShapeId
The id of the shape that stopped touching the sensor shape.
Definition types.h:1080
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:1145
b2ContactId contactId
Id of the contact.
Definition types.h:1150
int endCount
The number of end touch events.
Definition types.h:1099
b2ContactEndTouchEvent * endEvents
Array of end touch events.
Definition types.h:1173
int beginCount
Number of begin touch events.
Definition types.h:1179
int endCount
Number of end touch events.
Definition types.h:1182
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:1142
b2JointId jointId
The joint id.
Definition types.h:1228
void * userData
The user data from the joint for convenience.
Definition types.h:1231
b2ShapeId visitorShapeId
The id of the shape that began touching the sensor shape.
Definition types.h:1062
b2WorldTransform transform
The world transform of the body.
Definition types.h:1203
int count
Number of events.
Definition types.h:1242
int moveCount
Number of move events.
Definition types.h:1220
b2SensorBeginTouchEvent * beginEvents
Array of sensor begin touch events.
Definition types.h:1090
Body events are buffered in the Box2D world and are available as event arrays after the time step is ...
Definition types.h:1215
Body move events triggered when a body moves.
Definition types.h:1198
A begin touch event is generated when two shapes begin touching.
Definition types.h:1104
An end touch event is generated when two shapes stop touching.
Definition types.h:1120
Contact events are buffered in the Box2D world and are available as event arrays after the time step ...
Definition types.h:1168
A hit event is generated when two shapes collide with a speed faster than the hit event threshold.
Definition types.h:1140
Joint events report joints that are awake and have a force and/or torque exceeding the threshold.
Definition types.h:1226
Joint events are buffered in the world and are available as event arrays after the time step is compl...
Definition types.h:1237
A begin touch event is generated when a shape starts to overlap a sensor shape.
Definition types.h:1057
An end touch event is generated when a shape stops overlapping a sensor shape.
Definition types.h:1071
Sensor events are buffered in the world and are available as begin/end overlap event arrays after the...
Definition types.h:1088
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:728
b2JointDef base
Base joint definition.
Definition types.h:725
b2FilterJointDef b2DefaultFilterJointDef(void)
Use this to initialize your joint definition.
A filter joint is used to disable collision between two specific bodies.
Definition types.h:723
Body id references a body instance. This should be treated as an opaque handle.
Definition id.h:46
Contact id references a contact instance. This should be treated as an opaque handle.
Definition id.h:78
Joint id references a joint instance. This should be treated as an opaque handle.
Definition id.h:70
Shape id references a shape instance. This should be treated as an opaque handle.
Definition id.h:54
void * userData
User data pointer.
Definition types.h:632
b2Transform localFrameB
The second local joint frame.
Definition types.h:644
float forceThreshold
Force threshold for joint events.
Definition types.h:647
float constraintHertz
Constraint hertz (advanced feature).
Definition types.h:653
float constraintDampingRatio
Constraint damping ratio (advanced feature).
Definition types.h:656
b2BodyId bodyIdB
The second attached body.
Definition types.h:638
float torqueThreshold
Torque threshold for joint events.
Definition types.h:650
float drawScale
Debug draw scale.
Definition types.h:659
b2BodyId bodyIdA
The first attached body.
Definition types.h:635
b2Transform localFrameA
The first local joint frame.
Definition types.h:641
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:662
b2JointType
Joint type enumeration.
Definition types.h:612
@ b2_motorJoint
fully control the movement of a body
Definition types.h:615
@ b2_revoluteJoint
rotate around a pivot
Definition types.h:619
@ b2_filterJoint
filter collision between two bodies
Definition types.h:614
@ b2_prismaticJoint
slide along an axis
Definition types.h:618
@ b2_distanceJoint
constrain the distance between two points
Definition types.h:613
@ b2_wheelJoint
wheel spins with shock absorber
Definition types.h:621
@ b2_weldJoint
bring two bodies together with some flex
Definition types.h:620
@ b2_moverJoint
control the movement of the dynamic character mover
Definition types.h:616
@ b2_pogoJoint
ground interaction for the dynamic character mover
Definition types.h:617
Base joint definition used by all joint types.
Definition types.h:630
b2Vec2 b2Pos
Alias in single precision.
Definition math_types.h:61
b2Transform b2WorldTransform
Alias in single precision.
Definition math_types.h:64
Axis-aligned bounding box.
Definition math_types.h:77
2D rotation This is similar to using a complex number for rotation
Definition math_types.h:29
A 2D rigid transform.
Definition math_types.h:36
2D vector This can be used to represent a point or free vector
Definition math_types.h:14
float angularVelocity
The desired angular velocity.
Definition types.h:750
float maxVelocityTorque
The maximum motor torque in newton-meters.
Definition types.h:753
float linearHertz
Linear spring hertz for position control.
Definition types.h:756
float maxVelocityForce
The maximum motor force in newtons.
Definition types.h:747
float angularHertz
Angular spring hertz for position control.
Definition types.h:765
float angularDampingRatio
Angular spring damping ratio.
Definition types.h:768
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:774
b2JointDef base
Base joint definition.
Definition types.h:741
float linearDampingRatio
Linear spring damping ratio.
Definition types.h:759
float maxSpringTorque
Maximum spring torque in newton-meters.
Definition types.h:771
float maxSpringForce
Maximum spring force in newtons.
Definition types.h:762
b2Vec2 linearVelocity
The desired linear velocity.
Definition types.h:744
b2MotorJointDef b2DefaultMotorJointDef(void)
Use this to initialize your joint definition.
A motor joint is used to control the relative velocity and/or transform between two bodies.
Definition types.h:739
b2Vec2 linearVelocity
The desired linear velocity.
Definition types.h:790
b2JointDef base
Base joint definition.
Definition types.h:787
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:796
b2Vec2 maxVelocityForce
The maximum motor force in newtons.
Definition types.h:793
b2MoverJointDef b2DefaultMoverJointDef(void)
Use this to initialize your joint definition.
A mover joint is used to move a dynamic character mover through velocity commands.
Definition types.h:785
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:814
float impulse
The initial pogo internal impulse.
Definition types.h:830
float maxTensionForce
Maximum tension force. Controls how sticky the mover is to ground.
Definition types.h:823
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:837
float velocity
The initial pogo internal velocity.
Definition types.h:834
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:817
float maxCompressionForce
Maximum compression force. How hard the pogo pushes the mover up from the ground.
Definition types.h:826
float restLength
Spring length.
Definition types.h:820
b2Vec2 normal
Normal vector at the contact.
Definition types.h:811
b2JointDef base
Base joint definition.
Definition types.h:808
b2PogoJointDef b2DefaultPogoJointDef(void)
Use this to initialize your joint definition.
Pogo joint definition.
Definition types.h:806
float targetTranslation
The target translation for the joint in meters.
Definition types.h:864
float lowerTranslation
The lower translation limit.
Definition types.h:870
bool enableMotor
Enable/disable the joint motor.
Definition types.h:876
float motorSpeed
The desired motor speed, typically in meters per second.
Definition types.h:882
bool enableSpring
Enable a linear spring along the prismatic joint axis.
Definition types.h:854
float upperTranslation
The upper translation limit.
Definition types.h:873
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:885
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:860
bool enableLimit
Enable/disable the joint limit.
Definition types.h:867
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:857
b2JointDef base
Base joint definition.
Definition types.h:851
float maxMotorForce
The maximum motor force, typically in newtons.
Definition types.h:879
b2PrismaticJointDef b2DefaultPrismaticJointDef(void)
Use this to initialize your joint definition.
Prismatic joint definition Body B may slide along the x-axis in local frame A.
Definition types.h:849
b2ShapeId shapeId
the shape hit
Definition types.h:1651
float lengthScale
length units per meter in effect when recorded
Definition types.h:1618
b2QueryFilter filter
the query filter
Definition types.h:1640
int workerCount
worker count used for the replay world
Definition types.h:1615
float timeStep
dt of the recorded steps
Definition types.h:1616
b2Pos point
the hit point on the shape surface
Definition types.h:1652
int frameCount
total recorded steps
Definition types.h:1614
b2Vec2 translation
ray and cast translation
Definition types.h:1643
int hitCount
number of recorded results
Definition types.h:1644
b2ReplayQueryType type
the query type
Definition types.h:1639
b2AABB aabb
overlap AABB, relative to origin
Definition types.h:1641
float fraction
the query translation fraction
Definition types.h:1654
b2Pos origin
query origin
Definition types.h:1642
int subStepCount
recorded sub-steps
Definition types.h:1617
b2Vec2 normal
the unit normal vector at the hit point
Definition types.h:1653
b2AABB bounds
accumulated world bounds over the recording, zero-extent if unavailable
Definition types.h:1619
struct b2Replay b2Replay
Opaque handle for incremental playback of a recording.
Definition types.h:1608
b2ReplayQueryType
The kind of a recorded spatial query, matching the public query and cast functions.
Definition types.h:1625
Static metadata describing a recording, resolved once when the player opens the file.
Definition types.h:1613
One result of a recorded spatial query.
Definition types.h:1650
A spatial query recorded during a replayed frame, exposed for inspection.
Definition types.h:1638
float targetAngle
The target angle for the joint in radians. The spring-damper will drive to this angle.
Definition types.h:901
b2JointDef base
Base joint definition.
Definition types.h:898
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:910
float lowerAngle
The lower angle for the joint limit in radians. Minimum of -0.99*pi radians.
Definition types.h:916
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:931
bool enableLimit
A flag to enable joint limits.
Definition types.h:913
float motorSpeed
The desired motor speed in radians per second.
Definition types.h:928
float upperAngle
The upper angle for the joint limit in radians. Maximum of 0.99*pi radians.
Definition types.h:919
bool enableSpring
Enable a rotational spring on the revolute hinge axis.
Definition types.h:904
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:907
bool enableMotor
A flag to enable the joint motor.
Definition types.h:922
float maxMotorTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:925
b2RevoluteJointDef b2DefaultRevoluteJointDef(void)
Use this to initialize your joint definition.
Revolute joint definition A point on body B is fixed to a point on body A.
Definition types.h:896
float tangentSpeed
The tangent speed for conveyor belts.
Definition types.h:414
int groupIndex
Collision groups allow a certain group of objects to never collide (negative) or always collide (posi...
Definition types.h:350
uint64_t userMaterialId
User material identifier.
Definition types.h:418
uint32_t customColor
Custom debug draw color.
Definition types.h:421
float restitution
The coefficient of restitution (bounce) usually in the range [0,1].
Definition types.h:408
bool invokeContactCreation
When shapes are created they will scan the environment for collision the next time step.
Definition types.h:478
uint64_t maskBits
The collision mask bits.
Definition types.h:368
bool enablePreSolveEvents
Enable pre-solve contact events for this shape.
Definition types.h:473
bool enableCustomFiltering
Enable custom filtering.
Definition types.h:450
bool isSensor
A sensor shape generates overlap events but never generates a collision response.
Definition types.h:457
bool updateBodyMass
Should the body update the mass properties when this shape is created.
Definition types.h:483
void * userData
Use this to store application specific shape data.
Definition types.h:435
uint64_t maskBits
The collision mask bits.
Definition types.h:343
bool enableContactEvents
Enable contact events for this shape.
Definition types.h:465
b2SurfaceMaterial material
The surface material for this shape.
Definition types.h:438
uint64_t categoryBits
The collision category bits.
Definition types.h:335
bool enableHitEvents
Enable hit events for this shape.
Definition types.h:469
b2Filter filter
Collision filtering data.
Definition types.h:446
float density
The density, usually in kg/m^2.
Definition types.h:443
float rollingResistance
The rolling resistance usually in the range [0,1].
Definition types.h:411
bool enableSensorEvents
Enable sensor events for this shape.
Definition types.h:461
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:486
uint64_t categoryBits
The collision category bits of this query. Normally you would just set one bit.
Definition types.h:364
float friction
The Coulomb (dry) friction coefficient, usually in the range [0,1].
Definition types.h:404
b2QueryFilter b2DefaultQueryFilter(void)
Use this to initialize your query filter.
b2Filter b2DefaultFilter(void)
Use this to initialize your filter.
b2ShapeType
Shape type.
Definition types.h:378
b2ShapeDef b2DefaultShapeDef(void)
Use this to initialize your shape definition.
b2SurfaceMaterial b2DefaultSurfaceMaterial(void)
Use this to initialize your surface material.
@ b2_shapeTypeCount
The number of shape types.
Definition types.h:395
@ b2_polygonShape
A convex polygon.
Definition types.h:389
@ b2_circleShape
A circle with an offset.
Definition types.h:380
@ b2_segmentShape
A line segment.
Definition types.h:386
@ b2_chainSegmentShape
A line segment owned by a chain shape.
Definition types.h:392
@ b2_capsuleShape
A capsule is an extruded circle.
Definition types.h:383
This is used to filter collision on shapes.
Definition types.h:322
The query filter is used to filter collisions between queries and shapes.
Definition types.h:362
Used to create a shape.
Definition types.h:433
The surface material groups together parameters related to the shape surface, which is the 2D boundar...
Definition types.h:402
float linearHertz
Linear stiffness expressed as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:948
float angularHertz
Angular stiffness as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:951
float angularDampingRatio
Angular damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:957
float linearDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:954
b2JointDef base
Base joint definition.
Definition types.h:945
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:960
b2WeldJointDef b2DefaultWeldJointDef(void)
Use this to initialize your joint definition.
Weld joint definition Connects two bodies together rigidly.
Definition types.h:943
bool enableSpring
Enable a linear spring along the local axis.
Definition types.h:976
float hertz
Spring stiffness in Hertz.
Definition types.h:979
float motorSpeed
The desired motor speed in radians per second.
Definition types.h:1000
bool enableLimit
Enable/disable the joint linear limit.
Definition types.h:985
float upperTranslation
The upper translation limit.
Definition types.h:991
b2JointDef base
Base joint definition.
Definition types.h:973
float lowerTranslation
The lower translation limit.
Definition types.h:988
float dampingRatio
Spring damping ratio, non-dimensional.
Definition types.h:982
bool enableMotor
Enable/disable the joint rotational motor.
Definition types.h:994
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:1003
float maxMotorTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:997
b2WheelJointDef b2DefaultWheelJointDef(void)
Use this to initialize your joint definition.
Wheel joint definition Body B is a wheel that may rotate freely and slide along the local x-axis in f...
Definition types.h:971
b2Pos point
The point of contact, on the surface of the hit shape.
Definition types.h:62
b2Pos position
The center of the explosion in world space.
Definition types.h:1019
int staticShapeCount
Number of expected static shapes.
Definition types.h:86
int arenaByteCount
Reserve arena allocator space, used for temporary allocations.
Definition types.h:101
b2FinishTaskCallbackFcn * finishTask
Function to finish a task.
Definition types.h:167
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:179
float contactSpeed
This parameter controls how fast overlap is resolved and usually has units of meters per second.
Definition types.h:138
int recycledContactCount
Number of contacts recycled in the most recent step.
Definition types.h:602
int nodeVisits
The number of BVH nodes visited. Diagnostic.
Definition types.h:71
float fraction
The fraction of the input ray.
Definition types.h:68
int dynamicShapeCount
Number of expected dynamic and kinematic shapes.
Definition types.h:89
bool enableRestitutionPropagation
Enable full contact propagation in the restitution solver. Expensive. (Experimental).
Definition types.h:122
float contactHertz
Contact stiffness.
Definition types.h:129
uint64_t maskBits
Mask bits to filter shapes.
Definition types.h:1016
float contactDampingRatio
Contact bounciness.
Definition types.h:133
b2Vec2 normal
The unit normal vector at the point of contact.
Definition types.h:65
float impulsePerLength
Impulse per unit length.
Definition types.h:1030
void * userTaskContext
User context that is provided to enqueueTask and finishTask.
Definition types.h:170
float hitEventThreshold
Threshold speed for hit events. Usually meters per second.
Definition types.h:125
b2Vec2 gravity
Gravity vector. Box2D has no up-vector defined.
Definition types.h:110
bool enableSleep
Can bodies go to sleep to improve performance.
Definition types.h:150
int leafVisits
The number of BVH leaves visited. Diagnostic.
Definition types.h:74
float falloff
The falloff distance beyond the radius. Impulse is reduced to zero at this distance.
Definition types.h:1025
int workerCount
Number of workers for multithreading.
Definition types.h:161
bool enableContinuous
Enable continuous collision.
Definition types.h:153
int dynamicBodyCount
Number of expected dynamic and kinematic bodies.
Definition types.h:95
float restitutionThreshold
Restitution speed threshold, usually in m/s.
Definition types.h:114
b2RestitutionCallbackFcn * restitutionCallback
Optional mixing callback for restitution. The default uses max(restitutionA, restitutionB).
Definition types.h:147
int contactCount
Number of expected contacts.
Definition types.h:98
b2EnqueueTaskCallbackFcn * enqueueTask
Function to spawn tasks.
Definition types.h:164
float maximumLinearSpeed
Maximum linear speed. Usually meters per second.
Definition types.h:141
float radius
The radius of the explosion.
Definition types.h:1022
void * userData
User data.
Definition types.h:173
int staticBodyCount
Number of expected static bodies.
Definition types.h:92
b2FrictionCallbackFcn * frictionCallback
Optional mixing callback for friction. The default uses sqrt(frictionA * frictionB).
Definition types.h:144
b2Capacity capacity
Optional initial capacities.
Definition types.h:176
int restitutionIterations
Number of iterations of the restitution solver.
Definition types.h:119
bool hit
Did the ray hit? If false, all other data is invalid.
Definition types.h:77
int awakeContactCount
Number of contacts touched by the collide pass (graph contacts + awake-set non-touching).
Definition types.h:599
b2ShapeId shapeId
The shape hit.
Definition types.h:59
void b2TaskCallbackFcn(void *taskContext)
Task interface This is the prototype for a Box2D task.
Definition types.h:26
float b2FrictionCallbackFcn(float frictionA, uint64_t userMaterialIdA, float frictionB, uint64_t userMaterialIdB)
Optional friction mixing callback.
Definition types.h:43
b2ExplosionDef b2DefaultExplosionDef(void)
Use this to initialize your explosion definition.
bool b2OverlapResultCallbackFcn(b2ShapeId shapeId, void *context)
Prototype callback for overlap queries.
Definition types.h:1310
void * b2EnqueueTaskCallbackFcn(b2TaskCallbackFcn *task, void *taskContext, void *userContext)
These functions can be provided to Box2D to invoke a task system.
Definition types.h:32
void b2PreSolveCallbackFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold *manifold, void *context)
Prototype for a pre-solve callback.
Definition types.h:1290
bool b2PreContinuousCallbackFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Pos point, b2Vec2 normal, void *context)
Prototype for a pre-continuous callback.
Definition types.h:1303
float b2RestitutionCallbackFcn(float restitutionA, uint64_t userMaterialIdA, float restitutionB, uint64_t userMaterialIdB)
Optional restitution mixing callback.
Definition types.h:50
float b2CastResultCallbackFcn(b2ShapeId shapeId, b2Pos point, b2Vec2 normal, float fraction, void *context)
Prototype callback for ray and shape casts.
Definition types.h:1329
void b2FinishTaskCallbackFcn(void *userTask, void *userContext)
Finishes a user task object that wraps a Box2D task.
Definition types.h:37
bool b2CustomFilterCallbackFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, void *context)
Prototype for a contact filter callback.
Definition types.h:1277
b2WorldDef b2DefaultWorldDef(void)
Use this to initialize your world definition.
Optional world capacities that can be used to avoid run-time allocations.
Definition types.h:84
Counters that give details of the simulation size.
Definition types.h:585
The explosion definition is used to configure options for explosions.
Definition types.h:1014
Profiling data.
Definition types.h:556
Result from b2World_CastRayClosest If there is initial overlap the fraction and normal will be zero w...
Definition types.h:57
World definition used to create a simulation world.
Definition types.h:108
This struct holds callbacks you can implement to draw a Box2D world.
Definition types.h:1507
b2AABB drawingBounds
World bounds used for debug draw. An empty box draws nothing.
Definition types.h:1544
bool drawJoints
Option to draw joints.
Definition types.h:1565
void(*) DrawBoundsFcn(b2AABB aabb, b2HexColor color, void *context)
Draw a bounding box.
Definition types.h:1541
float forceScale
Scale to use when drawing forces.
Definition types.h:1547
bool drawContactFeatures
Option to draw contact feature ids.
Definition types.h:1583
bool drawChainNormals
Option to draw chain shape normals.
Definition types.h:1562
bool drawContacts
Option to draw contact points.
Definition types.h:1553
bool drawIslands
Option to draw islands as bounding boxes.
Definition types.h:1595
void(*) DrawTransformFcn(b2WorldTransform transform, void *context)
Draw a transform. Choose your own length scale.
Definition types.h:1531
bool drawAnchorA
Draw anchor A for contact points (instead of anchorB).
Definition types.h:1556
void * context
User context that is passed as an argument to drawing callback functions.
Definition types.h:1598
void(*) DrawPolygonFcn(b2WorldTransform transform, const b2Vec2 *vertices, int vertexCount, b2HexColor color, void *context)
Draw a closed polygon provided in CCW order.
Definition types.h:1509
float jointScale
Global scaling for joint drawing.
Definition types.h:1550
bool drawBounds
Option to draw the bounding boxes for shapes.
Definition types.h:1571
void(*) DrawStringFcn(b2Pos p, const char *s, b2HexColor color, void *context)
Draw a string in world space.
Definition types.h:1537
void(*) DrawSolidCircleFcn(b2WorldTransform transform, b2Vec2 center, float radius, b2HexColor color, void *context)
Draw a solid circle.
Definition types.h:1520
bool drawShapes
Option to draw shapes.
Definition types.h:1559
bool drawJointExtras
Option to draw additional information for joints.
Definition types.h:1568
void(*) DrawCircleFcn(b2Pos center, float radius, b2HexColor color, void *context)
Draw a circle.
Definition types.h:1517
bool drawContactForces
Option to draw contact normal forces.
Definition types.h:1589
bool drawFrictionForces
Option to draw contact friction forces.
Definition types.h:1592
void(*) DrawLineFcn(b2Pos p1, b2Pos p2, b2HexColor color, void *context)
Draw a line segment.
Definition types.h:1528
void(*) DrawPointFcn(b2Pos p, float size, b2HexColor color, void *context)
Draw a point.
Definition types.h:1534
bool drawGraphColors
Option to visualize the graph coloring used for contacts and joints.
Definition types.h:1580
bool drawContactNormals
Option to draw contact normals.
Definition types.h:1586
void(*) DrawSolidCapsuleFcn(b2Pos p1, b2Pos p2, float radius, b2HexColor color, void *context)
Draw a solid capsule.
Definition types.h:1524
bool drawBodyNames
Option to draw body names.
Definition types.h:1577
bool drawMass
Option to draw the mass and center of mass of dynamic bodies.
Definition types.h:1574
void(*) DrawSolidPolygonFcn(b2WorldTransform transform, const b2Vec2 *vertices, int vertexCount, float radius, b2HexColor color, void *context)
Draw a solid closed polygon provided in CCW order.
Definition types.h:1513