9#include "math_functions.h"
14#define B2_DEFAULT_CATEGORY_BITS 1
15#define B2_DEFAULT_MASK_BITS UINT64_MAX
33typedef void b2TaskCallback(
int startIndex,
int endIndex, uint32_t workerIndex,
void* taskContext );
56typedef float b2FrictionCallback(
float frictionA,
int userMaterialIdA,
float frictionB,
int userMaterialIdB );
62typedef float b2RestitutionCallback(
float restitutionA,
int userMaterialIdA,
float restitutionB,
int userMaterialIdB );
471typedef struct b2Profile
479 float solveConstraints;
480 float prepareConstraints;
481 float integrateVelocities;
484 float integratePositions;
486 float applyRestitution;
498typedef struct b2Counters
506 int staticTreeHeight;
1223typedef enum b2HexColor
1225 b2_colorAliceBlue = 0xF0F8FF,
1226 b2_colorAntiqueWhite = 0xFAEBD7,
1227 b2_colorAqua = 0x00FFFF,
1228 b2_colorAquamarine = 0x7FFFD4,
1229 b2_colorAzure = 0xF0FFFF,
1230 b2_colorBeige = 0xF5F5DC,
1231 b2_colorBisque = 0xFFE4C4,
1232 b2_colorBlack = 0x000000,
1233 b2_colorBlanchedAlmond = 0xFFEBCD,
1234 b2_colorBlue = 0x0000FF,
1235 b2_colorBlueViolet = 0x8A2BE2,
1236 b2_colorBrown = 0xA52A2A,
1237 b2_colorBurlywood = 0xDEB887,
1238 b2_colorCadetBlue = 0x5F9EA0,
1239 b2_colorChartreuse = 0x7FFF00,
1240 b2_colorChocolate = 0xD2691E,
1241 b2_colorCoral = 0xFF7F50,
1242 b2_colorCornflowerBlue = 0x6495ED,
1243 b2_colorCornsilk = 0xFFF8DC,
1244 b2_colorCrimson = 0xDC143C,
1245 b2_colorCyan = 0x00FFFF,
1246 b2_colorDarkBlue = 0x00008B,
1247 b2_colorDarkCyan = 0x008B8B,
1248 b2_colorDarkGoldenRod = 0xB8860B,
1249 b2_colorDarkGray = 0xA9A9A9,
1250 b2_colorDarkGreen = 0x006400,
1251 b2_colorDarkKhaki = 0xBDB76B,
1252 b2_colorDarkMagenta = 0x8B008B,
1253 b2_colorDarkOliveGreen = 0x556B2F,
1254 b2_colorDarkOrange = 0xFF8C00,
1255 b2_colorDarkOrchid = 0x9932CC,
1256 b2_colorDarkRed = 0x8B0000,
1257 b2_colorDarkSalmon = 0xE9967A,
1258 b2_colorDarkSeaGreen = 0x8FBC8F,
1259 b2_colorDarkSlateBlue = 0x483D8B,
1260 b2_colorDarkSlateGray = 0x2F4F4F,
1261 b2_colorDarkTurquoise = 0x00CED1,
1262 b2_colorDarkViolet = 0x9400D3,
1263 b2_colorDeepPink = 0xFF1493,
1264 b2_colorDeepSkyBlue = 0x00BFFF,
1265 b2_colorDimGray = 0x696969,
1266 b2_colorDodgerBlue = 0x1E90FF,
1267 b2_colorFireBrick = 0xB22222,
1268 b2_colorFloralWhite = 0xFFFAF0,
1269 b2_colorForestGreen = 0x228B22,
1270 b2_colorFuchsia = 0xFF00FF,
1271 b2_colorGainsboro = 0xDCDCDC,
1272 b2_colorGhostWhite = 0xF8F8FF,
1273 b2_colorGold = 0xFFD700,
1274 b2_colorGoldenRod = 0xDAA520,
1275 b2_colorGray = 0x808080,
1276 b2_colorGreen = 0x008000,
1277 b2_colorGreenYellow = 0xADFF2F,
1278 b2_colorHoneyDew = 0xF0FFF0,
1279 b2_colorHotPink = 0xFF69B4,
1280 b2_colorIndianRed = 0xCD5C5C,
1281 b2_colorIndigo = 0x4B0082,
1282 b2_colorIvory = 0xFFFFF0,
1283 b2_colorKhaki = 0xF0E68C,
1284 b2_colorLavender = 0xE6E6FA,
1285 b2_colorLavenderBlush = 0xFFF0F5,
1286 b2_colorLawnGreen = 0x7CFC00,
1287 b2_colorLemonChiffon = 0xFFFACD,
1288 b2_colorLightBlue = 0xADD8E6,
1289 b2_colorLightCoral = 0xF08080,
1290 b2_colorLightCyan = 0xE0FFFF,
1291 b2_colorLightGoldenRodYellow = 0xFAFAD2,
1292 b2_colorLightGray = 0xD3D3D3,
1293 b2_colorLightGreen = 0x90EE90,
1294 b2_colorLightPink = 0xFFB6C1,
1295 b2_colorLightSalmon = 0xFFA07A,
1296 b2_colorLightSeaGreen = 0x20B2AA,
1297 b2_colorLightSkyBlue = 0x87CEFA,
1298 b2_colorLightSlateGray = 0x778899,
1299 b2_colorLightSteelBlue = 0xB0C4DE,
1300 b2_colorLightYellow = 0xFFFFE0,
1301 b2_colorLime = 0x00FF00,
1302 b2_colorLimeGreen = 0x32CD32,
1303 b2_colorLinen = 0xFAF0E6,
1304 b2_colorMagenta = 0xFF00FF,
1305 b2_colorMaroon = 0x800000,
1306 b2_colorMediumAquaMarine = 0x66CDAA,
1307 b2_colorMediumBlue = 0x0000CD,
1308 b2_colorMediumOrchid = 0xBA55D3,
1309 b2_colorMediumPurple = 0x9370DB,
1310 b2_colorMediumSeaGreen = 0x3CB371,
1311 b2_colorMediumSlateBlue = 0x7B68EE,
1312 b2_colorMediumSpringGreen = 0x00FA9A,
1313 b2_colorMediumTurquoise = 0x48D1CC,
1314 b2_colorMediumVioletRed = 0xC71585,
1315 b2_colorMidnightBlue = 0x191970,
1316 b2_colorMintCream = 0xF5FFFA,
1317 b2_colorMistyRose = 0xFFE4E1,
1318 b2_colorMoccasin = 0xFFE4B5,
1319 b2_colorNavajoWhite = 0xFFDEAD,
1320 b2_colorNavy = 0x000080,
1321 b2_colorOldLace = 0xFDF5E6,
1322 b2_colorOlive = 0x808000,
1323 b2_colorOliveDrab = 0x6B8E23,
1324 b2_colorOrange = 0xFFA500,
1325 b2_colorOrangeRed = 0xFF4500,
1326 b2_colorOrchid = 0xDA70D6,
1327 b2_colorPaleGoldenRod = 0xEEE8AA,
1328 b2_colorPaleGreen = 0x98FB98,
1329 b2_colorPaleTurquoise = 0xAFEEEE,
1330 b2_colorPaleVioletRed = 0xDB7093,
1331 b2_colorPapayaWhip = 0xFFEFD5,
1332 b2_colorPeachPuff = 0xFFDAB9,
1333 b2_colorPeru = 0xCD853F,
1334 b2_colorPink = 0xFFC0CB,
1335 b2_colorPlum = 0xDDA0DD,
1336 b2_colorPowderBlue = 0xB0E0E6,
1337 b2_colorPurple = 0x800080,
1338 b2_colorRebeccaPurple = 0x663399,
1339 b2_colorRed = 0xFF0000,
1340 b2_colorRosyBrown = 0xBC8F8F,
1341 b2_colorRoyalBlue = 0x4169E1,
1342 b2_colorSaddleBrown = 0x8B4513,
1343 b2_colorSalmon = 0xFA8072,
1344 b2_colorSandyBrown = 0xF4A460,
1345 b2_colorSeaGreen = 0x2E8B57,
1346 b2_colorSeaShell = 0xFFF5EE,
1347 b2_colorSienna = 0xA0522D,
1348 b2_colorSilver = 0xC0C0C0,
1349 b2_colorSkyBlue = 0x87CEEB,
1350 b2_colorSlateBlue = 0x6A5ACD,
1351 b2_colorSlateGray = 0x708090,
1352 b2_colorSnow = 0xFFFAFA,
1353 b2_colorSpringGreen = 0x00FF7F,
1354 b2_colorSteelBlue = 0x4682B4,
1355 b2_colorTan = 0xD2B48C,
1356 b2_colorTeal = 0x008080,
1357 b2_colorThistle = 0xD8BFD8,
1358 b2_colorTomato = 0xFF6347,
1359 b2_colorTurquoise = 0x40E0D0,
1360 b2_colorViolet = 0xEE82EE,
1361 b2_colorWheat = 0xF5DEB3,
1362 b2_colorWhite = 0xFFFFFF,
1363 b2_colorWhiteSmoke = 0xF5F5F5,
1364 b2_colorYellow = 0xFFFF00,
1365 b2_colorYellowGreen = 0x9ACD32,
1367 b2_colorBox2DRed = 0xDC3132,
1368 b2_colorBox2DBlue = 0x30AEBF,
1369 b2_colorBox2DGreen = 0x8CC924,
1370 b2_colorBox2DYellow = 0xFFEE8C
float sleepThreshold
Sleep speed threshold, default is 0.05 meters per second.
Definition types.h:213
b2Vec2 linearVelocity
The initial linear velocity of the body's origin. Usually in meters per second.
Definition types.h:191
bool fixedRotation
Should this body be prevented from rotating? Useful for characters.
Definition types.h:228
const char * name
Optional body name for debugging. Up to 31 characters (excluding null termination)
Definition types.h:216
b2Vec2 position
The initial world position of the body.
Definition types.h:185
b2Rot rotation
The initial world rotation of the body. Use b2MakeRot() if you have an angle.
Definition types.h:188
bool allowFastRotation
This allows this body to bypass rotational speed limits.
Definition types.h:241
bool isEnabled
Used to disable a body. A disabled body does not move or collide.
Definition types.h:237
b2BodyType type
The body type: static, kinematic, or dynamic.
Definition types.h:180
float linearDamping
Linear damping is used to reduce the linear velocity.
Definition types.h:201
float angularVelocity
The initial angular velocity of the body. Radians per second.
Definition types.h:194
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:244
float gravityScale
Scale the gravity applied to this body. Non-dimensional.
Definition types.h:210
void * userData
Use this to store application specific body data.
Definition types.h:219
bool isBullet
Treat this body as high speed object that performs continuous collision detection against dynamic and...
Definition types.h:234
bool isAwake
Is this body initially awake or sleeping?
Definition types.h:225
bool enableSleep
Set this flag to false if this body should never fall asleep.
Definition types.h:222
float angularDamping
Angular damping is used to reduce the angular velocity.
Definition types.h:207
b2BodyType
The body simulation type.
Definition types.h:158
b2BodyDef b2DefaultBodyDef(void)
Use this to initialize your body definition.
@ b2_staticBody
zero mass, zero velocity, may be manually moved
Definition types.h:160
@ b2_kinematicBody
zero mass, velocity set by user, moved by solver
Definition types.h:163
@ b2_dynamicBody
positive mass, velocity determined by forces, moved by solver
Definition types.h:166
@ b2_bodyTypeCount
number of body types
Definition types.h:169
A body definition holds all the data needed to construct a rigid body.
Definition types.h:178
These are the collision planes returned from b2World_CollideMover.
Definition collision.h:784
A contact manifold describes the contact points between colliding shapes.
Definition collision.h:539
float length
The rest length of this joint. Clamped to a stable minimum value.
Definition types.h:553
bool enableLimit
Enable/disable the joint limit.
Definition types.h:566
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:547
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:584
float dampingRatio
The spring linear damping ratio, non-dimensional.
Definition types.h:563
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:590
float maxMotorForce
The maximum motor force, usually in newtons.
Definition types.h:578
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:550
b2BodyId bodyIdB
The second attached body.
Definition types.h:544
void * userData
User data pointer.
Definition types.h:587
b2BodyId bodyIdA
The first attached body.
Definition types.h:541
bool enableSpring
Enable the distance constraint to behave like a spring.
Definition types.h:557
float minLength
Minimum length. Clamped to a stable minimum value.
Definition types.h:569
bool enableMotor
Enable/disable the joint motor.
Definition types.h:575
float maxLength
Maximum length. Must be greater than or equal to the minimum length.
Definition types.h:572
float hertz
The spring linear stiffness Hertz, cycles per second.
Definition types.h:560
float motorSpeed
The desired motor speed, usually in meters per second.
Definition types.h:581
b2DistanceJointDef b2DefaultDistanceJointDef(void)
Use this to initialize your joint definition.
Distance joint definition.
Definition types.h:539
int hitCount
Number of hit events.
Definition types.h:1117
b2ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:1004
int beginCount
The number of begin touch events.
Definition types.h:1040
b2ContactBeginTouchEvent * beginEvents
Array of begin touch events.
Definition types.h:1102
float approachSpeed
The speed the shapes are approaching. Always positive. Typically in meters per second.
Definition types.h:1093
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:1074
b2Manifold manifold
The initial contact manifold.
Definition types.h:1057
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:1050
b2BodyMoveEvent * moveEvents
Array of move events.
Definition types.h:1144
b2Vec2 normal
Normal vector pointing from shape A to shape B.
Definition types.h:1090
b2ContactHitEvent * hitEvents
Array of hit events.
Definition types.h:1108
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:1053
b2SensorEndTouchEvent * endEvents
Array of sensor end touch events.
Definition types.h:1037
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:1069
b2ShapeId sensorShapeId
The id of the sensor shape.
Definition types.h:1019
b2ShapeId visitorShapeId
The id of the dynamic shape that stopped touching the sensor shape.
Definition types.h:1024
b2ShapeId shapeIdB
Id of the second shape.
Definition types.h:1084
int endCount
The number of end touch events.
Definition types.h:1043
b2ContactEndTouchEvent * endEvents
Array of end touch events.
Definition types.h:1105
int beginCount
Number of begin touch events.
Definition types.h:1111
int endCount
Number of end touch events.
Definition types.h:1114
b2Vec2 point
Point where the shapes hit.
Definition types.h:1087
b2ShapeId shapeIdA
Id of the first shape.
Definition types.h:1081
b2ShapeId visitorShapeId
The id of the dynamic shape that began touching the sensor shape.
Definition types.h:1007
int moveCount
Number of move events.
Definition types.h:1147
b2SensorBeginTouchEvent * beginEvents
Array of sensor begin touch events.
Definition types.h:1034
Body events are buffered in the Box2D world and are available as event arrays after the time step is ...
Definition types.h:1142
Body move events triggered when a body moves.
Definition types.h:1131
A begin touch event is generated when a shape starts to overlap a sensor shape.
Definition types.h:1002
An end touch event is generated when a shape stops overlapping a sensor shape.
Definition types.h:1015
Sensor events are buffered in the Box2D world and are available as begin/end overlap event arrays aft...
Definition types.h:1032
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:692
void * userData
User data pointer.
Definition types.h:689
b2BodyId bodyIdA
The first attached body.
Definition types.h:683
b2BodyId bodyIdB
The second attached body.
Definition types.h:686
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:681
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:520
Axis-aligned bounding box.
Definition math_functions.h:59
2D rotation This is similar to using a complex number for rotation
Definition math_functions.h:38
2D vector This can be used to represent a point or free vector
Definition math_functions.h:21
float maxForce
The maximum motor force in newtons.
Definition types.h:616
float correctionFactor
Position correction factor in the range [0,1].
Definition types.h:622
b2Vec2 linearOffset
Position of bodyB minus the position of bodyA, in bodyA's frame.
Definition types.h:610
float angularOffset
The bodyB angle minus bodyA angle in radians.
Definition types.h:613
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:631
b2BodyId bodyIdB
The second attached body.
Definition types.h:607
void * userData
User data pointer.
Definition types.h:628
b2BodyId bodyIdA
The first attached body.
Definition types.h:604
float maxTorque
The maximum motor torque in newton-meters.
Definition types.h:619
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:625
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:602
void * userData
User data pointer.
Definition types.h:667
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:670
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:664
b2BodyId bodyIdB
The second attached body.
Definition types.h:649
float maxForce
Maximum force, typically in newtons.
Definition types.h:661
float hertz
Stiffness in hertz.
Definition types.h:655
b2Vec2 target
The initial target point in world space.
Definition types.h:652
float dampingRatio
Damping ratio, non-dimensional.
Definition types.h:658
b2BodyId bodyIdA
The first attached body. This is assumed to be static.
Definition types.h:646
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:644
void * userData
User data pointer.
Definition types.h:757
float lowerTranslation
The lower translation limit.
Definition types.h:739
bool enableMotor
Enable/disable the joint motor.
Definition types.h:745
float motorSpeed
The desired motor speed, typically in meters per second.
Definition types.h:751
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:718
b2BodyId bodyIdA
The first attached body.
Definition types.h:709
bool enableSpring
Enable a linear spring along the prismatic joint axis.
Definition types.h:727
float upperTranslation
The upper translation limit.
Definition types.h:742
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:760
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:733
bool enableLimit
Enable/disable the joint limit.
Definition types.h:736
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:730
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:715
float referenceAngle
The constrained angle between the bodies: bodyB_angle - bodyA_angle.
Definition types.h:724
b2BodyId bodyIdB
The second attached body.
Definition types.h:712
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:754
b2Vec2 localAxisA
The local translation unit axis in bodyA.
Definition types.h:721
float maxMotorForce
The maximum motor force, typically in newtons.
Definition types.h:748
Prismatic joint definition.
Definition types.h:707
float dampingRatio
The spring damping ratio, non-dimensional.
Definition types.h:804
float lowerAngle
The lower angle for the joint limit in radians. Minimum of -0.95*pi radians.
Definition types.h:810
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:834
bool enableLimit
A flag to enable joint limits.
Definition types.h:807
float motorSpeed
The desired motor speed in radians per second.
Definition types.h:822
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:791
void * userData
User data pointer.
Definition types.h:831
float upperAngle
The upper angle for the joint limit in radians. Maximum of 0.95*pi radians.
Definition types.h:813
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:788
float referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians).
Definition types.h:795
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:828
bool enableSpring
Enable a rotational spring on the revolute hinge axis.
Definition types.h:798
b2BodyId bodyIdA
The first attached body.
Definition types.h:782
float hertz
The spring stiffness Hertz, cycles per second.
Definition types.h:801
bool enableMotor
A flag to enable the joint motor.
Definition types.h:816
b2BodyId bodyIdB
The second attached body.
Definition types.h:785
float maxMotorTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:819
float drawSize
Scale the debug draw.
Definition types.h:825
b2RevoluteJointDef b2DefaultRevoluteJointDef(void)
Use this to initialize your joint definition.
Revolute joint definition.
Definition types.h:780
float tangentSpeed
The tangent speed for conveyor belts.
Definition types.h:348
b2Filter filter
Contact filtering data.
Definition types.h:453
int groupIndex
Collision groups allow a certain group of objects to never collide (negative) or always collide (posi...
Definition types.h:285
uint32_t customColor
Custom debug draw color.
Definition types.h:355
float restitution
The coefficient of restitution (bounce) usually in the range [0,1].
Definition types.h:342
const b2SurfaceMaterial * materials
Surface materials for each segment. These are cloned.
Definition types.h:446
int userMaterialId
User material identifier.
Definition types.h:352
bool isLoop
Indicates a closed chain formed by connecting the first and last points.
Definition types.h:456
bool invokeContactCreation
When shapes are created they will scan the environment for collision the next time step.
Definition types.h:406
uint64_t maskBits
The collision mask bits.
Definition types.h:303
void * userData
Use this to store application specific shape data.
Definition types.h:437
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:462
bool enablePreSolveEvents
Enable pre-solve contact events for this shape.
Definition types.h:401
int count
The point count, must be 4 or more.
Definition types.h:443
int materialCount
The material count.
Definition types.h:450
bool isSensor
A sensor shape generates overlap events but never generates a collision response.
Definition types.h:388
bool updateBodyMass
Should the body update the mass properties when this shape is created. Default is true.
Definition types.h:409
void * userData
Use this to store application specific shape data.
Definition types.h:370
uint64_t maskBits
The collision mask bits.
Definition types.h:277
const b2Vec2 * points
An array of at least 4 points. These are cloned and may be temporary.
Definition types.h:440
bool enableContactEvents
Enable contact events for this shape. Only applies to kinematic and dynamic bodies....
Definition types.h:394
b2SurfaceMaterial material
The surface material for this shape.
Definition types.h:373
uint64_t categoryBits
The collision category bits.
Definition types.h:268
bool enableHitEvents
Enable hit events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors....
Definition types.h:397
b2Filter filter
Collision filtering data.
Definition types.h:381
float density
The density, usually in kg/m^2.
Definition types.h:378
float rollingResistance
The rolling resistance usually in the range [0,1].
Definition types.h:345
bool enableSensorEvents
Enable sensors to detect this chain. False by default.
Definition types.h:459
bool enableSensorEvents
Enable sensor events for this shape. This applies to sensors and non-sensors. False by default,...
Definition types.h:391
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:412
uint64_t categoryBits
The collision category bits of this query. Normally you would just set one bit.
Definition types.h:299
float friction
The Coulomb (dry) friction coefficient, usually in the range [0,1].
Definition types.h:338
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:313
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:330
@ b2_polygonShape
A convex polygon.
Definition types.h:324
@ b2_circleShape
A circle with an offset.
Definition types.h:315
@ b2_segmentShape
A line segment.
Definition types.h:321
@ b2_chainSegmentShape
A line segment owned by a chain shape.
Definition types.h:327
@ b2_capsuleShape
A capsule is an extruded circle.
Definition types.h:318
Used to create a chain of line segments.
Definition types.h:435
This is used to filter collision on shapes.
Definition types.h:255
The query filter is used to filter collisions between queries and shapes.
Definition types.h:297
Used to create a shape.
Definition types.h:368
Surface materials allow chain shapes to have per segment surface properties.
Definition types.h:336
float linearHertz
Linear stiffness expressed as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:866
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:856
b2BodyId bodyIdB
The second attached body.
Definition types.h:853
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:859
void * userData
User data pointer.
Definition types.h:881
float referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians) todo maybe make this a b2Rot.
Definition types.h:863
b2BodyId bodyIdA
The first attached body.
Definition types.h:850
float angularHertz
Angular stiffness as Hertz (cycles per second). Use zero for maximum stiffness.
Definition types.h:869
float angularDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:875
float linearDampingRatio
Linear damping ratio, non-dimensional. Use 1 for critical damping.
Definition types.h:872
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:878
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:884
b2WeldJointDef b2DefaultWeldJointDef(void)
Use this to initialize your joint definition.
Weld joint definition.
Definition types.h:848
bool enableSpring
Enable a linear spring along the local axis.
Definition types.h:916
float hertz
Spring stiffness in Hertz.
Definition types.h:919
float motorSpeed
The desired motor speed in radians per second.
Definition types.h:940
bool enableLimit
Enable/disable the joint linear limit.
Definition types.h:925
float upperTranslation
The upper translation limit.
Definition types.h:931
float lowerTranslation
The lower translation limit.
Definition types.h:928
bool collideConnected
Set this flag to true if the attached bodies should collide.
Definition types.h:943
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition types.h:910
float dampingRatio
Spring damping ratio, non-dimensional.
Definition types.h:922
b2BodyId bodyIdB
The second attached body.
Definition types.h:904
bool enableMotor
Enable/disable the joint rotational motor.
Definition types.h:934
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition types.h:907
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:949
b2BodyId bodyIdA
The first attached body.
Definition types.h:901
void * userData
User data pointer.
Definition types.h:946
float maxMotorTorque
The maximum motor torque, typically in newton-meters.
Definition types.h:937
b2Vec2 localAxisA
The local translation unit axis in bodyA.
Definition types.h:913
b2WheelJointDef b2DefaultWheelJointDef(void)
Use this to initialize your joint definition.
Wheel joint definition.
Definition types.h:899
b2AABB drawingBounds
Bounds to use if restricting drawing to a rectangular region.
Definition types.h:1407
bool drawJoints
Option to draw joints.
Definition types.h:1416
bool drawFrictionImpulses
Option to draw contact friction impulses.
Definition types.h:1446
bool drawContactFeatures
Option to draw contact feature ids.
Definition types.h:1443
void(* DrawStringFcn)(b2Vec2 p, const char *s, b2HexColor color, void *context)
Draw a string in world space.
Definition types.h:1404
void(* DrawTransformFcn)(b2Transform transform, void *context)
Draw a transform. Choose your own length scale.
Definition types.h:1398
bool drawContactImpulses
Option to draw contact normal impulses.
Definition types.h:1440
b2FrictionCallback * frictionCallback
Optional mixing callback for friction. The default uses sqrt(frictionA * frictionB).
Definition types.h:114
bool drawContacts
Option to draw contact points.
Definition types.h:1431
bool drawIslands
Option to draw islands as bounding boxes.
Definition types.h:1449
int internalValue
Used internally to detect a valid definition. DO NOT SET.
Definition types.h:147
void(* DrawSegmentFcn)(b2Vec2 p1, b2Vec2 p2, b2HexColor color, void *context)
Draw a line segment.
Definition types.h:1395
void * context
User context that is passed as an argument to drawing callback functions.
Definition types.h:1452
void(* DrawPointFcn)(b2Vec2 p, float size, b2HexColor color, void *context)
Draw a point.
Definition types.h:1401
void(* DrawSolidPolygonFcn)(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:1382
bool drawBounds
Option to draw the bounding boxes for shapes.
Definition types.h:1422
void(* DrawCircleFcn)(b2Vec2 center, float radius, b2HexColor color, void *context)
Draw a circle.
Definition types.h:1386
float contactHertz
Contact stiffness. Cycles per second. Increasing this increases the speed of overlap recovery,...
Definition types.h:93
uint64_t maskBits
Mask bits to filter shapes.
Definition types.h:962
bool drawShapes
Option to draw shapes.
Definition types.h:1413
bool drawJointExtras
Option to draw additional information for joints.
Definition types.h:1419
float contactDampingRatio
Contact bounciness.
Definition types.h:97
void(* DrawSolidCircleFcn)(b2Transform transform, float radius, b2HexColor color, void *context)
Draw a solid circle.
Definition types.h:1389
b2FinishTaskCallback * finishTask
Function to finish a task.
Definition types.h:138
float impulsePerLength
Impulse per unit length.
Definition types.h:976
void * userTaskContext
User context that is provided to enqueueTask and finishTask.
Definition types.h:141
float hitEventThreshold
Threshold speed for hit events. Usually meters per second.
Definition types.h:90
b2Vec2 gravity
Gravity vector. Box2D has no up-vector defined.
Definition types.h:83
bool enableSleep
Can bodies go to sleep to improve performance.
Definition types.h:120
float falloff
The falloff distance beyond the radius. Impulse is reduced to zero at this distance.
Definition types.h:971
int workerCount
Number of workers to use with the provided task system.
Definition types.h:132
bool drawGraphColors
Option to visualize the graph coloring used for contacts and joints.
Definition types.h:1434
bool enableContinuous
Enable continuous collision.
Definition types.h:123
float restitutionThreshold
Restitution speed threshold, usually in m/s.
Definition types.h:87
bool drawContactNormals
Option to draw contact normals.
Definition types.h:1437
bool useDrawingBounds
Option to restrict drawing to a rectangular region. May suffer from unstable depth sorting.
Definition types.h:1410
float maximumLinearSpeed
Maximum linear speed. Usually meters per second.
Definition types.h:111
b2Vec2 position
The center of the explosion in world space.
Definition types.h:965
float radius
The radius of the explosion.
Definition types.h:968
void * userData
User data.
Definition types.h:144
void(* DrawSolidCapsuleFcn)(b2Vec2 p1, b2Vec2 p2, float radius, b2HexColor color, void *context)
Draw a solid capsule.
Definition types.h:1392
bool drawBodyNames
Option to draw body names.
Definition types.h:1428
bool drawMass
Option to draw the mass and center of mass of dynamic bodies.
Definition types.h:1425
float jointHertz
Joint stiffness. Cycles per second.
Definition types.h:105
float maxContactPushSpeed
This parameter controls how fast overlap is resolved and usually has units of meters per second.
Definition types.h:102
b2EnqueueTaskCallback * enqueueTask
Function to spawn tasks.
Definition types.h:135
void(* DrawPolygonFcn)(const b2Vec2 *vertices, int vertexCount, b2HexColor color, void *context)
Draw a closed polygon provided in CCW order.
Definition types.h:1379
float jointDampingRatio
Joint bounciness. Non-dimensional.
Definition types.h:108
b2RestitutionCallback * restitutionCallback
Optional mixing callback for restitution. The default uses max(restitutionA, restitutionB).
Definition types.h:117
void b2TaskCallback(int startIndex, int endIndex, uint32_t workerIndex, void *taskContext)
Task interface This is prototype for a Box2D task.
Definition types.h:33
float b2FrictionCallback(float frictionA, int userMaterialIdA, float frictionB, int userMaterialIdB)
Optional friction mixing callback.
Definition types.h:56
bool b2OverlapResultFcn(b2ShapeId shapeId, void *context)
Prototype callback for overlap queries.
Definition types.h:1196
b2ExplosionDef b2DefaultExplosionDef(void)
Use this to initialize your explosion definition.
float b2RestitutionCallback(float restitutionA, int userMaterialIdA, float restitutionB, int userMaterialIdB)
Optional restitution mixing callback.
Definition types.h:62
void * b2EnqueueTaskCallback(b2TaskCallback *task, int itemCount, int minRange, void *taskContext, void *userContext)
These functions can be provided to Box2D to invoke a task system.
Definition types.h:46
bool b2PreSolveFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, b2Manifold *manifold, void *context)
Prototype for a pre-solve callback.
Definition types.h:1189
float b2CastResultFcn(b2ShapeId shapeId, b2Vec2 point, b2Vec2 normal, float fraction, void *context)
Prototype callback for ray casts.
Definition types.h:1213
bool b2CustomFilterFcn(b2ShapeId shapeIdA, b2ShapeId shapeIdB, void *context)
Prototype for a contact filter callback.
Definition types.h:1174
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:50
This struct holds callbacks you can implement to draw a Box2D world.
Definition types.h:1377
The explosion definition is used to configure options for explosions.
Definition types.h:960
Result from b2World_RayCastClosest.
Definition types.h:67
World definition used to create a simulation world.
Definition types.h:81