### b2World_EnableWarmStarting Source: https://box2d.org/documentation/group__world.html Enables or disables warm starting for the world. Warm starting can improve simulation performance. ```APIDOC ## b2World_EnableWarmStarting ### Description Enable warm starting. ### Method B2_API void ### Parameters - **worldId** (b2WorldId) - The identifier of the world. - **flag** (bool) - True to enable warm starting, false to disable. ``` -------------------------------- ### Enable/Disable Warm Starting in Box2D Source: https://box2d.org/documentation/box2d_8h_source.html Control the use of warm starting for iterative solvers to improve performance. Use b2World_IsWarmStartingEnabled to check the current state. ```c B2_API void b2World_EnableWarmStarting( b2WorldId worldId, bool flag ); B2_API bool b2World_IsWarmStartingEnabled( b2WorldId worldId ); ``` -------------------------------- ### Warm Starting and Speculative Contact Source: https://box2d.org/documentation/box2d_8h_source.html Controls and queries the state of warm starting and speculative contact features. ```APIDOC ## b2World_EnableWarmStarting ### Description Enables or disables warm starting for the solver. Warm starting reuses previous solution values to speed up convergence. ### Method `b2World_EnableWarmStarting` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **flag** (*bool*): `true` to enable warm starting, `false` to disable. ``` ```APIDOC ## b2World_IsWarmStartingEnabled ### Description Checks if warm starting is currently enabled for the world. ### Method `b2World_IsWarmStartingEnabled` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. ### Returns - **bool**: `true` if warm starting is enabled, `false` otherwise. ``` ```APIDOC ## b2World_EnableSpeculative ### Description Enables or disables speculative contact. Speculative contact allows contacts to be resolved before they actually occur, improving stability. ### Method `b2World_EnableSpeculative` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **flag** (*bool*): `true` to enable speculative contact, `false` to disable. ``` -------------------------------- ### b2World_IsWarmStartingEnabled Source: https://box2d.org/documentation/group__world.html Checks if constraint warm starting is enabled for the specified world. ```APIDOC ## b2World_IsWarmStartingEnabled ### Description Checks if constraint warm starting is enabled for the specified world. ### Method N/A (Function Call) ### Parameters #### Path Parameters - **worldId** (b2WorldId) - Required - Identifier for the Box2D world. ### Response #### Success Response - **return value** (bool) - True if warm starting is enabled, false otherwise. ### Response Example ``` // Example usage (conceptual) bool isEnabled = b2World_IsWarmStartingEnabled(myWorldId); ``` ``` -------------------------------- ### b2Chain_GetMaterial Source: https://box2d.org/documentation/group__shape.html Get the chain material. ```APIDOC ## b2Chain_GetMaterial ### Description Get the chain material. ### Signature B2_API int | **b2Chain_GetMaterial** (b2ChainId chainId) ``` -------------------------------- ### Mouse Joint Creation and Configuration Source: https://box2d.org/documentation/group__mouse__joint.html Functions for creating, setting, and getting properties of a mouse joint. ```APIDOC ## b2CreateMouseJoint ### Description Creates a mouse joint, which is used to make a point on a body track a specified world point. This is a soft constraint that allows stretching without applying huge forces and includes a rotation constraint heuristic for improved control. ### Method `b2JointId b2CreateMouseJoint(b2WorldId worldId, const b2MouseJointDef *def)` ### Parameters #### Path Parameters - `worldId` (b2WorldId) - The ID of the world in which to create the joint. - `def` (const b2MouseJointDef *) - A pointer to the mouse joint definition structure. ### Response #### Success Response (b2JointId) - Returns the ID of the newly created mouse joint. ## b2MouseJoint_SetTarget ### Description Sets the target world point for the mouse joint. ### Method `void b2MouseJoint_SetTarget(b2JointId jointId, b2Vec2 target)` ### Parameters #### Path Parameters - `jointId` (b2JointId) - The ID of the mouse joint. - `target` (b2Vec2) - The new target point in world space. ## b2MouseJoint_GetTarget ### Description Gets the current target world point of the mouse joint. ### Method `b2Vec2 b2MouseJoint_GetTarget(b2JointId jointId)` ### Parameters #### Path Parameters - `jointId` (b2JointId) - The ID of the mouse joint. ### Response #### Success Response (b2Vec2) - Returns the current target point in world space. ## b2MouseJoint_SetSpringHertz ### Description Sets the spring stiffness of the mouse joint in Hertz. ### Method `void b2MouseJoint_SetSpringHertz(b2JointId jointId, float hertz)` ### Parameters #### Path Parameters - `jointId` (b2JointId) - The ID of the mouse joint. - `hertz` (float) - The desired spring stiffness in Hertz. ## b2MouseJoint_GetSpringHertz ### Description Gets the spring stiffness of the mouse joint in Hertz. ### Method `float b2MouseJoint_GetSpringHertz(b2JointId jointId)` ### Parameters #### Path Parameters - `jointId` (b2JointId) - The ID of the mouse joint. ### Response #### Success Response (float) - Returns the current spring stiffness in Hertz. ## b2MouseJoint_SetSpringDampingRatio ### Description Sets the damping ratio for the mouse joint's spring. This value is non-dimensional. ### Method `void b2MouseJoint_SetSpringDampingRatio(b2JointId jointId, float dampingRatio)` ### Parameters #### Path Parameters - `jointId` (b2JointId) - The ID of the mouse joint. - `dampingRatio` (float) - The desired damping ratio. ## b2MouseJoint_GetSpringDampingRatio ### Description Gets the damping ratio of the mouse joint's spring. ### Method `float b2MouseJoint_GetSpringDampingRatio(b2JointId jointId)` ### Parameters #### Path Parameters - `jointId` (b2JointId) - The ID of the mouse joint. ### Response #### Success Response (float) - Returns the current damping ratio. ## b2MouseJoint_SetMaxForce ### Description Sets the maximum force that the mouse joint can exert, typically in Newtons. ### Method `void b2MouseJoint_SetMaxForce(b2JointId jointId, float maxForce)` ### Parameters #### Path Parameters - `jointId` (b2JointId) - The ID of the mouse joint. - `maxForce` (float) - The maximum force allowed. ## b2MouseJoint_GetMaxForce ### Description Gets the maximum force that the mouse joint can exert. ### Method `float b2MouseJoint_GetMaxForce(b2JointId jointId)` ### Parameters #### Path Parameters - `jointId` (b2JointId) - The ID of the mouse joint. ### Response #### Success Response (float) - Returns the current maximum force. ## b2DefaultMouseJointDef ### Description Provides a default definition structure for a mouse joint, which can be used to initialize a new joint. ### Method `b2MouseJointDef b2DefaultMouseJointDef(void)` ### Response #### Success Response (b2MouseJointDef) - Returns a `b2MouseJointDef` structure with default values. ``` -------------------------------- ### Tuning Parameters Source: https://box2d.org/documentation/box2d_8h_source.html Functions to set and get various tuning parameters that affect simulation behavior. ```APIDOC ## b2World_SetRestitutionThreshold ### Description Sets the threshold for restitution. Velocities below this threshold will not generate restitution. ### Method `b2World_SetRestitutionThreshold` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **value** (*float*): The restitution threshold value. ``` ```APIDOC ## b2World_GetRestitutionThreshold ### Description Gets the current restitution threshold for the world. ### Method `b2World_GetRestitutionThreshold` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. ### Returns - **float**: The current restitution threshold. ``` ```APIDOC ## b2World_SetHitEventThreshold ### Description Sets the threshold for hit events. Collisions with relative velocity above this threshold will generate hit events. ### Method `b2World_SetHitEventThreshold` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **value** (*float*): The hit event threshold value. ``` ```APIDOC ## b2World_GetHitEventThreshold ### Description Gets the current hit event threshold for the world. ### Method `b2World_GetHitEventThreshold` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. ### Returns - **float**: The current hit event threshold. ``` ```APIDOC ## b2World_SetContactTuning ### Description Sets tuning parameters for contact solvers, affecting how contacts are resolved. ### Method `b2World_SetContactTuning` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **hertz** (*float*): The frequency for the contact spring. - **dampingRatio** (*float*): The damping ratio for the contact spring. - **pushSpeed** (*float*): The speed used for pushing contacts apart. ``` ```APIDOC ## b2World_SetJointTuning ### Description Sets tuning parameters for joint solvers, affecting how joints are resolved. ### Method `b2World_SetJointTuning` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **hertz** (*float*): The frequency for the joint spring. - **dampingRatio** (*float*): The damping ratio for the joint spring. ``` ```APIDOC ## b2World_SetMaximumLinearSpeed ### Description Sets the maximum linear speed for any body in the world. This is a safety clamp. ### Method `b2World_SetMaximumLinearSpeed` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **maximumLinearSpeed** (*float*): The maximum allowed linear speed. ``` ```APIDOC ## b2World_GetMaximumLinearSpeed ### Description Gets the maximum linear speed allowed for bodies in the world. ### Method `b2World_GetMaximumLinearSpeed` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. ### Returns - **float**: The maximum linear speed. ``` -------------------------------- ### Get Shape Count Source: https://box2d.org/documentation/md_simulation.html Get the number of shapes attached to a body. ```APIDOC ## b2Body_GetShapeCount ### Description Get the number of shapes on this body. ### Method `int b2Body_GetShapeCount(b2BodyId bodyId)` ### Parameters - **bodyId** (b2BodyId) - The ID of the body. ### Returns - **int** - The number of shapes on the body. ``` -------------------------------- ### Initialize World Definition Source: https://box2d.org/documentation/hello.html Use b2DefaultWorldDef() to populate a b2WorldDef with default values. This is necessary as C lacks constructors and zero initialization is not suitable for b2WorldDef. ```c b2WorldDef worldDef = b2DefaultWorldDef(); ``` -------------------------------- ### Get Body Transform Source: https://box2d.org/documentation/md_simulation.html Get the world transform of a body, which includes its position and rotation. ```c++ b2Transform transform = b2Body_GetTransform(myBodyId); ``` -------------------------------- ### b2DefaultSurfaceMaterial Source: https://box2d.org/documentation/group__shape.html Use this to initialize your surface material. ```APIDOC ## b2DefaultSurfaceMaterial ### Description Use this to initialize your surface material. ### Signature b2SurfaceMaterial | **b2DefaultSurfaceMaterial** (void) ``` -------------------------------- ### b2World_EnableWarmStarting Source: https://box2d.org/documentation/group__world.html Enables or disables constraint warm starting. This is an advanced feature for testing; disabling it greatly reduces stability and offers no performance gain. ```APIDOC ## b2World_EnableWarmStarting() ### Description Enable/disable constraint warm starting. Advanced feature for testing. Disabling warm starting greatly reduces stability and provides no performance gain. ### Parameters - **worldId** (b2WorldId) - The world to modify - **flag** (bool) - True to enable warm starting, false to disable ### Returns - void ``` -------------------------------- ### Get Revolute Joint Current Angle Source: https://box2d.org/documentation/group__revolute__joint.html Gets the current angle of the revolute joint in radians, relative to its reference angle. Useful for tracking rotation. ```c++ B2_API float | b2RevoluteJoint_GetAngle (b2JointId jointId) ``` -------------------------------- ### Coordinate System Scaling for Rendering Source: https://box2d.org/documentation/md_loose__ends.html Example of setting up an OpenGL viewport to scale Box2D's MKS units to screen space for rendering. ```C++ float lowerX = -25.0f, upperX = 25.0f, lowerY = -5.0f, upperY = 25.0f; gluOrtho2D(lowerX, upperX, lowerY, upperY); ``` -------------------------------- ### Convert Pixels to Meters Example Source: https://box2d.org/documentation/md_faq.html Demonstrates how to convert between pixel coordinates and meters using a scaling factor. This is crucial for aligning game sprites with physics objects. ```text Suppose you have a sprite for a character that is 100x100 pixels. You decide to use a scaling factor that is 0.01. This will make the character physics box 1m x 1m. So go make a physics box that is 1x1. Now suppose the character starts out at pixel coordinate (345,679). So position the physics box at (3.45,6.79). Now simulate the physics world. Suppose the character physics box moves to (2.31,4.98), so move your character sprite to pixel coordinates (231,498). Now the only tricky part is choosing a scaling factor. This really depends on your game. You should try to get your moving objects in the range 0.1 - 10 meters, with 1 meter being the sweet spot. ``` -------------------------------- ### Step World with Sub-stepping (v3.0) Source: https://box2d.org/documentation/md_migration.html Simulates the Box2D world for one time step using the new sub-stepping solver. Recommended to start with 4 sub-steps and adjust as needed. ```cpp void b2World_Step(b2WorldId worldId, float timeStep, int32_t subStepCount); ``` -------------------------------- ### b2Body_GetMass Source: https://box2d.org/documentation/box2d_8h_source.html Gets the mass of the body. ```APIDOC ## b2Body_GetMass ### Description Gets the mass of the physics body. ### Method `b2Body_GetMass` ### Parameters - **bodyId** (b2BodyId) - The identifier of the body. ### Returns - **float** - The mass of the body. ``` -------------------------------- ### b2DefaultChainDef Source: https://box2d.org/documentation/group__shape.html Use this to initialize your chain definition. ```APIDOC ## b2DefaultChainDef ### Description Use this to initialize your chain definition. ### Signature b2ChainDef | **b2DefaultChainDef** (void) ``` -------------------------------- ### Create and Destroy Box2D World Source: https://box2d.org/documentation/box2d_8h_source.html Use b2CreateWorld to initialize a new physics world and b2DestroyWorld to clean it up. Ensure the world definition is valid before creation. ```c B2_API b2WorldId b2CreateWorld( const b2WorldDef* def ); B2_API void b2DestroyWorld( b2WorldId worldId ); ``` -------------------------------- ### b2Chain_GetRestitution Source: https://box2d.org/documentation/group__shape.html Get the chain restitution. ```APIDOC ## b2Chain_GetRestitution ### Description Get the chain restitution. ### Signature B2_API float | **b2Chain_GetRestitution** (b2ChainId chainId) ``` -------------------------------- ### Box2D Simulation Loop - Time Step Source: https://box2d.org/documentation/md_simulation.html Starts the Box2D simulation by calling b2World_Step with the provided time step. This is the entry point for advancing the simulation. ```c b2World_Step ``` -------------------------------- ### b2Chain_GetFriction Source: https://box2d.org/documentation/group__shape.html Get the chain friction. ```APIDOC ## b2Chain_GetFriction ### Description Get the chain friction. ### Signature B2_API float | **b2Chain_GetFriction** (b2ChainId chainId) ``` -------------------------------- ### Create Dynamic Body (Box2D v2.4) Source: https://box2d.org/documentation/md_migration.html Demonstrates creating a dynamic rigid body in Box2D version 2.4. Requires a b2World object. ```cpp b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody; bodyDef.position.Set(0.0f, 4.0f); b2Body* body = world.CreateBody(&bodyDef); ``` -------------------------------- ### b2Body_GetMassData Source: https://box2d.org/documentation/box2d_8h_source.html Gets the mass data for the body. ```APIDOC ## b2Body_GetMassData ### Description Gets the mass data for the physics body. ### Method `b2Body_GetMassData` ### Parameters - **bodyId** (b2BodyId) - The identifier of the body. ### Returns - **b2MassData** - The mass data of the body. ``` -------------------------------- ### b2Body_GetRotationalInertia Source: https://box2d.org/documentation/box2d_8h_source.html Gets the rotational inertia of the body. ```APIDOC ## b2Body_GetRotationalInertia ### Description Gets the rotational inertia of the physics body. ### Method `b2Body_GetRotationalInertia` ### Parameters - **bodyId** (b2BodyId) - The identifier of the body. ### Returns - **float** - The rotational inertia of the body. ``` -------------------------------- ### Configure Multithreading for World Source: https://box2d.org/documentation/md_simulation.html Set up multithreading options for the world definition, including worker count and task callback functions. This can significantly improve performance. ```c worldDef.workerCount = 4; worldDef.enqueueTask = myAddTaskFunction; worldDef.finishTask = myFinishTaskFunction; worldDef.userTaskContext = &myTaskSystem; ``` -------------------------------- ### Initialize Body Position and Angle Source: https://box2d.org/documentation/md_simulation.html Set the initial world position and angle for a body within its definition. This is more performant than creating the body at the world origin and then moving it. ```c b2BodyDef bodyDef = b2DefaultBodyDef(); bodyDef.position = (b2Vec2){0.0f, 2.0f}; bodyDef.angle = 0.25f * b2_pi; ``` -------------------------------- ### b2DynamicTree_GetHeight Source: https://box2d.org/documentation/collision_8h_source.html Gets the height of the dynamic tree. ```APIDOC ## b2DynamicTree_GetHeight ### Description Gets the height of the dynamic tree. ### Parameters #### Path Parameters - **tree** (const b2DynamicTree*) - Pointer to the dynamic tree. ### Function Signature `int b2DynamicTree_GetHeight( const b2DynamicTree* tree );` ``` -------------------------------- ### b2Rot_GetYAxis Source: https://box2d.org/documentation/math__functions_8h_source.html Gets the y-axis vector of a rotation. ```APIDOC ## b2Rot_GetYAxis ### Description Gets the y-axis vector of a rotation. ### Signature `b2Vec2 b2Rot_GetYAxis( b2Rot q )` ### Parameters * `q` (b2Rot) - The rotation. ### Returns * `b2Vec2` - The y-axis vector. ``` -------------------------------- ### Configure a Soft Distance Joint (Spring) Source: https://box2d.org/documentation/md_simulation.html This example demonstrates how to configure a distance joint to act as a spring. It enables the spring behavior and sets the Hertz (stiffness) and damping ratio for the spring-damper connection. ```c jointDef.enableSpring = true; jointDef.hertz = 2.0f; jointDef.dampingRatio = 0.5f; ``` -------------------------------- ### Create a Box2D Body Source: https://box2d.org/documentation/index.html Use `b2DefaultBodyDef()` to initialize a body definition, set its position, and then create the body using `b2CreateBody()`. Definitions are temporary and copied internally. ```c++ b2BodyDef bodyDef = b2DefaultBodyDef(); bodyDef.position = (b2Vec2){10.0f, 5.0f}; b2BodyId myBodyId = b2CreateBody(myWorldId, &bodyDef); ``` -------------------------------- ### b2Rot_GetXAxis Source: https://box2d.org/documentation/math__functions_8h_source.html Gets the x-axis vector of a rotation. ```APIDOC ## b2Rot_GetXAxis ### Description Gets the x-axis vector of a rotation. ### Signature `b2Vec2 b2Rot_GetXAxis( b2Rot q )` ### Parameters * `q` (b2Rot) - The rotation. ### Returns * `b2Vec2` - The x-axis vector. ``` -------------------------------- ### b2Rot_GetAngle Source: https://box2d.org/documentation/math__functions_8h_source.html Gets the angle of a rotation in radians. ```APIDOC ## b2Rot_GetAngle ### Description Gets the angle of a rotation in radians. ### Signature `float b2Rot_GetAngle( b2Rot q )` ### Parameters * `q` (b2Rot) - The rotation. ### Returns * `float` - The angle in radians. ``` -------------------------------- ### Create Chain Loop (Version 2.4) Source: https://box2d.org/documentation/md_migration.html Demonstrates how to create a chain loop using the older API in Box2D Version 2.4. Requires manual setup of points and fixture definition. ```cpp b2Vec2 points[5]; points[0].Set(-8.0f, 6.0f); points[1].Set(-8.0f, 20.0f); points[2].Set(8.0f, 20.0f); points[3].Set(8.0f, 6.0f); points[4].Set(0.0f, -2.0f); b2ChainShape chain; chain.CreateLoop(points, 5); b2FixtureDef fixtureDef; fixtureDef.shape = &chain; b2Fixture* chainFixture = body->CreateFixture(&fixtureDef); ``` -------------------------------- ### b2Chain_GetSegmentCount Source: https://box2d.org/documentation/group__shape.html Get the number of segments on this chain. ```APIDOC ## b2Chain_GetSegmentCount ### Description Get the number of segments on this chain. ### Signature B2_API int | **b2Chain_GetSegmentCount** (b2ChainId chainId) ``` -------------------------------- ### Shape Cast Example Source: https://box2d.org/documentation/md_collision.html Demonstrates how to perform a shape cast against a polygon. The input includes points defining the shape, its radius, translation, and maximum fraction to consider. The output indicates if a hit occurred. ```cpp b2ShapeCastInput input = {0}; input.points[0] = (b2Vec2){1.0f, 0.0f}; input.points[1] = (b2Vec2){2.0f, -3.0f}; input.radius = 0.2f; input.translation = (b2Vec2){1.0f, 0.0f}; input.maxFraction = 1.0f; b2CastOutput output = b2ShapeCastPolygon(&input, &myPolygon); if (output.hit == true) { // do something } ``` -------------------------------- ### b2Shape_GetMassData Source: https://box2d.org/documentation/group__shape.html Get the mass data for a shape. ```APIDOC ## b2Shape_GetMassData ### Description Get the mass data for a shape. ### Signature B2_API b2MassData | **b2Shape_GetMassData** (b2ShapeId shapeId) ``` -------------------------------- ### Create a Rigid Body with an ID Source: https://box2d.org/documentation/md_simulation.html Demonstrates how to create a rigid body in a Box2D world using a body definition and obtaining a unique body ID. ```c b2BodyId myBodyId = b2CreateBody(myWorldId, &myBodyDef); ``` -------------------------------- ### b2Shape_GetAABB Source: https://box2d.org/documentation/group__shape.html Get the current world AABB. ```APIDOC ## b2Shape_GetAABB ### Description Get the current world AABB. ### Signature B2_API b2AABB | **b2Shape_GetAABB** (b2ShapeId shapeId) ``` -------------------------------- ### b2Body_GetAngularVelocity Source: https://box2d.org/documentation/box2d_8h_source.html Gets the angular velocity of a given body. ```APIDOC ## b2Body_GetAngularVelocity ### Description Gets the angular velocity of a physics body. ### Method `b2Body_GetAngularVelocity` ### Parameters - **bodyId** (b2BodyId) - The identifier of the body. ### Returns - **float** - The angular velocity of the body. ``` -------------------------------- ### Box2D C World ID Initialization Source: https://box2d.org/documentation/group__id.html Demonstrates how to initialize a b2WorldId in C. All IDs are considered null if initialized to zero. ```c b2WorldId worldId = {0}; ``` -------------------------------- ### b2Body_GetRotation Source: https://box2d.org/documentation/box2d_8h_source.html Gets the world-space rotation of a given body. ```APIDOC ## b2Body_GetRotation ### Description Gets the world-space rotation of a physics body. ### Method `b2Body_GetRotation` ### Parameters - **bodyId** (b2BodyId) - The identifier of the body. ### Returns - **b2Rot** - The world-space rotation of the body. ``` -------------------------------- ### b2DefaultFilter Source: https://box2d.org/documentation/group__shape.html Use this to initialize your filter. ```APIDOC ## b2DefaultFilter ### Description Use this to initialize your filter. ### Signature b2Filter | **b2DefaultFilter** (void) ``` -------------------------------- ### b2Body_GetPosition Source: https://box2d.org/documentation/box2d_8h_source.html Gets the world-space position of a given body. ```APIDOC ## b2Body_GetPosition ### Description Gets the world-space position of a physics body. ### Method `b2Body_GetPosition` ### Parameters - **bodyId** (b2BodyId) - The identifier of the body. ### Returns - **b2Vec2** - The world-space position of the body. ``` -------------------------------- ### Create a Dynamic Body Source: https://box2d.org/documentation/hello.html Use `b2CreateBody` with `b2_dynamicBody` type and set the initial position. Avoid creating bodies at the origin and then moving them to prevent lag. ```cpp b2BodyDef bodyDef = b2DefaultBodyDef(); bodyDef.type = b2_dynamicBody; bodyDef.position = (b2Vec2){0.0f, 4.0f}; b2BodyId bodyId = b2CreateBody(worldId, &bodyDef); ``` -------------------------------- ### b2DynamicTree_GetAABB Source: https://box2d.org/documentation/collision_8h_source.html Gets the AABB of a proxy in the dynamic tree. ```APIDOC ## b2DynamicTree_GetAABB ### Description Gets the AABB of a proxy in the dynamic tree. ### Parameters #### Path Parameters - **tree** (const b2DynamicTree*) - Pointer to the dynamic tree. - **proxyId** (int) - The ID of the proxy. ### Function Signature `b2AABB b2DynamicTree_GetAABB( const b2DynamicTree* tree, int proxyId );` ``` -------------------------------- ### Initialize b2ChainSegment Source: https://box2d.org/documentation/md_collision.html Initializes a b2ChainSegment with ghost vertices and a line segment. This is a foundational step for creating chain segments that help eliminate ghost collisions. ```c b2ChainSegment chainSegment = {0}; chainSegment.ghost1 = (b2Vec2){1.7f, 0.0f}; chainSegment.segment = (b2Segment){{1.0f, 0.25f}, {0.0f, 0.0f}}; chainSegment.ghost2 = (b2Vec2){-1.7f, 0.4f}; ``` -------------------------------- ### b2DynamicTree_GetProxyCount Source: https://box2d.org/documentation/collision_8h_source.html Gets the number of proxies in the dynamic tree. ```APIDOC ## b2DynamicTree_GetProxyCount ### Description Gets the number of proxies in the dynamic tree. ### Parameters #### Path Parameters - **tree** (const b2DynamicTree*) - Pointer to the dynamic tree. ### Function Signature `int b2DynamicTree_GetProxyCount( const b2DynamicTree* tree );` ``` -------------------------------- ### b2DynamicTree_GetAreaRatio Source: https://box2d.org/documentation/collision_8h_source.html Gets the area ratio of the dynamic tree. ```APIDOC ## b2DynamicTree_GetAreaRatio ### Description Gets the area ratio of the dynamic tree. ### Parameters #### Path Parameters - **tree** (const b2DynamicTree*) - Pointer to the dynamic tree. ### Function Signature `float b2DynamicTree_GetAreaRatio( const b2DynamicTree* tree );` ``` -------------------------------- ### b2DefaultQueryFilter Source: https://box2d.org/documentation/group__shape.html Use this to initialize your query filter. ```APIDOC ## b2DefaultQueryFilter ### Description Use this to initialize your query filter. ### Signature b2QueryFilter | **b2DefaultQueryFilter** (void) ``` -------------------------------- ### b2Chain_GetWorld Source: https://box2d.org/documentation/group__shape.html Get the world that owns this chain shape. ```APIDOC ## b2Chain_GetWorld ### Description Get the world that owns this chain shape. ### Signature B2_API b2WorldId | **b2Chain_GetWorld** (b2ChainId chainId) ``` -------------------------------- ### b2DynamicTree_CreateProxy Source: https://box2d.org/documentation/collision_8h_source.html Creates a proxy in the dynamic tree with the given AABB and user data. ```APIDOC ## b2DynamicTree_CreateProxy ### Description Creates a proxy in the dynamic tree. You must provide an AABB and a userData value. ### Method int ### Endpoint b2DynamicTree_CreateProxy(b2DynamicTree *tree, b2AABB aabb, uint64_t categoryBits, uint64_t userData) ### Parameters #### Path Parameters - **tree** (b2DynamicTree *) - Required - Pointer to the dynamic tree. - **aabb** (b2AABB) - Required - The axis-aligned bounding box for the proxy. - **categoryBits** (uint64_t) - Required - The category bits for the proxy. - **userData** (uint64_t) - Required - User-defined data associated with the proxy. ### Returns int: The ID of the newly created proxy. ``` -------------------------------- ### b2Shape_GetSensorOverlaps Source: https://box2d.org/documentation/group__shape.html Get the overlapped shapes for a sensor shape. ```APIDOC ## b2Shape_GetSensorOverlaps ### Description Get the overlapped shapes for a sensor shape. ### Signature B2_API int | b2Shape_GetSensorOverlaps (b2ShapeId shapeId, b2ShapeId *overlaps, int capacity) ``` -------------------------------- ### Ray Cast Against Proxies Source: https://box2d.org/documentation/group__tree.html Performs a ray cast against the proxies in the dynamic tree. It relies on a callback for exact ray casting and collision filtering. Performance is roughly k * log(n). ```c b2TreeStats b2DynamicTree_RayCast( const b2DynamicTree *_tree_, const b2RayCastInput *_input_, uint64_t _maskBits_, b2TreeRayCastCallbackFcn *_callback_, void *_context_ ); ``` -------------------------------- ### b2Shape_GetContactData Source: https://box2d.org/documentation/group__shape.html Get the touching contact data for a shape. ```APIDOC ## b2Shape_GetContactData ### Description Get the touching contact data for a shape. ### Signature B2_API int | b2Shape_GetContactData (b2ShapeId shapeId, b2ContactData *contactData, int capacity) ``` -------------------------------- ### Box2D C++ World ID Initialization Source: https://box2d.org/documentation/group__id.html Demonstrates how to initialize a b2WorldId in C++. All IDs are considered null if initialized to zero. ```cpp b2WorldId worldId = {}; ``` -------------------------------- ### b2Body_GetJointCount Source: https://box2d.org/documentation/group__body.html Gets the number of joints connected to this body. ```APIDOC ## b2Body_GetJointCount ### Description Gets the number of joints connected to this body. ### Method int ### Parameters - **bodyId** (b2BodyId) - The ID of the body. ``` -------------------------------- ### Create Chain Loop (Version 3.0) Source: https://box2d.org/documentation/md_migration.html Illustrates creating a chain loop with the simplified API in Box2D Version 3.0. Uses a b2ChainDef structure and a dedicated creation function. ```cpp b2Vec2 points[5] = { {-8.0f, 6.0f}, {-8.0f, 20.0f}, {8.0f, 20.0f}, {8.0f, 6.0f}, {0.0f, -2.0f} }; b2ChainDef chainDef = b2DefaultChainDef(); chainDef.points = points; chainDef.count = 5; chainDef.loop = true; b2ChainId chainId = b2CreateChain(bodyId, &chainDef); ``` -------------------------------- ### b2WeldJoint_GetAngularDampingRatio Source: https://box2d.org/documentation/box2d_8h_source.html Gets the angular damping ratio for a weld joint. ```APIDOC ## b2WeldJoint_GetAngularDampingRatio ### Description Gets the angular damping ratio for a weld joint. ### Function Signature `B2_API float b2WeldJoint_GetAngularDampingRatio(b2JointId jointId)` ### Parameters - **jointId** (`b2JointId`): The ID of the weld joint. ### Returns The non-dimensional angular damping ratio of the weld joint. ``` -------------------------------- ### Get Box2D Simulation Profile and Counters Source: https://box2d.org/documentation/box2d_8h_source.html Access performance profiling data and simulation counters for the physics world. ```c B2_API b2Profile b2World_GetProfile( b2WorldId worldId ); B2_API b2Counters b2World_GetCounters( b2WorldId worldId ); ``` -------------------------------- ### b2Body_GetWorldCenterOfMass Source: https://box2d.org/documentation/box2d_8h_source.html Gets the center of mass of the body in world coordinates. ```APIDOC ## b2Body_GetWorldCenterOfMass ### Description Gets the center of mass of the physics body in world coordinates. ### Method `b2Body_GetWorldCenterOfMass` ### Parameters - **bodyId** (b2BodyId) - The identifier of the body. ### Returns - **b2Vec2** - The world center of mass. ``` -------------------------------- ### b2Body_GetLinearVelocity Source: https://box2d.org/documentation/box2d_8h_source.html Gets the world-space linear velocity of a given body. ```APIDOC ## b2Body_GetLinearVelocity ### Description Gets the world-space linear velocity of a physics body. ### Method `b2Body_GetLinearVelocity` ### Parameters - **bodyId** (b2BodyId) - The identifier of the body. ### Returns - **b2Vec2** - The world-space linear velocity of the body. ``` -------------------------------- ### Tick and Millisecond Utilities Source: https://box2d.org/documentation/base_8h_source.html Provides functions for getting high-resolution timer ticks and converting them to milliseconds. Includes a function to reset the tick counter. ```c B2_API uint64_t b2GetTicks( void ); B2_API float b2GetMilliseconds( uint64_t ticks ); B2_API float b2GetMillisecondsAndReset( uint64_t* ticks ); ``` -------------------------------- ### Enable a Body Source: https://box2d.org/documentation/md_simulation.html Re-enable a body that was previously disabled, making it active in the simulation again. ```c b2Body_Enable(myBodyId); ``` -------------------------------- ### b2DynamicTree_GetByteCount Source: https://box2d.org/documentation/collision_8h_source.html Gets the total byte count of the dynamic tree. ```APIDOC ## b2DynamicTree_GetByteCount ### Description Gets the total byte count of the dynamic tree. ### Parameters #### Path Parameters - **tree** (const b2DynamicTree*) - Pointer to the dynamic tree. ### Function Signature `int b2DynamicTree_GetByteCount( const b2DynamicTree* tree );` ``` -------------------------------- ### b2DynamicTree_CreateProxy Source: https://box2d.org/documentation/collision_8h_source.html Creates a proxy in the dynamic tree for a given AABB, category bits, and user data. ```APIDOC ## b2DynamicTree_CreateProxy ### Description Creates a proxy in the dynamic tree for a given AABB, category bits, and user data. ### Parameters #### Path Parameters - **tree** (b2DynamicTree*) - Pointer to the dynamic tree. - **aabb** (b2AABB) - The axis-aligned bounding box for the proxy. - **categoryBits** (uint64_t) - The category bits for the proxy. - **userData** (uint64_t) - User-defined data associated with the proxy. ### Function Signature `int b2DynamicTree_CreateProxy( b2DynamicTree* tree, b2AABB aabb, uint64_t categoryBits, uint64_t userData );` ``` -------------------------------- ### b2DynamicTree_GetRootBounds Source: https://box2d.org/documentation/collision_8h_source.html Gets the AABB of the root node of the dynamic tree. ```APIDOC ## b2DynamicTree_GetRootBounds ### Description Gets the AABB of the root node of the dynamic tree. ### Parameters #### Path Parameters - **tree** (const b2DynamicTree*) - Pointer to the dynamic tree. ### Function Signature `b2AABB b2DynamicTree_GetRootBounds( const b2DynamicTree* tree );` ``` -------------------------------- ### Create Box2D World (v2.4) Source: https://box2d.org/documentation/md_migration.html This snippet shows how to create a Box2D world in version 2.4 using C++. ```cpp #include "box2d/box2d.h" b2Vec2 gravity(0.0f, -10.0f); b2World world(gravity); ``` -------------------------------- ### b2DynamicTree_GetCategoryBits Source: https://box2d.org/documentation/collision_8h_source.html Gets the category bits for a proxy in the dynamic tree. ```APIDOC ## b2DynamicTree_GetCategoryBits ### Description Gets the category bits for a proxy in the dynamic tree. ### Parameters #### Path Parameters - **tree** (b2DynamicTree*) - Pointer to the dynamic tree. - **proxyId** (int) - The ID of the proxy. ### Function Signature `uint64_t b2DynamicTree_GetCategoryBits( b2DynamicTree* tree, int proxyId );` ``` -------------------------------- ### Define Ground Body Position Source: https://box2d.org/documentation/hello.html Initialize a body definition and set the initial world position for the ground body. ```c++ b2BodyDef groundBodyDef = b2DefaultBodyDef(); groundBodyDef.position = (b2Vec2){0.0f, -10.0f}; ``` -------------------------------- ### b2Shape_GetClosestPoint Source: https://box2d.org/documentation/group__shape.html Get the closest point on a shape to a target point. ```APIDOC ## b2Shape_GetClosestPoint ### Description Get the closest point on a shape to a target point. ### Signature B2_API b2Vec2 | b2Shape_GetClosestPoint (b2ShapeId shapeId, b2Vec2 target) ``` -------------------------------- ### Get Shape Filter Source: https://box2d.org/documentation/group__shape.html Retrieves the filter settings for a shape. ```APIDOC ## b2Shape_GetFilter ### Description Get the shape filter. ### Method [Not applicable - C API] ### Parameters - **shapeId** (b2ShapeId) - The identifier of the shape. ### Return Value b2Filter - The filter settings of the shape. ``` -------------------------------- ### Create a Revolute Joint with Limits and Motor Source: https://box2d.org/documentation/md_simulation.html Configures a revolute joint with angle limits and a motor, demonstrating how to set lower and upper angle bounds, enable limits, and configure a motor for friction simulation. ```c++ b2Vec2 worldPivot = {10.0f, -4.0f}; b2RevoluteJointDef jointDef = b2DefaultRevoluteJointDef(); jointDef.bodyIdA = myBodyIdA; jointDef.bodyIdB = myBodyIdB; jointDef.localAnchorA = b2Body_GetLocalPoint(myBodyIdA, worldPivot); jointDef.localAnchorB = b2Body_GetLocalPoint(myBodyIdB, worldPivot); jointDef.lowerAngle = -0.5f * b2_pi; // -90 degrees jointDef.upperAngle = 0.25f * b2_pi; // 45 degrees jointDef.enableLimit = true; jointDef.maxMotorTorque = 10.0f; jointDef.motorSpeed = 0.0f; jointDef.enableMotor = true; b2DistanceJointDef::enableLimit bool enableLimit Enable/disable the joint limit. **Definition** types.h:566 b2DistanceJointDef::enableMotor bool enableMotor Enable/disable the joint motor. **Definition** types.h:575 b2DistanceJointDef::motorSpeed float motorSpeed The desired motor speed, usually in meters per second. **Definition** types.h:581 ``` -------------------------------- ### Get Shape Material Source: https://box2d.org/documentation/group__shape.html Retrieves the material identifier of a shape. ```APIDOC ## b2Shape_GetMaterial ### Description Get the shape material identifier. ### Method [Not applicable - C API] ### Parameters - **shapeId** (b2ShapeId) - The identifier of the shape. ### Return Value int - The material identifier of the shape. ``` -------------------------------- ### Create a Rotation Source: https://box2d.org/documentation/md_collision.html Use b2MakeRot to create a 2D rotation from an angle in radians. ```cpp b2Rot b2MakeRot(float radians); ``` -------------------------------- ### Create Ground Body in World Source: https://box2d.org/documentation/hello.html Create the ground body in the simulation world using the defined body definition and the world ID. Bodies are static by default. ```c++ b2BodyId groundId = b2CreateBody(worldId, &groundBodyDef); ``` -------------------------------- ### Get Shape Restitution Source: https://box2d.org/documentation/group__shape.html Retrieves the restitution (bounciness) of a shape. ```APIDOC ## b2Shape_GetRestitution ### Description Get the shape restitution. ### Method [Not applicable - C API] ### Parameters - **shapeId** (b2ShapeId) - The identifier of the shape. ### Return Value float - The restitution value of the shape. ``` -------------------------------- ### Get Shape Friction Source: https://box2d.org/documentation/group__shape.html Retrieves the friction coefficient of a shape. ```APIDOC ## b2Shape_GetFriction ### Description Get the friction of a shape. ### Method [Not applicable - C API] ### Parameters - **shapeId** (b2ShapeId) - The identifier of the shape. ### Return Value float - The friction coefficient of the shape. ``` -------------------------------- ### b2CreateWorld Source: https://box2d.org/documentation/group__world.html Creates a new Box2D world for rigid body simulation. It takes a world definition as input. ```APIDOC ## b2CreateWorld ### Description Creates a world for rigid body simulation. ### Method B2_API b2WorldId ### Parameters - **def** (const b2WorldDef *) - Description of the world definition. ### Response - **b2WorldId** - Identifier for the newly created world. ``` -------------------------------- ### Get Shape Type Source: https://box2d.org/documentation/group__shape.html Retrieves the type of a given shape. ```APIDOC ## b2Shape_GetType ### Description Get the type of a shape. ### Method [Not applicable - C API] ### Parameters - **shapeId** (b2ShapeId) - The identifier of the shape. ### Return Value b2ShapeType - The type of the shape. ``` -------------------------------- ### b2DynamicTree_Create Source: https://box2d.org/documentation/collision_8h_source.html Creates a new dynamic tree for spatial partitioning. ```APIDOC ## b2DynamicTree_Create ### Description Creates a new dynamic tree for spatial partitioning. ### Function Signature `b2DynamicTree b2DynamicTree_Create( void );` ``` -------------------------------- ### b2Body_GetShapeCount Source: https://box2d.org/documentation/group__body.html Gets the number of shapes currently attached to this body. ```APIDOC ## b2Body_GetShapeCount ### Description Gets the number of shapes currently attached to this body. ### Method int ### Parameters - **bodyId** (b2BodyId) - The ID of the body. ``` -------------------------------- ### User Data and Callbacks Source: https://box2d.org/documentation/box2d_8h_source.html Functions for setting and retrieving user-defined data and custom callbacks. ```APIDOC ## b2World_SetUserData ### Description Attaches arbitrary user data to the world. ### Method `b2World_SetUserData` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **userData** (*void*): A pointer to the user-defined data. ``` ```APIDOC ## b2World_GetUserData ### Description Retrieves the user-defined data attached to the world. ### Method `b2World_GetUserData` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. ### Returns - **void*:** A pointer to the user-defined data. ``` ```APIDOC ## b2World_SetCustomFilterCallback ### Description Sets a custom callback function that can filter contacts before they are solved. ### Method `b2World_SetCustomFilterCallback` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **fcn** (*b2CustomFilterFcn*): Pointer to the custom filter callback function. - **context** (*void*): User-defined context pointer passed to the callback. ``` ```APIDOC ## b2World_SetPreSolveCallback ### Description Sets a callback function that is invoked before contact solving begins. ### Method `b2World_SetPreSolveCallback` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **fcn** (*b2PreSolveFcn*): Pointer to the pre-solve callback function. - **context** (*void*): User-defined context pointer passed to the callback. ``` ```APIDOC ## b2World_SetFrictionCallback ### Description Sets a callback function to customize friction calculations. ### Method `b2World_SetFrictionCallback` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **callback** (*b2FrictionCallback*): Pointer to the friction callback structure. ``` ```APIDOC ## b2World_SetRestitutionCallback ### Description Sets a callback function to customize restitution calculations. ### Method `b2World_SetRestitutionCallback` ### Parameters - **worldId** (*b2WorldId*): The identifier of the world. - **callback** (*b2RestitutionCallback*): Pointer to the restitution callback structure. ``` -------------------------------- ### b2WheelJoint_GetLowerLimit Source: https://box2d.org/documentation/box2d_8h_source.html Gets the lower limit of the wheel joint's movement. ```APIDOC ## b2WheelJoint_GetLowerLimit ### Description Gets the lower limit of the wheel joint's movement. ### Method GET ### Endpoint N/A (SDK Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **return value** (float) - The lower limit. ``` -------------------------------- ### Initialize a Circle Inline Source: https://box2d.org/documentation/md_collision.html An alternative way to initialize a circle primitive using an inline initializer list. ```c++ b2Circle circle = {{2.0f, 3.0f}, 0.5f}; ```