box2d 3.0.0
A 2D physics engine for games
 
Loading...
Searching...
No Matches
box2d.h
1// SPDX-FileCopyrightText: 2023 Erin Catto
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "box2d/api.h"
7#include "box2d/callbacks.h"
8#include "box2d/event_types.h"
9#include "box2d/geometry.h"
10#include "box2d/id.h"
11#include "box2d/joint_types.h"
12#include "box2d/types.h"
13
14typedef struct b2Capsule b2Capsule;
15typedef struct b2Circle b2Circle;
16typedef struct b2Polygon b2Polygon;
17typedef struct b2DebugDraw b2DebugDraw;
18typedef struct b2Segment b2Segment;
19
30BOX2D_API b2WorldId b2CreateWorld(const b2WorldDef* def);
31
33BOX2D_API void b2DestroyWorld(b2WorldId worldId);
34
40BOX2D_API void b2World_Step(b2WorldId worldId, float timeStep, int32_t velocityIterations, int32_t relaxIterations);
41
43BOX2D_API void b2World_Draw(b2WorldId worldId, b2DebugDraw* debugDraw);
44
47
50
52BOX2D_API void b2World_QueryAABB(b2WorldId worldId, b2QueryResultFcn* fcn, b2AABB aabb, b2QueryFilter filter, void* context);
53
55BOX2D_API void b2World_OverlapCircle(b2WorldId worldId, b2QueryResultFcn* fcn, const b2Circle* circle, b2Transform transform,
56 b2QueryFilter filter, void* context);
57
59BOX2D_API void b2World_OverlapCapsule(b2WorldId worldId, b2QueryResultFcn* fcn, const b2Capsule* capsule, b2Transform transform,
60 b2QueryFilter filter, void* context);
61
63BOX2D_API void b2World_OverlapPolygon(b2WorldId worldId, b2QueryResultFcn* fcn, const b2Polygon* polygon, b2Transform transform,
64 b2QueryFilter filter, void* context);
65
72BOX2D_API void b2World_RayCast(b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter, b2RayResultFcn* fcn,
73 void* context);
74
76BOX2D_API b2RayResult b2World_RayCastClosest(b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter);
77
79BOX2D_API void b2World_CircleCast(b2WorldId worldId, const b2Circle* circle, b2Transform originTransform, b2Vec2 translation,
80 b2QueryFilter filter, b2RayResultFcn* fcn, void* context);
81
83BOX2D_API void b2World_CapsuleCast(b2WorldId worldId, const b2Capsule* capsule, b2Transform originTransform, b2Vec2 translation,
84 b2QueryFilter filter, b2RayResultFcn* fcn, void* context);
85
87BOX2D_API void b2World_PolygonCast(b2WorldId worldId, const b2Polygon* polygon, b2Transform originTransform, b2Vec2 translation,
88 b2QueryFilter filter, b2RayResultFcn* fcn, void* context);
89
91BOX2D_API void b2World_EnableSleeping(b2WorldId worldId, bool flag);
92
94BOX2D_API void b2World_EnableWarmStarting(b2WorldId worldId, bool flag);
95
97BOX2D_API void b2World_EnableContinuous(b2WorldId worldId, bool flag);
98
100BOX2D_API void b2World_SetRestitutionThreshold(b2WorldId worldId, float value);
101
107BOX2D_API void b2World_SetContactTuning(b2WorldId worldId, float hertz, float dampingRatio, float pushVelocity);
108
110BOX2D_API struct b2Profile b2World_GetProfile(b2WorldId worldId);
111
114
125BOX2D_API b2BodyId b2CreateBody(b2WorldId worldId, const b2BodyDef* def);
126
129BOX2D_API void b2DestroyBody(b2BodyId bodyId);
130
133
135BOX2D_API void b2Body_SetType(b2BodyId bodyId, b2BodyType type);
136
138BOX2D_API void* b2Body_GetUserData(b2BodyId bodyId);
139
142
144BOX2D_API float b2Body_GetAngle(b2BodyId bodyId);
145
148
150BOX2D_API void b2Body_SetTransform(b2BodyId bodyId, b2Vec2 position, float angle);
151
153BOX2D_API b2Vec2 b2Body_GetLocalPoint(b2BodyId bodyId, b2Vec2 worldPoint);
154
156BOX2D_API b2Vec2 b2Body_GetWorldPoint(b2BodyId bodyId, b2Vec2 localPoint);
157
159BOX2D_API b2Vec2 b2Body_GetLocalVector(b2BodyId bodyId, b2Vec2 worldVector);
160
162BOX2D_API b2Vec2 b2Body_GetWorldVector(b2BodyId bodyId, b2Vec2 localVector);
163
166
168BOX2D_API float b2Body_GetAngularVelocity(b2BodyId bodyId);
169
171BOX2D_API void b2Body_SetLinearVelocity(b2BodyId bodyId, b2Vec2 linearVelocity);
172
174BOX2D_API void b2Body_SetAngularVelocity(b2BodyId bodyId, float angularVelocity);
175
182BOX2D_API void b2Body_ApplyForce(b2BodyId bodyId, b2Vec2 force, b2Vec2 point, bool wake);
183
187BOX2D_API void b2Body_ApplyForceToCenter(b2BodyId bodyId, b2Vec2 force, bool wake);
188
193BOX2D_API void b2Body_ApplyTorque(b2BodyId bodyId, float torque, bool wake);
194
201BOX2D_API void b2Body_ApplyLinearImpulse(b2BodyId bodyId, b2Vec2 impulse, b2Vec2 point, bool wake);
202
206BOX2D_API void b2Body_ApplyLinearImpulseToCenter(b2BodyId bodyId, b2Vec2 impulse, bool wake);
207
211BOX2D_API void b2Body_ApplyAngularImpulse(b2BodyId bodyId, float impulse, bool wake);
212
214BOX2D_API float b2Body_GetMass(b2BodyId bodyId);
215
217BOX2D_API float b2Body_GetInertiaTensor(b2BodyId bodyId);
218
221
224
228BOX2D_API void b2Body_SetMassData(b2BodyId bodyId, b2MassData massData);
229
231BOX2D_API bool b2Body_IsAwake(b2BodyId bodyId);
232
234BOX2D_API void b2Body_Wake(b2BodyId bodyId);
235
237BOX2D_API bool b2Body_IsEnabled(b2BodyId bodyId);
238
240BOX2D_API void b2Body_Disable(b2BodyId bodyId);
241
243BOX2D_API void b2Body_Enable(b2BodyId bodyId);
244
247BOX2D_API b2ShapeId b2Body_GetNextShape(b2ShapeId shapeId);
248
250BOX2D_API int32_t b2Body_GetContactCapacity(b2BodyId bodyId);
251
253BOX2D_API int32_t b2Body_GetContactData(b2BodyId bodyId, b2ContactData* contactData, int32_t capacity);
254
266BOX2D_API b2ShapeId b2CreateCircleShape(b2BodyId bodyId, const b2ShapeDef* def, const b2Circle* circle);
267
271BOX2D_API b2ShapeId b2CreateSegmentShape(b2BodyId bodyId, const b2ShapeDef* def, const b2Segment* segment);
272
276BOX2D_API b2ShapeId b2CreateCapsuleShape(b2BodyId bodyId, const b2ShapeDef* def, const b2Capsule* capsule);
277
281BOX2D_API b2ShapeId b2CreatePolygonShape(b2BodyId bodyId, const b2ShapeDef* def, const b2Polygon* polygon);
282
284BOX2D_API void b2DestroyShape(b2ShapeId shapeId);
285
288BOX2D_API b2ChainId b2CreateChain(b2BodyId bodyId, const b2ChainDef* def);
289
291BOX2D_API void b2DestroyChain(b2ChainId chainId);
292
295
298BOX2D_API void* b2Shape_GetUserData(b2ShapeId shapeId);
299
301BOX2D_API bool b2Shape_TestPoint(b2ShapeId shapeId, b2Vec2 point);
302
304BOX2D_API void b2Shape_SetFriction(b2ShapeId shapeId, float friction);
305
307BOX2D_API void b2Shape_SetRestitution(b2ShapeId shapeId, float restitution);
308
311
313BOX2D_API const b2Circle* b2Shape_GetCircle(b2ShapeId shapeId);
314
316BOX2D_API const b2Segment* b2Shape_GetSegment(b2ShapeId shapeId);
317
320
322BOX2D_API const b2Capsule* b2Shape_GetCapsule(b2ShapeId shapeId);
323
325BOX2D_API const b2Polygon* b2Shape_GetPolygon(b2ShapeId shapeId);
326
328BOX2D_API void b2Chain_SetFriction(b2ChainId chainId, float friction);
329
331BOX2D_API void b2Chain_SetRestitution(b2ChainId chainId, float restitution);
332
334BOX2D_API int32_t b2Shape_GetContactCapacity(b2ShapeId shapeId);
335
337BOX2D_API int32_t b2Shape_GetContactData(b2ShapeId shapeId, b2ContactData* contactData, int32_t capacity);
338
350
354
358
362
366
370
374
376BOX2D_API void b2DestroyJoint(b2JointId jointId);
377
380
383
385BOX2D_API float b2DistanceJoint_GetConstraintForce(b2JointId jointId, float timeStep);
386
389BOX2D_API void b2DistanceJoint_SetLength(b2JointId jointId, float length, float minLength, float maxLength);
390
393
396BOX2D_API void b2DistanceJoint_SetTuning(b2JointId jointId, float hertz, float dampingRatio);
397
399BOX2D_API void b2MotorJoint_SetLinearOffset(b2JointId jointId, b2Vec2 linearOffset);
400
402BOX2D_API void b2MotorJoint_SetAngularOffset(b2JointId jointId, float angularOffset);
403
405BOX2D_API void b2MotorJoint_SetMaxForce(b2JointId jointId, float maxForce);
406
408BOX2D_API void b2MotorJoint_SetMaxTorque(b2JointId jointId, float maxTorque);
409
411BOX2D_API void b2MotorJoint_SetCorrectionFactor(b2JointId jointId, float correctionFactor);
412
414BOX2D_API b2Vec2 b2MotorJoint_GetConstraintForce(b2JointId jointId, float inverseTimeStep);
415
417BOX2D_API float b2MotorJoint_GetConstraintTorque(b2JointId jointId, float inverseTimeStep);
418
420BOX2D_API void b2MouseJoint_SetTarget(b2JointId jointId, b2Vec2 target);
421
423BOX2D_API void b2PrismaticJoint_EnableLimit(b2JointId jointId, bool enableLimit);
424
426BOX2D_API void b2PrismaticJoint_EnableMotor(b2JointId jointId, bool enableMotor);
427
429BOX2D_API void b2PrismaticJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed);
430
432BOX2D_API float b2PrismaticJoint_GetMotorForce(b2JointId jointId, float inverseTimeStep);
433
435BOX2D_API void b2PrismaticJoint_SetMaxMotorForce(b2JointId jointId, float force);
436
438BOX2D_API b2Vec2 b2PrismaticJoint_GetConstraintForce(b2JointId jointId, float inverseTimeStep);
439
441BOX2D_API float b2PrismaticJoint_GetConstraintTorque(b2JointId jointId, float inverseTimeStep);
442
444BOX2D_API void b2RevoluteJoint_EnableLimit(b2JointId jointId, bool enableLimit);
445
447BOX2D_API void b2RevoluteJoint_EnableMotor(b2JointId jointId, bool enableMotor);
448
450BOX2D_API void b2RevoluteJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed);
451
453BOX2D_API float b2RevoluteJoint_GetMotorTorque(b2JointId jointId, float inverseTimeStep);
454
456BOX2D_API void b2RevoluteJoint_SetMaxMotorTorque(b2JointId jointId, float torque);
457
459BOX2D_API b2Vec2 b2RevoluteJoint_GetConstraintForce(b2JointId jointId, float inverseTimeStep);
460
462BOX2D_API float b2RevoluteJoint_GetConstraintTorque(b2JointId jointId, float inverseTimeStep);
463
465BOX2D_API void b2WheelJoint_SetStiffness(b2JointId jointId, float stiffness);
466
468BOX2D_API void b2WheelJoint_SetDamping(b2JointId jointId, float damping);
469
471BOX2D_API void b2WheelJoint_EnableLimit(b2JointId jointId, bool enableLimit);
472
474BOX2D_API void b2WheelJoint_EnableMotor(b2JointId jointId, bool enableMotor);
475
477BOX2D_API void b2WheelJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed);
478
480BOX2D_API float b2WheelJoint_GetMotorTorque(b2JointId jointId, float inverseTimeStep);
481
483BOX2D_API void b2WheelJoint_SetMaxMotorTorque(b2JointId jointId, float torque);
484
486BOX2D_API b2Vec2 b2WheelJoint_GetConstraintForce(b2JointId jointId, float inverseTimeStep);
487
489BOX2D_API float b2WheelJoint_GetConstraintTorque(b2JointId jointId, float inverseTimeStep);
490
b2Vec2 b2Body_GetWorldCenterOfMass(b2BodyId bodyId)
Get the center of mass position of the body in world space.
float b2Body_GetAngle(b2BodyId bodyId)
Get the world angle of a body in radians.
b2Transform b2Body_GetTransform(b2BodyId bodyId)
Get the world transform of a body.
void b2Body_Enable(b2BodyId bodyId)
Enable a body by adding it to the simulation.
void b2Body_SetAngularVelocity(b2BodyId bodyId, float angularVelocity)
Set the angular velocity of a body in radians per second.
void * b2Body_GetUserData(b2BodyId bodyId)
Get the user data stored in a body.
void b2Body_ApplyForceToCenter(b2BodyId bodyId, b2Vec2 force, bool wake)
b2Vec2 b2Body_GetLocalCenterOfMass(b2BodyId bodyId)
Get the center of mass position of the body in local space.
void b2Body_ApplyLinearImpulse(b2BodyId bodyId, b2Vec2 impulse, b2Vec2 point, bool wake)
float b2Body_GetMass(b2BodyId bodyId)
Get the mass of the body (kilograms)
void b2Body_ApplyLinearImpulseToCenter(b2BodyId bodyId, b2Vec2 impulse, bool wake)
void b2Body_ApplyTorque(b2BodyId bodyId, float torque, bool wake)
bool b2Body_IsAwake(b2BodyId bodyId)
Is this body awake?
b2Vec2 b2Body_GetLinearVelocity(b2BodyId bodyId)
Get the linear velocity of a body's center of mass.
b2ShapeId b2Body_GetFirstShape(b2BodyId bodyId)
Iterate over shapes on a body.
void b2Body_Disable(b2BodyId bodyId)
Disable a body by removing it completely from the simulation.
void b2Body_ApplyForce(b2BodyId bodyId, b2Vec2 force, b2Vec2 point, bool wake)
b2Vec2 b2Body_GetLocalPoint(b2BodyId bodyId, b2Vec2 worldPoint)
Get a local point on a body given a world point.
b2Vec2 b2Body_GetWorldVector(b2BodyId bodyId, b2Vec2 localVector)
Get a world vector on a body given a local vector.
b2Vec2 b2Body_GetWorldPoint(b2BodyId bodyId, b2Vec2 localPoint)
Get a world point on a body given a local point.
void b2Body_SetTransform(b2BodyId bodyId, b2Vec2 position, float angle)
Set the world transform of a body. This acts as a teleport and is fairly expensive.
void b2Body_SetType(b2BodyId bodyId, b2BodyType type)
Set the type of a body. This has a similar cost to re-creating the body.
void b2Body_SetMassData(b2BodyId bodyId, b2MassData massData)
void b2Body_ApplyAngularImpulse(b2BodyId bodyId, float impulse, bool wake)
float b2Body_GetInertiaTensor(b2BodyId bodyId)
Get the inertia tensor of the body. In 2D this is a single number. (kilograms * meters^2)
void b2Body_Wake(b2BodyId bodyId)
Wake a body from sleep. This wakes the entire island the body is touching.
b2Vec2 b2Body_GetLocalVector(b2BodyId bodyId, b2Vec2 worldVector)
Get a local vector on a body given a world vector.
b2Vec2 b2Body_GetPosition(b2BodyId bodyId)
Get the world position of a body. This is the location of the body origin.
int32_t b2Body_GetContactData(b2BodyId bodyId, b2ContactData *contactData, int32_t capacity)
Get the touching contact data for a body.
b2BodyId b2CreateBody(b2WorldId worldId, const b2BodyDef *def)
float b2Body_GetAngularVelocity(b2BodyId bodyId)
Get the angular velocity of a body in radians per second.
int32_t b2Body_GetContactCapacity(b2BodyId bodyId)
Get the maximum capacity required for retrieving all the touching contacts on a body.
void b2Body_SetLinearVelocity(b2BodyId bodyId, b2Vec2 linearVelocity)
Set the linear velocity of a body.
void b2DestroyBody(b2BodyId bodyId)
b2BodyType b2Body_GetType(b2BodyId bodyId)
Get the type of a body.
bool b2Body_IsEnabled(b2BodyId bodyId)
Is this body enabled?
void b2RevoluteJoint_SetMaxMotorTorque(b2JointId jointId, float torque)
Set the maximum torque for a revolute joint motor.
void b2MotorJoint_SetLinearOffset(b2JointId jointId, b2Vec2 linearOffset)
Set the linear offset target for a motor joint.
b2JointId b2CreateMotorJoint(b2WorldId worldId, const b2MotorJointDef *def)
void b2DistanceJoint_SetTuning(b2JointId jointId, float hertz, float dampingRatio)
void b2WheelJoint_SetMaxMotorTorque(b2JointId jointId, float torque)
Set the wheel joint maximum motor torque.
b2BodyId b2Joint_GetBodyA(b2JointId jointId)
Get body A on a joint.
void b2DistanceJoint_SetLength(b2JointId jointId, float length, float minLength, float maxLength)
void b2WheelJoint_SetDamping(b2JointId jointId, float damping)
Set the wheel joint damping.
void b2WheelJoint_SetStiffness(b2JointId jointId, float stiffness)
Set the wheel joint stiffness.
void b2PrismaticJoint_SetMaxMotorForce(b2JointId jointId, float force)
Set the maximum force for a pristmatic joint motor.
b2JointId b2CreatePrismaticJoint(b2WorldId worldId, const b2PrismaticJointDef *def)
b2JointId b2CreateMouseJoint(b2WorldId worldId, const b2MouseJointDef *def)
float b2PrismaticJoint_GetConstraintTorque(b2JointId jointId, float inverseTimeStep)
Get the current constraint torque for a prismatic joint.
void b2WheelJoint_EnableLimit(b2JointId jointId, bool enableLimit)
Enable/disable the wheel joint limit.
b2Vec2 b2RevoluteJoint_GetConstraintForce(b2JointId jointId, float inverseTimeStep)
Get the current constraint force for a revolute joint.
b2JointId b2CreateRevoluteJoint(b2WorldId worldId, const b2RevoluteJointDef *def)
b2JointId b2CreateWeldJoint(b2WorldId worldId, const b2WeldJointDef *def)
float b2WheelJoint_GetConstraintTorque(b2JointId jointId, float inverseTimeStep)
Get the current wheel joint constraint torque.
void b2MotorJoint_SetMaxTorque(b2JointId jointId, float maxTorque)
Set the maximum torque for a motor joint.
void b2PrismaticJoint_EnableMotor(b2JointId jointId, bool enableMotor)
Enable/disable a prismatic joint motor.
void b2MotorJoint_SetAngularOffset(b2JointId jointId, float angularOffset)
Set the angular offset target for a motor joint in radians.
b2Vec2 b2MotorJoint_GetConstraintForce(b2JointId jointId, float inverseTimeStep)
Get the current constraint force for a motor joint.
void b2MotorJoint_SetMaxForce(b2JointId jointId, float maxForce)
Set the maximum force for a motor joint.
float b2PrismaticJoint_GetMotorForce(b2JointId jointId, float inverseTimeStep)
Get the current motor force for a prismatic joint.
void b2PrismaticJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed)
Set the motor speed for a prismatic joint.
b2JointId b2CreateDistanceJoint(b2WorldId worldId, const b2DistanceJointDef *def)
b2Vec2 b2WheelJoint_GetConstraintForce(b2JointId jointId, float inverseTimeStep)
Get the current wheel joint constraint force.
void b2PrismaticJoint_EnableLimit(b2JointId jointId, bool enableLimit)
Enable/disable a prismatic joint limit.
void b2WheelJoint_EnableMotor(b2JointId jointId, bool enableMotor)
Enable/disable the wheel joint motor.
float b2MotorJoint_GetConstraintTorque(b2JointId jointId, float inverseTimeStep)
Get the current constraint torque for a motor joint.
float b2DistanceJoint_GetConstraintForce(b2JointId jointId, float timeStep)
Get the constraint force on a distance joint.
void b2RevoluteJoint_EnableMotor(b2JointId jointId, bool enableMotor)
Enable/disable a revolute joint motor.
b2JointId b2CreateWheelJoint(b2WorldId worldId, const b2WheelJointDef *def)
float b2DistanceJoint_GetCurrentLength(b2JointId jointId)
Get the current length of a distance joint.
void b2RevoluteJoint_EnableLimit(b2JointId jointId, bool enableLimit)
Enable/disable a revolute joint limit.
float b2RevoluteJoint_GetMotorTorque(b2JointId jointId, float inverseTimeStep)
Get the current motor torque for a revolute joint.
b2Vec2 b2PrismaticJoint_GetConstraintForce(b2JointId jointId, float inverseTimeStep)
Get the current constraint force for a prismatic joint.
void b2WheelJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed)
Set the wheel joint motor speed in radians per second.
void b2MotorJoint_SetCorrectionFactor(b2JointId jointId, float correctionFactor)
Set the correction factor for a motor joint.
float b2WheelJoint_GetMotorTorque(b2JointId jointId, float inverseTimeStep)
Get the wheel joint current motor torque.
float b2RevoluteJoint_GetConstraintTorque(b2JointId jointId, float inverseTimeStep)
Get the current constraint torque for a revolute joint.
void b2RevoluteJoint_SetMotorSpeed(b2JointId jointId, float motorSpeed)
Set the motor speed for a revolute joint in radians per second.
void b2MouseJoint_SetTarget(b2JointId jointId, b2Vec2 target)
Set the target for a mouse joint.
void b2DestroyJoint(b2JointId jointId)
Destroy any joint type.
b2BodyId b2Joint_GetBodyB(b2JointId jointId)
Get body B on a joint.
const b2Circle * b2Shape_GetCircle(b2ShapeId shapeId)
Access the circle geometry of a shape.
b2BodyId b2Shape_GetBody(b2ShapeId shapeId)
Get the body that a shape is attached to.
void b2Shape_SetFriction(b2ShapeId shapeId, float friction)
Set the friction on a shape. Normally this is specified in b2ShapeDef.
b2ShapeId b2CreateCircleShape(b2BodyId bodyId, const b2ShapeDef *def, const b2Circle *circle)
void b2Chain_SetRestitution(b2ChainId chainId, float restitution)
Set the restitution (bounciness) on a chain. Normally this is specified in b2ChainDef.
b2ShapeType b2Shape_GetType(b2ShapeId shapeId)
Get the type of a shape.
const b2Capsule * b2Shape_GetCapsule(b2ShapeId shapeId)
Access the capsule geometry of a shape.
void b2DestroyShape(b2ShapeId shapeId)
Destroy any shape type.
int32_t b2Shape_GetContactCapacity(b2ShapeId shapeId)
Get the maximum capacity required for retrieving all the touching contacts on a shape.
const b2Segment * b2Shape_GetSegment(b2ShapeId shapeId)
Access the line segment geometry of a shape.
b2ShapeId b2CreateCapsuleShape(b2BodyId bodyId, const b2ShapeDef *def, const b2Capsule *capsule)
bool b2Shape_TestPoint(b2ShapeId shapeId, b2Vec2 point)
Test a point for overlap with a shape.
int32_t b2Shape_GetContactData(b2ShapeId shapeId, b2ContactData *contactData, int32_t capacity)
Get the touching contact data for a shape. The provided shapeId will be either shapeIdA or shapeIdB o...
void * b2Shape_GetUserData(b2ShapeId shapeId)
void b2DestroyChain(b2ChainId chainId)
Destroy a chain shape.
b2ShapeId b2CreatePolygonShape(b2BodyId bodyId, const b2ShapeDef *def, const b2Polygon *polygon)
const b2Polygon * b2Shape_GetPolygon(b2ShapeId shapeId)
Access the convex polygon geometry of a shape.
b2ChainId b2CreateChain(b2BodyId bodyId, const b2ChainDef *def)
b2ShapeId b2CreateSegmentShape(b2BodyId bodyId, const b2ShapeDef *def, const b2Segment *segment)
const b2SmoothSegment * b2Shape_GetSmoothSegment(b2ShapeId shapeId)
Access the smooth line segment geometry of a shape. These come from chain shapes.
void b2Chain_SetFriction(b2ChainId chainId, float friction)
Set the friction of a chain. Normally this is set in b2ChainDef.
void b2Shape_SetRestitution(b2ShapeId shapeId, float restitution)
Set the restitution (bounciness) on a shape. Normally this is specified in b2ShapeDef.
void b2World_SetContactTuning(b2WorldId worldId, float hertz, float dampingRatio, float pushVelocity)
void b2World_EnableSleeping(b2WorldId worldId, bool flag)
Enable/disable sleep. Advanced feature for testing.
void b2World_Step(b2WorldId worldId, float timeStep, int32_t velocityIterations, int32_t relaxIterations)
void b2World_EnableContinuous(b2WorldId worldId, bool flag)
Enable/disable continuous collision. Advanced feature for testing.
void b2World_Draw(b2WorldId worldId, b2DebugDraw *debugDraw)
Call this to draw shapes and other debug draw data. This is intentionally non-const.
void b2World_RayCast(b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter, b2RayResultFcn *fcn, void *context)
b2WorldId b2CreateWorld(const b2WorldDef *def)
Create a world for rigid body simulation. This contains all the bodies, shapes, and constraints.
void b2World_OverlapCapsule(b2WorldId worldId, b2QueryResultFcn *fcn, const b2Capsule *capsule, b2Transform transform, b2QueryFilter filter, void *context)
Query the world for all shapes that overlap the provided capsule.
void b2World_PolygonCast(b2WorldId worldId, const b2Polygon *polygon, b2Transform originTransform, b2Vec2 translation, b2QueryFilter filter, b2RayResultFcn *fcn, void *context)
Cast a capsule through the world. Similar to a ray-cast except that a polygon is cast instead of a po...
struct b2Profile b2World_GetProfile(b2WorldId worldId)
Get the current profile.
b2ContactEvents b2World_GetContactEvents(b2WorldId worldId)
Get contact events for this current time step. The event data is transient. Do not store a reference ...
b2RayResult b2World_RayCastClosest(b2WorldId worldId, b2Vec2 origin, b2Vec2 translation, b2QueryFilter filter)
Ray-cast closest hit. Convenience function. This is less general than b2World_RayCast and does not al...
void b2World_EnableWarmStarting(b2WorldId worldId, bool flag)
Enable/disable constraint warm starting. Advanced feature for testing.
void b2World_CircleCast(b2WorldId worldId, const b2Circle *circle, b2Transform originTransform, b2Vec2 translation, b2QueryFilter filter, b2RayResultFcn *fcn, void *context)
Cast a circle through the world. Similar to a ray-cast except that a circle is cast instead of a poin...
b2SensorEvents b2World_GetSensorEvents(b2WorldId worldId)
Get sensor events for the current time step. The event data is transient. Do not store a reference to...
void b2World_CapsuleCast(b2WorldId worldId, const b2Capsule *capsule, b2Transform originTransform, b2Vec2 translation, b2QueryFilter filter, b2RayResultFcn *fcn, void *context)
Cast a capsule through the world. Similar to a ray-cast except that a capsule is cast instead of a po...
void b2DestroyWorld(b2WorldId worldId)
Destroy a world.
void b2World_QueryAABB(b2WorldId worldId, b2QueryResultFcn *fcn, b2AABB aabb, b2QueryFilter filter, void *context)
Query the world for all shapes that potentially overlap the provided AABB.
struct b2Statistics b2World_GetStatistics(b2WorldId worldId)
Get counters and sizes.
void b2World_SetRestitutionThreshold(b2WorldId worldId, float value)
Adjust the restitution threshold. Advanced feature for testing.
void b2World_OverlapCircle(b2WorldId worldId, b2QueryResultFcn *fcn, const b2Circle *circle, b2Transform transform, b2QueryFilter filter, void *context)
Query the world for all shapes that overlap the provided circle.
void b2World_OverlapPolygon(b2WorldId worldId, b2QueryResultFcn *fcn, const b2Polygon *polygon, b2Transform transform, b2QueryFilter filter, void *context)
Query the world for all shapes that overlap the provided polygon.
Body identitifier.
Definition id.h:23
A solid capsule.
Definition geometry.h:44
References a chain instances.
Definition id.h:47
A solid circle.
Definition geometry.h:37
Definition event_types.h:68
Definition event_types.h:58
This struct holds callbacks you can implement to draw a box2d world.
Definition debug_draw.h:10
Definition joint_types.h:13
References a joint instance.
Definition id.h:39
This holds the mass data computed for a shape.
Definition geometry.h:16
Definition joint_types.h:67
Definition joint_types.h:109
Definition geometry.h:56
Definition joint_types.h:150
Profiling data. Times are in milliseconds.
Definition timer.h:10
Use an instance of this structure and the callback below to get the closest hit.
Definition callbacks.h:52
Definition joint_types.h:222
A line segment with two-sided collision.
Definition geometry.h:66
Definition event_types.h:31
References a shape instance.
Definition id.h:31
Definition geometry.h:74
Counters that give details of the simulation size.
Definition timer.h:26
Definition joint_types.h:289
Definition joint_types.h:349
World identifier.
Definition id.h:16
types used by the Box2D API
b2BodyType
Definition types.h:191
b2ShapeType
Shape type.
Definition types.h:289
Axis-aligned bounding box.
Definition types.h:75
Definition types.h:201
Definition types.h:349
This holds contact filtering data.
Definition types.h:275
Used to create a shape.
Definition types.h:300
A 2D rigid transform.
Definition types.h:61
Definition types.h:47
World definition used to create a simulation world. Must be initialized using b2DefaultWorldDef.
Definition types.h:124