Module ffi

Module ffi 

Source

Structs§

b2AABB
Axis-aligned bounding box
b2BodyDef
A body definition holds all the data needed to construct a rigid body. You can safely re-use body definitions. Shapes are added to a body after construction. Body definitions are temporary objects used to bundle creation parameters. Must be initialized using b2DefaultBodyDef(). @ingroup body
b2BodyEvents
Body events are buffered in the Box2D world and are available as event arrays after the time step is complete. Note: this data becomes invalid if bodies are destroyed
b2BodyId
Body id references a body instance. This should be treated as an opaque handle.
b2BodyMoveEvent
Body move events triggered when a body moves. Triggered when a body moves due to simulation. Not reported for bodies moved by the user. This also has a flag to indicate that the body went to sleep so the application can also sleep that actor/entity/object associated with the body. On the other hand if the flag does not indicate the body went to sleep then the application can treat the actor/entity/object associated with the body as awake. This is an efficient way for an application to update game object transforms rather than calling functions such as b2Body_GetTransform() because this data is delivered as a contiguous array and it is only populated with bodies that have moved. @note If sleeping is disabled all dynamic and kinematic bodies will trigger move events.
b2Capsule
A solid capsule can be viewed as two semicircles connected by a rectangle.
b2CastOutput
Low level ray cast or shape-cast output data. Returns a zero fraction and normal in the case of initial overlap.
b2ChainDef
Used to create a chain of line segments. This is designed to eliminate ghost collisions with some limitations.
b2ChainId
Chain id references a chain instances. This should be treated as an opaque handle.
b2ChainSegment
A line segment with one-sided collision. Only collides on the right side. Several of these are generated for a chain shape. ghost1 -> point1 -> point2 -> ghost2
b2Circle
A solid circle
b2CollisionPlane
These are collision planes that can be fed to b2SolvePlanes. Normally this is assembled by the user from plane results in b2PlaneResult
b2ContactBeginTouchEvent
A begin touch event is generated when two shapes begin touching.
b2ContactData
The contact data for two shapes. By convention the manifold normal points from shape A to shape B. @see b2Shape_GetContactData() and b2Body_GetContactData()
b2ContactEndTouchEvent
An end touch event is generated when two shapes stop touching. You will get an end event if you do anything that destroys contacts previous to the last world step. These include things like setting the transform, destroying a body or shape, or changing a filter or body type.
b2ContactEvents
Contact events are buffered in the Box2D world and are available as event arrays after the time step is complete. Note: these may become invalid if bodies and/or shapes are destroyed
b2ContactHitEvent
A hit touch event is generated when two shapes collide with a speed faster than the hit speed threshold. This may be reported for speculative contacts that have a confirmed impulse.
b2ContactId
Contact id references a contact instance. This should be treated as an opaque handled.
b2CosSin
Cosine and sine pair This uses a custom implementation designed for cross-platform determinism
b2Counters
Counters that give details of the simulation size.
b2DebugDraw
This struct holds callbacks you can implement to draw a Box2D world. This structure should be zero initialized. @ingroup world
b2DistanceInput
Input for b2ShapeDistance
b2DistanceJointDef
Distance joint definition Connects a point on body A with a point on body B by a segment. Useful for ropes and springs. @ingroup distance_joint
b2DistanceOutput
Output for b2ShapeDistance
b2DynamicTree
The dynamic tree structure. This should be considered private data. It is placed here for performance reasons.
b2ExplosionDef
The explosion definition is used to configure options for explosions. Explosions consider shape geometry when computing the impulse. @ingroup world
b2Filter
This is used to filter collision on shapes. It affects shape-vs-shape collision and shape-versus-query collision (such as b2World_CastRay). @ingroup shape
b2FilterJointDef
A filter joint is used to disable collision between two specific bodies.
b2Hull
A convex hull. Used to create convex polygons. @warning Do not modify these values directly, instead use b2ComputeHull()
b2JointDef
Base joint definition used by all joint types. The local frames are measured from the body’s origin rather than the center of mass because:
b2JointEvent
Joint events report joints that are awake and have a force and/or torque exceeding the threshold The observed forces and torques are not returned for efficiency reasons.
b2JointEvents
Joint events are buffered in the world and are available as event arrays after the time step is complete. Note: this data becomes invalid if joints are destroyed
b2JointId
Joint id references a joint instance. This should be treated as an opaque handle.
b2Manifold
A contact manifold describes the contact points between colliding shapes. @note Box2D uses speculative collision so some contact points may be separated.
b2ManifoldPoint
A manifold point is a contact point belonging to a contact manifold. It holds details related to the geometry and dynamics of the contact points. Box2D uses speculative collision so some contact points may be separated. You may use the totalNormalImpulse to determine if there was an interaction during the time step.
b2MassData
This holds the mass data computed for a shape.
b2Mat22
A 2-by-2 Matrix
b2MotionLocks
Motion locks to restrict the body movement
b2MotorJointDef
A motor joint is used to control the relative velocity and or transform between two bodies. With a velocity of zero this acts like top-down friction. @ingroup motor_joint
b2Plane
separation = dot(normal, point) - offset
b2PlaneResult
These are the collision planes returned from b2World_CollideMover
b2PlaneSolverResult
Result returned by b2SolvePlanes
b2Polygon
A solid convex polygon. It is assumed that the interior of the polygon is to the left of each edge. Polygons have a maximum number of vertices equal to B2_MAX_POLYGON_VERTICES. In most cases you should not need many vertices for a convex polygon. @warning DO NOT fill this out manually, instead use a helper function like b2MakePolygon or b2MakeBox.
b2PrismaticJointDef
Prismatic joint definition Body B may slide along the x-axis in local frame A. Body B cannot rotate relative to body A. The joint translation is zero when the local frame origins coincide in world space. @ingroup prismatic_joint
b2Profile
! @cond Profiling data. Times are in milliseconds.
b2QueryFilter
The query filter is used to filter collisions between queries and shapes. For example, you may want a ray-cast representing a projectile to hit players and the static environment but not debris. @ingroup shape
b2RayCastInput
Low level ray cast input data
b2RayResult
Result from b2World_RayCastClosest If there is initial overlap the fraction and normal will be zero while the point is an arbitrary point in the overlap region. @ingroup world
b2RevoluteJointDef
Revolute joint definition A point on body B is fixed to a point on body A. Allows relative rotation. @ingroup revolute_joint
b2Rot
2D rotation This is similar to using a complex number for rotation
b2Segment
A line segment with two-sided collision.
b2SegmentDistanceResult
Result of computing the distance between two line segments
b2SensorBeginTouchEvent
A begin touch event is generated when a shape starts to overlap a sensor shape.
b2SensorEndTouchEvent
An end touch event is generated when a shape stops overlapping a sensor shape. These include things like setting the transform, destroying a body or shape, or changing a filter. You will also get an end event if the sensor or visitor are destroyed. Therefore you should always confirm the shape id is valid using b2Shape_IsValid.
b2SensorEvents
Sensor events are buffered in the world and are available as begin/end overlap event arrays after the time step is complete. Note: these may become invalid if bodies and/or shapes are destroyed
b2ShapeCastInput
Low level shape cast input in generic form. This allows casting an arbitrary point cloud wrap with a radius. For example, a circle is a single point with a non-zero radius. A capsule is two points with a non-zero radius. A box is four points with a zero radius.
b2ShapeCastPairInput
Input parameters for b2ShapeCast
b2ShapeDef
Used to create a shape. This is a temporary object used to bundle shape creation parameters. You may use the same shape definition to create multiple shapes. Must be initialized using b2DefaultShapeDef(). @ingroup shape
b2ShapeId
Shape id references a shape instance. This should be treated as an opaque handle.
b2ShapeProxy
A distance proxy is used by the GJK algorithm. It encapsulates any shape. You can provide between 1 and B2_MAX_POLYGON_VERTICES and a radius.
b2Simplex
Simplex from the GJK algorithm
b2SimplexCache
Used to warm start the GJK simplex. If you call this function multiple times with nearby transforms this might improve performance. Otherwise you can zero initialize this. The distance cache must be initialized to zero on the first call. Users should generally just zero initialize this structure for each call.
b2SimplexVertex
Simplex vertex for debugging the GJK algorithm
b2SurfaceMaterial
Surface materials allow chain shapes to have per segment surface properties. @ingroup shape
b2Sweep
This describes the motion of a body/shape for TOI computation. Shapes are defined with respect to the body origin, which may not coincide with the center of mass. However, to support dynamics we must interpolate the center of mass position.
b2TOIInput
Time of impact input
b2TOIOutput
Time of impact output
b2Transform
A 2D rigid transform
b2TreeNode
The tree nodes
b2TreeStats
These are performance results returned by dynamic tree queries.
b2Vec2
2D vector This can be used to represent a point or free vector
b2Version
Version numbering scheme. See https://semver.org/
b2WeldJointDef
Weld joint definition Connects two bodies together rigidly. This constraint provides springs to mimic soft-body simulation. @note The approximate solver in Box2D cannot hold many bodies together rigidly @ingroup weld_joint
b2WheelJointDef
Wheel joint definition Body B is a wheel that may rotate freely and slide along the local x-axis in frame A. The joint translation is zero when the local frame origins coincide in world space. @ingroup wheel_joint
b2WorldDef
World definition used to create a simulation world. Must be initialized using b2DefaultWorldDef(). @ingroup world
b2WorldId
World id references a world instance. This should be treated as an opaque handle.

Constants§

B2_DEFAULT_CATEGORY_BITS
B2_DEFAULT_MASK_BITS
B2_HASH_INIT
B2_MAX_POLYGON_VERTICES
B2_PI
b2BodyType_b2_bodyTypeCount
number of body types
b2BodyType_b2_dynamicBody
positive mass, velocity determined by forces, moved by solver
b2BodyType_b2_kinematicBody
zero mass, velocity set by user, moved by solver
b2BodyType_b2_staticBody
zero mass, zero velocity, may be manually moved
b2HexColor_b2_colorAliceBlue
b2HexColor_b2_colorAntiqueWhite
b2HexColor_b2_colorAqua
b2HexColor_b2_colorAquamarine
b2HexColor_b2_colorAzure
b2HexColor_b2_colorBeige
b2HexColor_b2_colorBisque
b2HexColor_b2_colorBlack
b2HexColor_b2_colorBlanchedAlmond
b2HexColor_b2_colorBlue
b2HexColor_b2_colorBlueViolet
b2HexColor_b2_colorBox2DBlue
b2HexColor_b2_colorBox2DGreen
b2HexColor_b2_colorBox2DRed
b2HexColor_b2_colorBox2DYellow
b2HexColor_b2_colorBrown
b2HexColor_b2_colorBurlywood
b2HexColor_b2_colorCadetBlue
b2HexColor_b2_colorChartreuse
b2HexColor_b2_colorChocolate
b2HexColor_b2_colorCoral
b2HexColor_b2_colorCornflowerBlue
b2HexColor_b2_colorCornsilk
b2HexColor_b2_colorCrimson
b2HexColor_b2_colorCyan
b2HexColor_b2_colorDarkBlue
b2HexColor_b2_colorDarkCyan
b2HexColor_b2_colorDarkGoldenRod
b2HexColor_b2_colorDarkGray
b2HexColor_b2_colorDarkGreen
b2HexColor_b2_colorDarkKhaki
b2HexColor_b2_colorDarkMagenta
b2HexColor_b2_colorDarkOliveGreen
b2HexColor_b2_colorDarkOrange
b2HexColor_b2_colorDarkOrchid
b2HexColor_b2_colorDarkRed
b2HexColor_b2_colorDarkSalmon
b2HexColor_b2_colorDarkSeaGreen
b2HexColor_b2_colorDarkSlateBlue
b2HexColor_b2_colorDarkSlateGray
b2HexColor_b2_colorDarkTurquoise
b2HexColor_b2_colorDarkViolet
b2HexColor_b2_colorDeepPink
b2HexColor_b2_colorDeepSkyBlue
b2HexColor_b2_colorDimGray
b2HexColor_b2_colorDodgerBlue
b2HexColor_b2_colorFireBrick
b2HexColor_b2_colorFloralWhite
b2HexColor_b2_colorForestGreen
b2HexColor_b2_colorFuchsia
b2HexColor_b2_colorGainsboro
b2HexColor_b2_colorGhostWhite
b2HexColor_b2_colorGold
b2HexColor_b2_colorGoldenRod
b2HexColor_b2_colorGray
b2HexColor_b2_colorGreen
b2HexColor_b2_colorGreenYellow
b2HexColor_b2_colorHoneyDew
b2HexColor_b2_colorHotPink
b2HexColor_b2_colorIndianRed
b2HexColor_b2_colorIndigo
b2HexColor_b2_colorIvory
b2HexColor_b2_colorKhaki
b2HexColor_b2_colorLavender
b2HexColor_b2_colorLavenderBlush
b2HexColor_b2_colorLawnGreen
b2HexColor_b2_colorLemonChiffon
b2HexColor_b2_colorLightBlue
b2HexColor_b2_colorLightCoral
b2HexColor_b2_colorLightCyan
b2HexColor_b2_colorLightGoldenRodYellow
b2HexColor_b2_colorLightGray
b2HexColor_b2_colorLightGreen
b2HexColor_b2_colorLightPink
b2HexColor_b2_colorLightSalmon
b2HexColor_b2_colorLightSeaGreen
b2HexColor_b2_colorLightSkyBlue
b2HexColor_b2_colorLightSlateGray
b2HexColor_b2_colorLightSteelBlue
b2HexColor_b2_colorLightYellow
b2HexColor_b2_colorLime
b2HexColor_b2_colorLimeGreen
b2HexColor_b2_colorLinen
b2HexColor_b2_colorMagenta
b2HexColor_b2_colorMaroon
b2HexColor_b2_colorMediumAquaMarine
b2HexColor_b2_colorMediumBlue
b2HexColor_b2_colorMediumOrchid
b2HexColor_b2_colorMediumPurple
b2HexColor_b2_colorMediumSeaGreen
b2HexColor_b2_colorMediumSlateBlue
b2HexColor_b2_colorMediumSpringGreen
b2HexColor_b2_colorMediumTurquoise
b2HexColor_b2_colorMediumVioletRed
b2HexColor_b2_colorMidnightBlue
b2HexColor_b2_colorMintCream
b2HexColor_b2_colorMistyRose
b2HexColor_b2_colorMoccasin
b2HexColor_b2_colorNavajoWhite
b2HexColor_b2_colorNavy
b2HexColor_b2_colorOldLace
b2HexColor_b2_colorOlive
b2HexColor_b2_colorOliveDrab
b2HexColor_b2_colorOrange
b2HexColor_b2_colorOrangeRed
b2HexColor_b2_colorOrchid
b2HexColor_b2_colorPaleGoldenRod
b2HexColor_b2_colorPaleGreen
b2HexColor_b2_colorPaleTurquoise
b2HexColor_b2_colorPaleVioletRed
b2HexColor_b2_colorPapayaWhip
b2HexColor_b2_colorPeachPuff
b2HexColor_b2_colorPeru
b2HexColor_b2_colorPink
b2HexColor_b2_colorPlum
b2HexColor_b2_colorPowderBlue
b2HexColor_b2_colorPurple
b2HexColor_b2_colorRebeccaPurple
b2HexColor_b2_colorRed
b2HexColor_b2_colorRosyBrown
b2HexColor_b2_colorRoyalBlue
b2HexColor_b2_colorSaddleBrown
b2HexColor_b2_colorSalmon
b2HexColor_b2_colorSandyBrown
b2HexColor_b2_colorSeaGreen
b2HexColor_b2_colorSeaShell
b2HexColor_b2_colorSienna
b2HexColor_b2_colorSilver
b2HexColor_b2_colorSkyBlue
b2HexColor_b2_colorSlateBlue
b2HexColor_b2_colorSlateGray
b2HexColor_b2_colorSnow
b2HexColor_b2_colorSpringGreen
b2HexColor_b2_colorSteelBlue
b2HexColor_b2_colorTan
b2HexColor_b2_colorTeal
b2HexColor_b2_colorThistle
b2HexColor_b2_colorTomato
b2HexColor_b2_colorTurquoise
b2HexColor_b2_colorViolet
b2HexColor_b2_colorWheat
b2HexColor_b2_colorWhite
b2HexColor_b2_colorWhiteSmoke
b2HexColor_b2_colorYellow
b2HexColor_b2_colorYellowGreen
b2JointType_b2_distanceJoint
b2JointType_b2_filterJoint
b2JointType_b2_motorJoint
b2JointType_b2_prismaticJoint
b2JointType_b2_revoluteJoint
b2JointType_b2_weldJoint
b2JointType_b2_wheelJoint
b2ShapeType_b2_capsuleShape
A capsule is an extruded circle
b2ShapeType_b2_chainSegmentShape
A line segment owned by a chain shape
b2ShapeType_b2_circleShape
A circle with an offset
b2ShapeType_b2_polygonShape
A convex polygon
b2ShapeType_b2_segmentShape
A line segment
b2ShapeType_b2_shapeTypeCount
The number of shape types
b2TOIState_b2_toiStateFailed
b2TOIState_b2_toiStateHit
b2TOIState_b2_toiStateOverlapped
b2TOIState_b2_toiStateSeparated
b2TOIState_b2_toiStateUnknown

Functions§

b2Atan2
Compute an approximate arctangent in the range [-pi, pi] This is hand coded for cross-platform determinism. The atan2f function in the standard library is not cross-platform deterministic. Accurate to around 0.0023 degrees
b2Body_ApplyAngularImpulse
Apply an angular impulse. The impulse is ignored if the body is not awake. This optionally wakes the body. @param bodyId The body id @param impulse the angular impulse, usually in units of kgmm/s @param wake also wake up the body @warning This should be used for one-shot impulses. If you need a steady torque, use a torque instead, which will work better with the sub-stepping solver.
b2Body_ApplyForce
Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This optionally wakes up the body. The force is ignored if the body is not awake. @param bodyId The body id @param force The world force vector, usually in newtons (N) @param point The world position of the point of application @param wake Option to wake up the body
b2Body_ApplyForceToCenter
Apply a force to the center of mass. This optionally wakes up the body. The force is ignored if the body is not awake. @param bodyId The body id @param force the world force vector, usually in newtons (N). @param wake also wake up the body
b2Body_ApplyLinearImpulse
Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. This optionally wakes the body. The impulse is ignored if the body is not awake. @param bodyId The body id @param impulse the world impulse vector, usually in Ns or kgm/s. @param point the world position of the point of application. @param wake also wake up the body @warning This should be used for one-shot impulses. If you need a steady force, use a force instead, which will work better with the sub-stepping solver.
b2Body_ApplyLinearImpulseToCenter
Apply an impulse to the center of mass. This immediately modifies the velocity. The impulse is ignored if the body is not awake. This optionally wakes the body. @param bodyId The body id @param impulse the world impulse vector, usually in Ns or kgm/s. @param wake also wake up the body @warning This should be used for one-shot impulses. If you need a steady force, use a force instead, which will work better with the sub-stepping solver.
b2Body_ApplyMassFromShapes
This updates the mass properties to the sum of the mass properties of the shapes. This normally does not need to be called unless you called SetMassData to override the mass and you later want to reset the mass. You may also use this when automatic mass computation has been disabled. You should call this regardless of body type. Note that sensor shapes may have mass.
b2Body_ApplyTorque
Apply a torque. This affects the angular velocity without affecting the linear velocity. This optionally wakes the body. The torque is ignored if the body is not awake. @param bodyId The body id @param torque about the z-axis (out of the screen), usually in N*m. @param wake also wake up the body
b2Body_ClearForces
Clear the force and torque on this body. Forces and torques are automatically cleared after each world step. So this only needs to be called if the application wants to remove the effect of previous calls to apply forces and torques before the world step is called. @param bodyId The body id
b2Body_ComputeAABB
Get the current world AABB that contains all the attached shapes. Note that this may not encompass the body origin. If there are no shapes attached then the returned AABB is empty and centered on the body origin.
b2Body_Disable
Disable a body by removing it completely from the simulation. This is expensive.
b2Body_Enable
Enable a body by adding it to the simulation. This is expensive.
b2Body_EnableContactEvents
Enable/disable contact events on all shapes. @see b2ShapeDef::enableContactEvents @warning changing this at runtime may cause mismatched begin/end touch events
b2Body_EnableHitEvents
Enable/disable hit events on all shapes @see b2ShapeDef::enableHitEvents
b2Body_EnableSleep
Enable or disable sleeping for this body. If sleeping is disabled the body will wake.
b2Body_GetAngularDamping
Get the current angular damping.
b2Body_GetAngularVelocity
Get the angular velocity of a body in radians per second
b2Body_GetContactCapacity
Get the maximum capacity required for retrieving all the touching contacts on a body
b2Body_GetContactData
Get the touching contact data for a body. @note Box2D uses speculative collision so some contact points may be separated. @returns the number of elements filled in the provided array @warning do not ignore the return value, it specifies the valid number of elements
b2Body_GetGravityScale
Get the current gravity scale
b2Body_GetJointCount
Get the number of joints on this body
b2Body_GetJoints
Get the joint ids for all joints on this body, up to the provided capacity @returns the number of joint ids stored in the user array
b2Body_GetLinearDamping
Get the current linear damping.
b2Body_GetLinearVelocity
Get the linear velocity of a body’s center of mass. Usually in meters per second.
b2Body_GetLocalCenterOfMass
Get the center of mass position of the body in local space
b2Body_GetLocalPoint
Get a local point on a body given a world point
b2Body_GetLocalPointVelocity
Get the linear velocity of a local point attached to a body. Usually in meters per second.
b2Body_GetLocalVector
Get a local vector on a body given a world vector
b2Body_GetMass
Get the mass of the body, usually in kilograms
b2Body_GetMassData
Get the mass data for a body
b2Body_GetMotionLocks
Get the motion locks for this body.
b2Body_GetName
Get the body name.
b2Body_GetPosition
Get the world position of a body. This is the location of the body origin.
b2Body_GetRotation
Get the world rotation of a body as a cosine/sine pair (complex number)
b2Body_GetRotationalInertia
Get the rotational inertia of the body, usually in kg*m^2
b2Body_GetShapeCount
Get the number of shapes on this body
b2Body_GetShapes
Get the shape ids for all shapes on this body, up to the provided capacity. @returns the number of shape ids stored in the user array
b2Body_GetSleepThreshold
Get the sleep threshold, usually in meters per second.
b2Body_GetTransform
Get the world transform of a body.
b2Body_GetType
Get the body type: static, kinematic, or dynamic
b2Body_GetUserData
Get the user data stored in a body
b2Body_GetWorld
Get the world that owns this body
b2Body_GetWorldCenterOfMass
Get the center of mass position of the body in world space
b2Body_GetWorldPoint
Get a world point on a body given a local point
b2Body_GetWorldPointVelocity
Get the linear velocity of a world point attached to a body. Usually in meters per second.
b2Body_GetWorldVector
Get a world vector on a body given a local vector
b2Body_IsAwake
@return true if this body is awake
b2Body_IsBullet
Is this body a bullet?
b2Body_IsEnabled
Returns true if this body is enabled
b2Body_IsSleepEnabled
Returns true if sleeping is enabled for this body
b2Body_IsValid
Body identifier validation. A valid body exists in a world and is non-null. This can be used to detect orphaned ids. Provides validation for up to 64K allocations.
b2Body_SetAngularDamping
Adjust the angular damping. Normally this is set in b2BodyDef before creation.
b2Body_SetAngularVelocity
Set the angular velocity of a body in radians per second
b2Body_SetAwake
Wake a body from sleep. This wakes the entire island the body is touching. @warning Putting a body to sleep will put the entire island of bodies touching this body to sleep, which can be expensive and possibly unintuitive.
b2Body_SetBullet
Set this body to be a bullet. A bullet does continuous collision detection against dynamic bodies (but not other bullets).
b2Body_SetGravityScale
Adjust the gravity scale. Normally this is set in b2BodyDef before creation. @see b2BodyDef::gravityScale
b2Body_SetLinearDamping
Adjust the linear damping. Normally this is set in b2BodyDef before creation.
b2Body_SetLinearVelocity
Set the linear velocity of a body. Usually in meters per second.
b2Body_SetMassData
Override the body’s mass properties. Normally this is computed automatically using the shape geometry and density. This information is lost if a shape is added or removed or if the body type changes.
b2Body_SetMotionLocks
Set the motion locks on this body.
b2Body_SetName
Set the body name. Up to 31 characters excluding 0 termination.
b2Body_SetSleepThreshold
Set the sleep threshold, usually in meters per second
b2Body_SetTargetTransform
Set the velocity to reach the given transform after a given time step. The result will be close but maybe not exact. This is meant for kinematic bodies. The target is not applied if the velocity would be below the sleep threshold and the body is currently asleep. @param bodyId The body id @param target The target transform for the body @param timeStep The time step of the next call to b2World_Step @param wake Option to wake the body or not
b2Body_SetTransform
Set the world transform of a body. This acts as a teleport and is fairly expensive. @note Generally you should create a body with then intended transform. @see b2BodyDef::position and b2BodyDef::rotation
b2Body_SetType
Change the body type. This is an expensive operation. This automatically updates the mass properties regardless of the automatic mass setting.
b2Body_SetUserData
Set the user data for a body
b2Body_WakeTouching
Wake bodies touching this body. Works for static bodies.
b2Chain_GetSegmentCount
Get the number of segments on this chain
b2Chain_GetSegments
Fill a user array with chain segment shape ids up to the specified capacity. Returns the actual number of segments returned.
b2Chain_GetSurfaceMaterial
Get a chain material by index.
b2Chain_GetSurfaceMaterialCount
Get the number of materials used on this chain. Must be 1 or the number of segments.
b2Chain_GetWorld
Get the world that owns this chain shape
b2Chain_IsValid
Chain identifier validation. Provides validation for up to 64K allocations.
b2Chain_SetSurfaceMaterial
Set a chain material. If the chain has only one material, this material is applied to all segments. Otherwise it is applied to a single segment.
b2ClipVector
Clips the velocity against the given collision planes. Planes with zero push or clipVelocity set to false are skipped.
b2CollideCapsuleAndCircle
Compute the contact manifold between a capsule and circle
b2CollideCapsules
Compute the contact manifold between a capsule and circle
b2CollideChainSegmentAndCapsule
Compute the contact manifold between a chain segment and a capsule
b2CollideChainSegmentAndCircle
Compute the contact manifold between a chain segment and a circle
b2CollideChainSegmentAndPolygon
Compute the contact manifold between a chain segment and a rounded polygon
b2CollideCircles
Compute the contact manifold between two circles
b2CollidePolygonAndCapsule
Compute the contact manifold between a polygon and capsule
b2CollidePolygonAndCircle
Compute the contact manifold between a polygon and a circle
b2CollidePolygons
Compute the contact manifold between two polygons
b2CollideSegmentAndCapsule
Compute the contact manifold between an segment and a capsule
b2CollideSegmentAndCircle
Compute the contact manifold between an segment and a circle
b2CollideSegmentAndPolygon
Compute the contact manifold between an segment and a polygon
b2ComputeCapsuleAABB
Compute the bounding box of a transformed capsule
b2ComputeCapsuleMass
Compute mass properties of a capsule
b2ComputeCircleAABB
Compute the bounding box of a transformed circle
b2ComputeCircleMass
Compute mass properties of a circle
b2ComputeCosSin
Compute the cosine and sine of an angle in radians. Implemented for cross-platform determinism.
b2ComputeHull
Compute the convex hull of a set of points. Returns an empty hull if it fails. Some failure cases:
b2ComputePolygonAABB
Compute the bounding box of a transformed polygon
b2ComputePolygonMass
Compute mass properties of a polygon
b2ComputeRotationBetweenUnitVectors
Compute the rotation between two unit vectors
b2ComputeSegmentAABB
Compute the bounding box of a transformed line segment
b2Contact_GetData
Get the data for a contact. The manifold may have no points if the contact is not touching.
b2Contact_IsValid
Contact identifier validation. Provides validation for up to 2^32 allocations.
b2CreateBody
Create a rigid body given a definition. No reference to the definition is retained. So you can create the definition on the stack and pass it as a pointer. @code{.c} b2BodyDef bodyDef = b2DefaultBodyDef(); b2BodyId myBodyId = b2CreateBody(myWorldId, &bodyDef); @endcode @warning This function is locked during callbacks.
b2CreateCapsuleShape
Create a capsule shape and attach it to a body. The shape definition and geometry are fully cloned. Contacts are not created until the next time step. @return the shape id for accessing the shape, this will be b2_nullShapeId if the length is too small.
b2CreateChain
Create a chain shape @see b2ChainDef for details
b2CreateCircleShape
Create a circle shape and attach it to a body. The shape definition and geometry are fully cloned. Contacts are not created until the next time step. @return the shape id for accessing the shape
b2CreateDistanceJoint
Create a distance joint @see b2DistanceJointDef for details
b2CreateFilterJoint
Create a filter joint. @see b2FilterJointDef for details
b2CreateMotorJoint
Create a motor joint @see b2MotorJointDef for details
b2CreatePolygonShape
Create a polygon shape and attach it to a body. The shape definition and geometry are fully cloned. Contacts are not created until the next time step. @return the shape id for accessing the shape
b2CreatePrismaticJoint
Create a prismatic (slider) joint. @see b2PrismaticJointDef for details
b2CreateRevoluteJoint
Create a revolute joint @see b2RevoluteJointDef for details
b2CreateSegmentShape
Create a line segment shape and attach it to a body. The shape definition and geometry are fully cloned. Contacts are not created until the next time step. @return the shape id for accessing the shape
b2CreateWeldJoint
Create a weld joint @see b2WeldJointDef for details
b2CreateWheelJoint
Create a wheel joint @see b2WheelJointDef for details
b2CreateWorld
Create a world for rigid body simulation. A world contains bodies, shapes, and constraints. You make create up to 128 worlds. Each world is completely independent and may be simulated in parallel. @return the world id.
b2DefaultBodyDef
Use this to initialize your body definition @ingroup body
b2DefaultChainDef
Use this to initialize your chain definition @ingroup shape
b2DefaultDebugDraw
Use this to initialize your drawing interface. This allows you to implement a sub-set of the drawing functions.
b2DefaultDistanceJointDef
Use this to initialize your joint definition @ingroup distance_joint
b2DefaultExplosionDef
Use this to initialize your explosion definition @ingroup world
b2DefaultFilter
Use this to initialize your filter @ingroup shape
b2DefaultFilterJointDef
Use this to initialize your joint definition @ingroup filter_joint
b2DefaultMotorJointDef
Use this to initialize your joint definition @ingroup motor_joint
b2DefaultPrismaticJointDef
Use this to initialize your joint definition @ingroup prismatic_joint
b2DefaultQueryFilter
Use this to initialize your query filter @ingroup shape
b2DefaultRevoluteJointDef
Use this to initialize your joint definition. @ingroup revolute_joint
b2DefaultShapeDef
Use this to initialize your shape definition @ingroup shape
b2DefaultSurfaceMaterial
Use this to initialize your surface material @ingroup shape
b2DefaultWeldJointDef
Use this to initialize your joint definition @ingroup weld_joint
b2DefaultWheelJointDef
Use this to initialize your joint definition @ingroup wheel_joint
b2DefaultWorldDef
Use this to initialize your world definition @ingroup world
b2DestroyBody
Destroy a rigid body given an id. This destroys all shapes and joints attached to the body. Do not keep references to the associated shapes and joints.
b2DestroyChain
Destroy a chain shape
b2DestroyJoint
Destroy a joint. Optionally wake attached bodies.
b2DestroyShape
Destroy a shape. You may defer the body mass update which can improve performance if several shapes on a body are destroyed at once. @see b2Body_ApplyMassFromShapes
b2DestroyWorld
Destroy a world
b2DistanceJoint_EnableLimit
Enable joint limit. The limit only works if the joint spring is enabled. Otherwise the joint is rigid and the limit has no effect.
b2DistanceJoint_EnableMotor
Enable/disable the distance joint motor
b2DistanceJoint_EnableSpring
Enable/disable the distance joint spring. When disabled the distance joint is rigid.
b2DistanceJoint_GetCurrentLength
Get the current length of a distance joint
b2DistanceJoint_GetLength
Get the rest length of a distance joint
b2DistanceJoint_GetMaxLength
Get the distance joint maximum length
b2DistanceJoint_GetMaxMotorForce
Get the distance joint maximum motor force, usually in newtons
b2DistanceJoint_GetMinLength
Get the distance joint minimum length
b2DistanceJoint_GetMotorForce
Get the distance joint current motor force, usually in newtons
b2DistanceJoint_GetMotorSpeed
Get the distance joint motor speed, usually in meters per second
b2DistanceJoint_GetSpringDampingRatio
Get the spring damping ratio
b2DistanceJoint_GetSpringForceRange
Get the force range for the spring.
b2DistanceJoint_GetSpringHertz
Get the spring Hertz
b2DistanceJoint_IsLimitEnabled
Is the distance joint limit enabled?
b2DistanceJoint_IsMotorEnabled
Is the distance joint motor enabled?
b2DistanceJoint_IsSpringEnabled
Is the distance joint spring enabled?
b2DistanceJoint_SetLength
Set the rest length of a distance joint @param jointId The id for a distance joint @param length The new distance joint length
b2DistanceJoint_SetLengthRange
Set the minimum and maximum length parameters of a distance joint
b2DistanceJoint_SetMaxMotorForce
Set the distance joint maximum motor force, usually in newtons
b2DistanceJoint_SetMotorSpeed
Set the distance joint motor speed, usually in meters per second
b2DistanceJoint_SetSpringDampingRatio
Set the spring damping ratio, non-dimensional
b2DistanceJoint_SetSpringForceRange
Set the force range for the spring.
b2DistanceJoint_SetSpringHertz
Set the spring stiffness in Hertz
b2DynamicTree_Create
Constructing the tree initializes the node pool.
b2DynamicTree_CreateProxy
Create a proxy. Provide an AABB and a userData value.
b2DynamicTree_Destroy
Destroy the tree, freeing the node pool.
b2DynamicTree_DestroyProxy
Destroy a proxy. This asserts if the id is invalid.
b2DynamicTree_EnlargeProxy
Enlarge a proxy and enlarge ancestors as necessary.
b2DynamicTree_GetAABB
Get the AABB of a proxy
b2DynamicTree_GetAreaRatio
Get the ratio of the sum of the node areas to the root area.
b2DynamicTree_GetByteCount
Get the number of bytes used by this tree
b2DynamicTree_GetCategoryBits
Get the category bits on a proxy.
b2DynamicTree_GetHeight
Get the height of the binary tree.
b2DynamicTree_GetProxyCount
Get the number of proxies created
b2DynamicTree_GetRootBounds
Get the bounding box that contains the entire tree
b2DynamicTree_GetUserData
Get proxy user data
b2DynamicTree_MoveProxy
Move a proxy to a new AABB by removing and reinserting into the tree.
b2DynamicTree_Query
Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB. @return performance data
b2DynamicTree_QueryAll
Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB. No filtering is performed. @return performance data
b2DynamicTree_RayCast
Ray cast against the proxies in the tree. This relies on the callback to perform a exact ray cast in the case were the proxy contains a shape. The callback also performs the any collision filtering. This has performance roughly equal to k * log(n), where k is the number of collisions and n is the number of proxies in the tree. Bit-wise filtering using mask bits can greatly improve performance in some scenarios. However, this filtering may be approximate, so the user should still apply filtering to results. @param tree the dynamic tree to ray cast @param input the ray cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1) @param maskBits mask bit hint: bool accept = (maskBits & node->categoryBits) != 0; @param callback a callback class that is called for each proxy that is hit by the ray @param context user context that is passed to the callback @return performance data
b2DynamicTree_Rebuild
Rebuild the tree while retaining subtrees that haven’t changed. Returns the number of boxes sorted.
b2DynamicTree_SetCategoryBits
Modify the category bits on a proxy. This is an expensive operation.
b2DynamicTree_ShapeCast
Ray cast against the proxies in the tree. This relies on the callback to perform a exact ray cast in the case were the proxy contains a shape. The callback also performs the any collision filtering. This has performance roughly equal to k * log(n), where k is the number of collisions and n is the number of proxies in the tree. @param tree the dynamic tree to ray cast @param input the ray cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1). @param maskBits filter bits: bool accept = (maskBits & node->categoryBits) != 0; @param callback a callback class that is called for each proxy that is hit by the shape @param context user context that is passed to the callback @return performance data
b2DynamicTree_Validate
Validate this tree. For testing.
b2DynamicTree_ValidateNoEnlarged
Validate this tree has no enlarged AABBs. For testing.
b2GetByteCount
@return the total bytes allocated by Box2D
b2GetLengthUnitsPerMeter
Get the current length units per meter.
b2GetMilliseconds
Get the milliseconds passed from an initial tick value.
b2GetMillisecondsAndReset
Get the milliseconds passed from an initial tick value. Resets the passed in value to the current tick value.
b2GetSweepTransform
Evaluate the transform sweep at a specific time.
b2GetTicks
Get the absolute number of system ticks. The value is platform specific.
b2GetVersion
Get the current version of Box2D
b2Hash
b2InternalAssertFcn
b2IsValidAABB
Is this a valid bounding box? Not Nan or infinity. Upper bound greater than or equal to lower bound.
b2IsValidFloat
Is this a valid number? Not NaN or infinity.
b2IsValidPlane
Is this a valid plane? Normal is a unit vector. Not Nan or infinity.
b2IsValidRay
Validate ray cast input data (NaN, etc)
b2IsValidRotation
Is this a valid rotation? Not NaN or infinity. Is normalized.
b2IsValidTransform
Is this a valid transform? Not NaN or infinity. Rotation is normalized.
b2IsValidVec2
Is this a valid vector? Not NaN or infinity.
b2Joint_GetAngularSeparation
Get the current angular separation error for this joint. Does not consider admissible movement. Usually in meters.
b2Joint_GetBodyA
Get body A id on a joint
b2Joint_GetBodyB
Get body B id on a joint
b2Joint_GetCollideConnected
Is collision allowed between connected bodies?
b2Joint_GetConstraintForce
Get the current constraint force for this joint. Usually in Newtons.
b2Joint_GetConstraintTorque
Get the current constraint torque for this joint. Usually in Newton * meters.
b2Joint_GetConstraintTuning
Get the joint constraint tuning. Advanced feature.
b2Joint_GetForceThreshold
Get the force threshold for joint events (Newtons)
b2Joint_GetLinearSeparation
Get the current linear separation error for this joint. Does not consider admissible movement. Usually in meters.
b2Joint_GetLocalFrameA
Get the local frame on bodyA
b2Joint_GetLocalFrameB
Get the local frame on bodyB
b2Joint_GetTorqueThreshold
Get the torque threshold for joint events (N-m)
b2Joint_GetType
Get the joint type
b2Joint_GetUserData
Get the user data on a joint
b2Joint_GetWorld
Get the world that owns this joint
b2Joint_IsValid
Joint identifier validation. Provides validation for up to 64K allocations.
b2Joint_SetCollideConnected
Toggle collision between connected bodies
b2Joint_SetConstraintTuning
Set the joint constraint tuning. Advanced feature. @param jointId the joint @param hertz the stiffness in Hertz (cycles per second) @param dampingRatio the non-dimensional damping ratio (one for critical damping)
b2Joint_SetForceThreshold
Set the force threshold for joint events (Newtons)
b2Joint_SetLocalFrameA
Set the local frame on bodyA
b2Joint_SetLocalFrameB
Set the local frame on bodyB
b2Joint_SetTorqueThreshold
Set the torque threshold for joint events (N-m)
b2Joint_SetUserData
Set the user data on a joint
b2Joint_WakeBodies
Wake the bodies connect to this joint
b2MakeBox
Make a box (rectangle) polygon, bypassing the need for a convex hull. @param halfWidth the half-width (x-axis) @param halfHeight the half-height (y-axis)
b2MakeOffsetBox
Make an offset box, bypassing the need for a convex hull. @param halfWidth the half-width (x-axis) @param halfHeight the half-height (y-axis) @param center the local center of the box @param rotation the local rotation of the box
b2MakeOffsetPolygon
Make an offset convex polygon from a convex hull. This will assert if the hull is not valid. @warning Do not manually fill in the hull data, it must come directly from b2ComputeHull
b2MakeOffsetProxy
Make a proxy with a transform. This is a deep copy of the points.
b2MakeOffsetRoundedBox
Make an offset rounded box, bypassing the need for a convex hull. @param halfWidth the half-width (x-axis) @param halfHeight the half-height (y-axis) @param center the local center of the box @param rotation the local rotation of the box @param radius the radius of the rounded extension
b2MakeOffsetRoundedPolygon
Make an offset convex polygon from a convex hull. This will assert if the hull is not valid. @warning Do not manually fill in the hull data, it must come directly from b2ComputeHull
b2MakePolygon
Make a convex polygon from a convex hull. This will assert if the hull is not valid. @warning Do not manually fill in the hull data, it must come directly from b2ComputeHull
b2MakeProxy
Make a proxy for use in overlap, shape cast, and related functions. This is a deep copy of the points.
b2MakeRoundedBox
Make a rounded box, bypassing the need for a convex hull. @param halfWidth the half-width (x-axis) @param halfHeight the half-height (y-axis) @param radius the radius of the rounded extension
b2MakeSquare
Make a square polygon, bypassing the need for a convex hull. @param halfWidth the half-width
b2MotorJoint_GetAngularDampingRatio
Get the spring angular damping ratio.
b2MotorJoint_GetAngularHertz
Get the spring angular hertz stiffness
b2MotorJoint_GetAngularVelocity
Get the desired relative angular velocity in radians per second
b2MotorJoint_GetLinearDampingRatio
Get the spring linear damping ratio.
b2MotorJoint_GetLinearHertz
Get the spring linear hertz stiffness
b2MotorJoint_GetLinearVelocity
Get the desired relative linear velocity in meters per second
b2MotorJoint_GetMaxSpringForce
Get the maximum spring force in newtons.
b2MotorJoint_GetMaxSpringTorque
Get the maximum spring torque in newtons * meters
b2MotorJoint_GetMaxVelocityForce
Get the motor joint maximum force, usually in newtons
b2MotorJoint_GetMaxVelocityTorque
Get the motor joint maximum torque, usually in newton-meters
b2MotorJoint_SetAngularDampingRatio
Set the spring angular damping ratio. Use 1.0 for critical damping.
b2MotorJoint_SetAngularHertz
Set the spring angular hertz stiffness
b2MotorJoint_SetAngularVelocity
Set the desired relative angular velocity in radians per second
b2MotorJoint_SetLinearDampingRatio
Set the spring linear damping ratio. Use 1.0 for critical damping.
b2MotorJoint_SetLinearHertz
Set the spring linear hertz stiffness
b2MotorJoint_SetLinearVelocity
Set the desired relative linear velocity in meters per second
b2MotorJoint_SetMaxSpringForce
Set the maximum spring force in newtons.
b2MotorJoint_SetMaxSpringTorque
Set the maximum spring torque in newtons * meters
b2MotorJoint_SetMaxVelocityForce
Set the motor joint maximum force, usually in newtons
b2MotorJoint_SetMaxVelocityTorque
Set the motor joint maximum torque, usually in newton-meters
b2PointInCapsule
Test a point for overlap with a capsule in local space
b2PointInCircle
Test a point for overlap with a circle in local space
b2PointInPolygon
Test a point for overlap with a convex polygon in local space
b2PrismaticJoint_EnableLimit
Enable/disable a prismatic joint limit
b2PrismaticJoint_EnableMotor
Enable/disable a prismatic joint motor
b2PrismaticJoint_EnableSpring
Enable/disable the joint spring.
b2PrismaticJoint_GetLowerLimit
Get the prismatic joint lower limit
b2PrismaticJoint_GetMaxMotorForce
Get the prismatic joint maximum motor force, usually in newtons
b2PrismaticJoint_GetMotorForce
Get the prismatic joint current motor force, usually in newtons
b2PrismaticJoint_GetMotorSpeed
Get the prismatic joint motor speed, usually in meters per second
b2PrismaticJoint_GetSpeed
Get the current joint translation speed, usually in meters per second.
b2PrismaticJoint_GetSpringDampingRatio
Get the prismatic spring damping ratio (non-dimensional)
b2PrismaticJoint_GetSpringHertz
Get the prismatic joint stiffness in Hertz
b2PrismaticJoint_GetTargetTranslation
Get the prismatic joint spring target translation, usually in meters
b2PrismaticJoint_GetTranslation
Get the current joint translation, usually in meters.
b2PrismaticJoint_GetUpperLimit
Get the prismatic joint upper limit
b2PrismaticJoint_IsLimitEnabled
Is the prismatic joint limit enabled?
b2PrismaticJoint_IsMotorEnabled
Is the prismatic joint motor enabled?
b2PrismaticJoint_IsSpringEnabled
Is the prismatic joint spring enabled or not?
b2PrismaticJoint_SetLimits
Set the prismatic joint limits
b2PrismaticJoint_SetMaxMotorForce
Set the prismatic joint maximum motor force, usually in newtons
b2PrismaticJoint_SetMotorSpeed
Set the prismatic joint motor speed, usually in meters per second
b2PrismaticJoint_SetSpringDampingRatio
Set the prismatic joint damping ratio (non-dimensional)
b2PrismaticJoint_SetSpringHertz
Set the prismatic joint stiffness in Hertz. This should usually be less than a quarter of the simulation rate. For example, if the simulation runs at 60Hz then the joint stiffness should be 15Hz or less.
b2PrismaticJoint_SetTargetTranslation
Set the prismatic joint spring target angle, usually in meters
b2RayCastCapsule
Ray cast versus capsule shape in local space.
b2RayCastCircle
Ray cast versus circle shape in local space.
b2RayCastPolygon
Ray cast versus polygon shape in local space.
b2RayCastSegment
Ray cast versus segment shape in local space. Optionally treat the segment as one-sided with hits from the left side being treated as a miss.
b2RevoluteJoint_EnableLimit
Enable/disable the revolute joint limit
b2RevoluteJoint_EnableMotor
Enable/disable a revolute joint motor
b2RevoluteJoint_EnableSpring
Enable/disable the revolute joint spring
b2RevoluteJoint_GetAngle
Get the revolute joint current angle in radians relative to the reference angle @see b2RevoluteJointDef::referenceAngle
b2RevoluteJoint_GetLowerLimit
Get the revolute joint lower limit in radians
b2RevoluteJoint_GetMaxMotorTorque
Get the revolute joint maximum motor torque, usually in newton-meters
b2RevoluteJoint_GetMotorSpeed
Get the revolute joint motor speed in radians per second
b2RevoluteJoint_GetMotorTorque
Get the revolute joint current motor torque, usually in newton-meters
b2RevoluteJoint_GetSpringDampingRatio
Get the revolute joint spring damping ratio, non-dimensional
b2RevoluteJoint_GetSpringHertz
Get the revolute joint spring stiffness in Hertz
b2RevoluteJoint_GetTargetAngle
Get the revolute joint spring target angle, radians
b2RevoluteJoint_GetUpperLimit
Get the revolute joint upper limit in radians
b2RevoluteJoint_IsLimitEnabled
Is the revolute joint limit enabled?
b2RevoluteJoint_IsMotorEnabled
Is the revolute joint motor enabled?
b2RevoluteJoint_IsSpringEnabled
It the revolute angular spring enabled?
b2RevoluteJoint_SetLimits
Set the revolute joint limits in radians. It is expected that lower <= upper and that -0.99 * B2_PI <= lower && upper <= -0.99 * B2_PI.
b2RevoluteJoint_SetMaxMotorTorque
Set the revolute joint maximum motor torque, usually in newton-meters
b2RevoluteJoint_SetMotorSpeed
Set the revolute joint motor speed in radians per second
b2RevoluteJoint_SetSpringDampingRatio
Set the revolute joint spring damping ratio, non-dimensional
b2RevoluteJoint_SetSpringHertz
Set the revolute joint spring stiffness in Hertz
b2RevoluteJoint_SetTargetAngle
Set the revolute joint spring target angle, radians
b2SegmentDistance
Compute the distance between two line segments, clamping at the end points if needed.
b2SetAllocator
This allows the user to override the allocation functions. These should be set during application startup.
b2SetAssertFcn
Override the default assert function @param assertFcn a non-null assert callback
b2SetLengthUnitsPerMeter
Box2D bases all length units on meters, but you may need different units for your game. You can set this value to use different units. This should be done at application startup and only modified once. Default value is 1. For example, if your game uses pixels for units you can use pixels for all length values sent to Box2D. There should be no extra cost. However, Box2D has some internal tolerances and thresholds that have been tuned for meters. By calling this function, Box2D is able to adjust those tolerances and thresholds to improve accuracy. A good rule of thumb is to pass the height of your player character to this function. So if your player character is 32 pixels high, then pass 32 to this function. Then you may confidently use pixels for all the length values sent to Box2D. All length values returned from Box2D will also be pixels because Box2D does not do any scaling internally. However, you are now on the hook for coming up with good values for gravity, density, and forces. @warning This must be modified before any calls to Box2D
b2SetLogFcn
Override the default log function @param logFcn a non-null log callback
b2ShapeCast
Perform a linear shape cast of shape B moving and shape A fixed. Determines the hit point, normal, and translation fraction. Initially touching shapes are treated as a miss.
b2ShapeCastCapsule
Shape cast versus a capsule.
b2ShapeCastCircle
Shape cast versus a circle.
b2ShapeCastPolygon
Shape cast versus a convex polygon.
b2ShapeCastSegment
Shape cast versus a line segment.
b2ShapeDistance
Compute the closest points between two shapes represented as point clouds. b2SimplexCache cache is input/output. On the first call set b2SimplexCache.count to zero. The underlying GJK algorithm may be debugged by passing in debug simplexes and capacity. You may pass in NULL and 0 for these.
b2Shape_ApplyWind
Apply a wind force to the body for this shape using the density of air. This considers the projected area of the shape in the wind direction. This also considers the relative velocity of the shape. @param shapeId the shape id @param wind the wind velocity in world space @param drag the drag coefficient, the force that opposes the relative velocity @param lift the lift coefficient, the force that is perpendicular to the relative velocity @param wake should this wake the body
b2Shape_AreContactEventsEnabled
Returns true if contact events are enabled
b2Shape_AreHitEventsEnabled
Returns true if hit events are enabled
b2Shape_ArePreSolveEventsEnabled
Returns true if pre-solve events are enabled
b2Shape_AreSensorEventsEnabled
Returns true if sensor events are enabled.
b2Shape_ComputeMassData
Compute the mass data for a shape
b2Shape_EnableContactEvents
Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. @see b2ShapeDef::enableContactEvents @warning changing this at run-time may lead to lost begin/end events
b2Shape_EnableHitEvents
Enable contact hit events for this shape. Ignored for sensors. @see b2WorldDef.hitEventThreshold
b2Shape_EnablePreSolveEvents
Enable pre-solve contact events for this shape. Only applies to dynamic bodies. These are expensive and must be carefully handled due to multithreading. Ignored for sensors. @see b2PreSolveFcn
b2Shape_EnableSensorEvents
Enable sensor events for this shape. @see b2ShapeDef::enableSensorEvents
b2Shape_GetAABB
Get the current world AABB
b2Shape_GetBody
Get the id of the body that a shape is attached to
b2Shape_GetCapsule
Get a copy of the shape’s capsule. Asserts the type is correct.
b2Shape_GetChainSegment
Get a copy of the shape’s chain segment. These come from chain shapes. Asserts the type is correct.
b2Shape_GetCircle
Get a copy of the shape’s circle. Asserts the type is correct.
b2Shape_GetClosestPoint
Get the closest point on a shape to a target point. Target and result are in world space. todo need sample
b2Shape_GetContactCapacity
Get the maximum capacity required for retrieving all the touching contacts on a shape
b2Shape_GetContactData
Get the touching contact data for a shape. The provided shapeId will be either shapeIdA or shapeIdB on the contact data. @note Box2D uses speculative collision so some contact points may be separated. @returns the number of elements filled in the provided array @warning do not ignore the return value, it specifies the valid number of elements
b2Shape_GetDensity
Get the density of a shape, usually in kg/m^2
b2Shape_GetFilter
Get the shape filter
b2Shape_GetFriction
Get the friction of a shape
b2Shape_GetParentChain
Get the parent chain id if the shape type is a chain segment, otherwise returns b2_nullChainId.
b2Shape_GetPolygon
Get a copy of the shape’s convex polygon. Asserts the type is correct.
b2Shape_GetRestitution
Get the shape restitution
b2Shape_GetSegment
Get a copy of the shape’s line segment. Asserts the type is correct.
b2Shape_GetSensorCapacity
Get the maximum capacity required for retrieving all the overlapped shapes on a sensor shape. This returns 0 if the provided shape is not a sensor. @param shapeId the id of a sensor shape @returns the required capacity to get all the overlaps in b2Shape_GetSensorOverlaps
b2Shape_GetSensorData
Get the overlap data for a sensor shape. @param shapeId the id of a sensor shape @param visitorIds a user allocated array that is filled with the overlapping shapes (visitors) @param capacity the capacity of overlappedShapes @returns the number of elements filled in the provided array @warning do not ignore the return value, it specifies the valid number of elements @warning overlaps may contain destroyed shapes so use b2Shape_IsValid to confirm each overlap
b2Shape_GetSurfaceMaterial
Get the shape surface material
b2Shape_GetType
Get the type of a shape
b2Shape_GetUserData
Get the user data for a shape. This is useful when you get a shape id from an event or query.
b2Shape_GetUserMaterial
Get the user material identifier
b2Shape_GetWorld
Get the world that owns this shape
b2Shape_IsSensor
Returns true if the shape is a sensor. It is not possible to change a shape from sensor to solid dynamically because this breaks the contract for sensor events.
b2Shape_IsValid
Shape identifier validation. Provides validation for up to 64K allocations.
b2Shape_RayCast
Ray cast a shape directly
b2Shape_SetCapsule
Allows you to change a shape to be a capsule or update the current capsule. This does not modify the mass properties. @see b2Body_ApplyMassFromShapes
b2Shape_SetCircle
Allows you to change a shape to be a circle or update the current circle. This does not modify the mass properties. @see b2Body_ApplyMassFromShapes
b2Shape_SetDensity
Set the mass density of a shape, usually in kg/m^2. This will optionally update the mass properties on the parent body. @see b2ShapeDef::density, b2Body_ApplyMassFromShapes
b2Shape_SetFilter
Set the current filter. This is almost as expensive as recreating the shape. This may cause contacts to be immediately destroyed. However contacts are not created until the next world step. Sensor overlap state is also not updated until the next world step. @see b2ShapeDef::filter
b2Shape_SetFriction
Set the friction on a shape
b2Shape_SetPolygon
Allows you to change a shape to be a polygon or update the current polygon. This does not modify the mass properties. @see b2Body_ApplyMassFromShapes
b2Shape_SetRestitution
Set the shape restitution (bounciness)
b2Shape_SetSegment
Allows you to change a shape to be a segment or update the current segment.
b2Shape_SetSurfaceMaterial
Set the shape surface material
b2Shape_SetUserData
Set the user data for a shape
b2Shape_SetUserMaterial
Set the user material identifier
b2Shape_TestPoint
Test a point for overlap with a shape
b2SolvePlanes
Solves the position of a mover that satisfies the given collision planes. @param targetDelta the desired movement from the position used to generate the collision planes @param planes the collision planes @param count the number of collision planes
b2TimeOfImpact
Compute the upper bound on time before two shapes penetrate. Time is represented as a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate, non-tunneling collisions. If you change the time interval, you should call this function again.
b2TransformPolygon
Transform a polygon. This is useful for transferring a shape from one body to another.
b2ValidateHull
This determines if a hull is valid. Checks for:
b2WeldJoint_GetAngularDampingRatio
Get the weld joint angular damping ratio, non-dimensional
b2WeldJoint_GetAngularHertz
Get the weld joint angular stiffness in Hertz
b2WeldJoint_GetLinearDampingRatio
Get the weld joint linear damping ratio (non-dimensional)
b2WeldJoint_GetLinearHertz
Get the weld joint linear stiffness in Hertz
b2WeldJoint_SetAngularDampingRatio
Set weld joint angular damping ratio, non-dimensional
b2WeldJoint_SetAngularHertz
Set the weld joint angular stiffness in Hertz. 0 is rigid.
b2WeldJoint_SetLinearDampingRatio
Set the weld joint linear damping ratio (non-dimensional)
b2WeldJoint_SetLinearHertz
Set the weld joint linear stiffness in Hertz. 0 is rigid.
b2WheelJoint_EnableLimit
Enable/disable the wheel joint limit
b2WheelJoint_EnableMotor
Enable/disable the wheel joint motor
b2WheelJoint_EnableSpring
Enable/disable the wheel joint spring
b2WheelJoint_GetLowerLimit
Get the wheel joint lower limit
b2WheelJoint_GetMaxMotorTorque
Get the wheel joint maximum motor torque, usually in newton-meters
b2WheelJoint_GetMotorSpeed
Get the wheel joint motor speed in radians per second
b2WheelJoint_GetMotorTorque
Get the wheel joint current motor torque, usually in newton-meters
b2WheelJoint_GetSpringDampingRatio
Get the wheel joint damping ratio, non-dimensional
b2WheelJoint_GetSpringHertz
Get the wheel joint stiffness in Hertz
b2WheelJoint_GetUpperLimit
Get the wheel joint upper limit
b2WheelJoint_IsLimitEnabled
Is the wheel joint limit enabled?
b2WheelJoint_IsMotorEnabled
Is the wheel joint motor enabled?
b2WheelJoint_IsSpringEnabled
Is the wheel joint spring enabled?
b2WheelJoint_SetLimits
Set the wheel joint limits
b2WheelJoint_SetMaxMotorTorque
Set the wheel joint maximum motor torque, usually in newton-meters
b2WheelJoint_SetMotorSpeed
Set the wheel joint motor speed in radians per second
b2WheelJoint_SetSpringDampingRatio
Set the wheel joint damping ratio, non-dimensional
b2WheelJoint_SetSpringHertz
Set the wheel joint stiffness in Hertz
b2World_CastMover
Cast a capsule mover through the world. This is a special shape cast that handles sliding along other shapes while reducing clipping.
b2World_CastRay
Cast a ray into the world to collect shapes in the path of the ray. Your callback function controls whether you get the closest point, any point, or n-points. @note The callback function may receive shapes in any order @param worldId The world to cast the ray against @param origin The start point of the ray @param translation The translation of the ray from the start point to the end point @param filter Contains bit flags to filter unwanted shapes from the results @param fcn A user implemented callback function @param context A user context that is passed along to the callback function @return traversal performance counters
b2World_CastRayClosest
Cast a ray into the world to collect the closest hit. This is a convenience function. Ignores initial overlap. This is less general than b2World_CastRay() and does not allow for custom filtering.
b2World_CastShape
Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point. @see b2World_CastRay
b2World_CollideMover
Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.
b2World_Draw
Call this to draw shapes and other debug draw data
b2World_DumpMemoryStats
Dump memory stats to box2d_memory.txt
b2World_EnableContinuous
Enable/disable continuous collision between dynamic and static bodies. Generally you should keep continuous collision enabled to prevent fast moving objects from going through static objects. The performance gain from disabling continuous collision is minor. @see b2WorldDef
b2World_EnableSleeping
Enable/disable sleep. If your application does not need sleeping, you can gain some performance by disabling sleep completely at the world level. @see b2WorldDef
b2World_EnableSpeculative
This is for internal testing
b2World_EnableWarmStarting
Enable/disable constraint warm starting. Advanced feature for testing. Disabling warm starting greatly reduces stability and provides no performance gain.
b2World_Explode
Apply a radial explosion @param worldId The world id @param explosionDef The explosion definition
b2World_GetAwakeBodyCount
Get the number of awake bodies.
b2World_GetBodyEvents
Get the body events for the current time step. The event data is transient. Do not store a reference to this data.
b2World_GetContactEvents
Get contact events for this current time step. The event data is transient. Do not store a reference to this data.
b2World_GetCounters
Get world counters and sizes
b2World_GetGravity
Get the gravity vector
b2World_GetHitEventThreshold
Get the the hit event speed threshold. Usually in meters per second.
b2World_GetJointEvents
Get the joint events for the current time step. The event data is transient. Do not store a reference to this data.
b2World_GetMaximumLinearSpeed
Get the maximum linear speed. Usually in m/s.
b2World_GetProfile
Get the current world performance profile
b2World_GetRestitutionThreshold
Get the the restitution speed threshold. Usually in meters per second.
b2World_GetSensorEvents
Get sensor events for the current time step. The event data is transient. Do not store a reference to this data.
b2World_GetUserData
Get the user data pointer.
b2World_IsContinuousEnabled
Is continuous collision enabled?
b2World_IsSleepingEnabled
Is body sleeping enabled?
b2World_IsValid
World id validation. Provides validation for up to 64K allocations.
b2World_IsWarmStartingEnabled
Is constraint warm starting enabled?
b2World_OverlapAABB
Overlap test for all shapes that potentially overlap the provided AABB
b2World_OverlapShape
Overlap test for all shapes that overlap the provided shape proxy.
b2World_RebuildStaticTree
This is for internal testing
b2World_SetContactTuning
Adjust contact tuning parameters @param worldId The world id @param hertz The contact stiffness (cycles per second) @param dampingRatio The contact bounciness with 1 being critical damping (non-dimensional) @param pushSpeed The maximum contact constraint push out speed (meters per second) @note Advanced feature
b2World_SetCustomFilterCallback
Register the custom filter callback. This is optional.
b2World_SetFrictionCallback
Set the friction callback. Passing NULL resets to default.
b2World_SetGravity
Set the gravity vector for the entire world. Box2D has no concept of an up direction and this is left as a decision for the application. Usually in m/s^2. @see b2WorldDef
b2World_SetHitEventThreshold
Adjust the hit event threshold. This controls the collision speed needed to generate a b2ContactHitEvent. Usually in meters per second. @see b2WorldDef::hitEventThreshold
b2World_SetMaximumLinearSpeed
Set the maximum linear speed. Usually in m/s.
b2World_SetPreSolveCallback
Register the pre-solve callback. This is optional.
b2World_SetRestitutionCallback
Set the restitution callback. Passing NULL resets to default.
b2World_SetRestitutionThreshold
Adjust the restitution threshold. It is recommended not to make this value very small because it will prevent bodies from sleeping. Usually in meters per second. @see b2WorldDef
b2World_SetUserData
Set the user data pointer.
b2World_Step
Simulate a world for one time step. This performs collision detection, integration, and constraint solution. @param worldId The world to simulate @param timeStep The amount of time to simulate, this should be a fixed number. Usually 1/60. @param subStepCount The number of sub-steps, increasing the sub-step count can increase accuracy. Usually 4.
b2Yield
Yield to be used in a busy loop.

Type Aliases§

b2AllocFcn
Prototype for user allocation function @param size the allocation size in bytes @param alignment the required alignment, guaranteed to be a power of 2
b2AssertFcn
Prototype for the user assert callback. Return 0 to skip the debugger break.
b2BodyType
The body simulation type. Each body is one of these three types. The type determines how the body behaves in the simulation. @ingroup body
b2CastResultFcn
Prototype callback for ray and shape casts. Called for each shape found in the query. You control how the ray cast proceeds by returning a float: return -1: ignore this shape and continue return 0: terminate the ray cast return fraction: clip the ray to this point return 1: don’t clip the ray and continue A cast with initial overlap will return a zero fraction and a zero normal. @param shapeId the shape hit by the ray @param point the point of initial intersection @param normal the normal vector at the point of intersection, zero for a shape cast with initial overlap @param fraction the fraction along the ray at the point of intersection, zero for a shape cast with initial overlap @param context the user context @return -1 to filter, 0 to terminate, fraction to clip the ray for closest hit, 1 to continue @see b2World_CastRay @ingroup world
b2CustomFilterFcn
Prototype for a contact filter callback. This is called when a contact pair is considered for collision. This allows you to perform custom logic to prevent collision between shapes. This is only called if one of the two shapes has custom filtering enabled. Notes:
b2EnqueueTaskCallback
These functions can be provided to Box2D to invoke a task system. These are designed to work well with enkiTS. Returns a pointer to the user’s task object. May be nullptr. A nullptr indicates to Box2D that the work was executed serially within the callback and there is no need to call b2FinishTaskCallback. The itemCount is the number of Box2D work items that are to be partitioned among workers by the user’s task system. This is essentially a parallel-for. The minRange parameter is a suggestion of the minimum number of items to assign per worker to reduce overhead. For example, suppose the task is small and that itemCount is 16. A minRange of 8 suggests that your task system should split the work items among just two workers, even if you have more available. In general the range [startIndex, endIndex) send to b2TaskCallback should obey: endIndex - startIndex >= minRange The exception of course is when itemCount < minRange. @ingroup world
b2FinishTaskCallback
Finishes a user task object that wraps a Box2D task. @ingroup world
b2FreeFcn
Prototype for user free function @param mem the memory previously allocated through b2AllocFcn @param size the allocation size in bytes
b2FrictionCallback
Optional friction mixing callback. This intentionally provides no context objects because this is called from a worker thread. @warning This function should not attempt to modify Box2D state or user application state. @ingroup world
b2HexColor
These colors are used for debug draw and mostly match the named SVG colors. See https://www.rapidtables.com/web/color/index.html https://johndecember.com/html/spec/colorsvg.html https://upload.wikimedia.org/wikipedia/commons/2/2b/SVG_Recognized_color_keyword_names.svg
b2JointType
Joint type enumeration
b2LogFcn
Prototype for user log callback. Used to log warnings.
b2OverlapResultFcn
Prototype callback for overlap queries. Called for each shape found in the query. @see b2World_OverlapABB @return false to terminate the query. @ingroup world
b2PlaneResultFcn
b2PreSolveFcn
Prototype for a pre-solve callback. This is called after a contact is updated. This allows you to inspect a contact before it goes to the solver. If you are careful, you can modify the contact manifold (e.g. modify the normal). Notes:
b2RestitutionCallback
Optional restitution mixing callback. This intentionally provides no context objects because this is called from a worker thread. @warning This function should not attempt to modify Box2D state or user application state. @ingroup world
b2ShapeType
Shape type @ingroup shape
b2TOIState
Describes the TOI output
b2TaskCallback
Task interface This is prototype for a Box2D task. Your task system is expected to invoke the Box2D task with these arguments. The task spans a range of the parallel-for: [startIndex, endIndex) The worker index must correctly identify each worker in the user thread pool, expected in [0, workerCount). A worker must only exist on only one thread at a time and is analogous to the thread index. The task context is the context pointer sent from Box2D when it is enqueued. The startIndex and endIndex are expected in the range [0, itemCount) where itemCount is the argument to b2EnqueueTaskCallback below. Box2D expects startIndex < endIndex and will execute a loop like this:
b2TreeQueryCallbackFcn
This function receives proxies found in the AABB query. @return true if the query should continue
b2TreeRayCastCallbackFcn
This function receives clipped ray cast input for a proxy. The function returns the new ray fraction.
b2TreeShapeCastCallbackFcn
This function receives clipped ray cast input for a proxy. The function returns the new ray fraction.