package vendor:box2d
Overview
Bindings for Box2D.
External Examples 1 ¶
The programs in odin-lang/examples about this package, and how many of its declarations each uses.
- raylib/
- box2d14
Index
Types (92)
- AABB
- AllocFcn
- AssertFcn
- BodyDef
- BodyEvents
- BodyId
- BodyMoveEvent
- BodyType
- Capsule
- CastOutput
- CastResultFcn
- ChainDef
- ChainId
- ChainSegment
- Circle
- CollisionPlane
- ContactBeginTouchEvent
- ContactData
- ContactEndTouchEvent
- ContactEvents
- ContactHitEvent
- CosSin
- Counters
- CustomFilterFcn
- DebugDraw
- DistanceInput
- DistanceJointDef
- DistanceOutput
- DynamicTree
- EnqueueTaskCallback
- ExplosionDef
- Filter
- FilterJointDef
- FinishTaskCallback
- FreeFcn
- FrictionCallback
- HexColor
- Hull
- JointId
- JointType
- Manifold
- ManifoldPoint
- MassData
- Mat22
- MotorJointDef
- MouseJointDef
- OverlapResultFcn
- Plane
- PlaneResult
- PlaneResultFcn
- PlaneSolverResult
- Polygon
- PreSolveFcn
- PrismaticJointDef
- Profile
- QueryFilter
- RayCastInput
- RayResult
- RestitutionCallback
- RevoluteJointDef
- Rot
- Segment
- SegmentDistanceResult
- SensorBeginTouchEvent
- SensorEndTouchEvent
- SensorEvents
- ShapeCastInput
- ShapeCastPairInput
- ShapeDef
- ShapeId
- ShapeProxy
- ShapeType
- Simplex
- SimplexCache
- SimplexVertex
- SurfaceMaterial
- Sweep
- TOIInput
- TOIOutput
- TOIState
- TaskCallback
- Transform
- TreeQueryCallbackFcn
- TreeRayCastCallbackFcn
- TreeShapeCastCallbackFcn
- TreeStats
- Vec2
- Version
- WeldJointDef
- WheelJointDef
- WorldDef
- WorldId
Variables (0)
This section is empty.
Procedures (490)
AABB_… (5)
- Abs
AbsFloatAbsIntAdd- Atan2
Body_… (64)
- Body_ApplyAngularImpulse
- Body_ApplyForce
- Body_ApplyForceToCenter
- Body_ApplyLinearImpulse
- Body_ApplyLinearImpulseToCenter
- Body_ApplyMassFromShapes
- Body_ApplyTorque
- Body_ComputeAABB
- Body_Disable
- Body_Enable
- Body_EnableContactEvents
- Body_EnableHitEvents
- Body_EnableSleep
- Body_GetAngularDamping
- Body_GetAngularVelocity
- Body_GetContactCapacity
- Body_GetContactData
- Body_GetGravityScale
- Body_GetJointCount
- Body_GetJoints
- Body_GetLinearDamping
- Body_GetLinearVelocity
- Body_GetLocalCenterOfMass
- Body_GetLocalPoint
- Body_GetLocalPointVelocity
- Body_GetLocalVector
- Body_GetMass
- Body_GetMassData
- Body_GetName
- Body_GetPosition
- Body_GetRotation
- Body_GetRotationalInertia
- Body_GetShapeCount
- Body_GetShapes
- Body_GetSleepThreshold
- Body_GetTransform
- Body_GetType
- Body_GetUserData
- Body_GetWorld
- Body_GetWorldCenterOfMass
- Body_GetWorldPoint
- Body_GetWorldPointVelocity
- Body_GetWorldVector
- Body_IsAwake
- Body_IsBullet
- Body_IsEnabled
- Body_IsFixedRotation
- Body_IsSleepEnabled
- Body_IsValid
- Body_SetAngularDamping
- Body_SetAngularVelocity
- Body_SetAwake
- Body_SetBullet
- Body_SetFixedRotation
- Body_SetGravityScale
- Body_SetLinearDamping
- Body_SetLinearVelocity
- Body_SetMassData
- Body_SetName
- Body_SetSleepThreshold
- Body_SetTargetTransform
- Body_SetTransform
- Body_SetType
- Body_SetUserData
- Clamp
ClampFloatClampInt- ClipVector
- CollideCapsuleAndCircle
- CollideCapsules
- CollideChainSegmentAndCapsule
- CollideChainSegmentAndCircle
- CollideChainSegmentAndPolygon
- CollideCircles
- CollidePolygonAndCapsule
- CollidePolygonAndCircle
- CollidePolygons
- CollideSegmentAndCapsule
- CollideSegmentAndCircle
- CollideSegmentAndPolygon
- ComputeAngularVelocity
- ComputeCapsuleAABB
- ComputeCapsuleMass
- ComputeCircleAABB
- ComputeCircleMass
- ComputeCosSin
- ComputeHull
- ComputePolygonAABB
- ComputePolygonMass
- ComputeRotationBetweenUnitVectors
- ComputeSegmentAABB
- CreateBody
- CreateCapsuleShape
- CreateChain
- CreateCircleShape
- CreateDistanceJoint
- CreateFilterJoint
- CreateMotorJoint
- CreateMouseJoint
- CreatePolygonShape
- CreatePrismaticJoint
- CreateRevoluteJoint
- CreateSegmentShape
- CreateWeldJoint
- CreateWheelJoint
- CreateWorld
- Cross
- CrossSV
- CrossVS
- DefaultBodyDef
- DefaultChainDef
- DefaultDebugDraw
- DefaultDistanceJointDef
- DefaultExplosionDef
- DefaultFilter
- DefaultFilterJointDef
- DefaultMotorJointDef
- DefaultMouseJointDef
- DefaultPrismaticJointDef
- DefaultQueryFilter
- DefaultRevoluteJointDef
- DefaultShapeDef
- DefaultSurfaceMaterial
- DefaultWeldJointDef
- DefaultWheelJointDef
- DefaultWorldDef
- DestroyBody
- DestroyChain
- DestroyJoint
- DestroyShape
- DestroyWorld
- Distance
DistanceJoint_… (21)
- DistanceJoint_EnableLimit
- DistanceJoint_EnableMotor
- DistanceJoint_EnableSpring
- DistanceJoint_GetCurrentLength
- DistanceJoint_GetLength
- DistanceJoint_GetMaxLength
- DistanceJoint_GetMaxMotorForce
- DistanceJoint_GetMinLength
- DistanceJoint_GetMotorForce
- DistanceJoint_GetMotorSpeed
- DistanceJoint_GetSpringDampingRatio
- DistanceJoint_GetSpringHertz
- DistanceJoint_IsLimitEnabled
- DistanceJoint_IsMotorEnabled
- DistanceJoint_IsSpringEnabled
- DistanceJoint_SetLength
- DistanceJoint_SetLengthRange
- DistanceJoint_SetMaxMotorForce
- DistanceJoint_SetMotorSpeed
- DistanceJoint_SetSpringDampingRatio
- DistanceJoint_SetSpringHertz
- DistanceSquared
- Dot
DynamicTree_… (21)
- DynamicTree_Create
- DynamicTree_CreateProxy
- DynamicTree_Destroy
- DynamicTree_DestroyProxy
- DynamicTree_EnlargeProxy
- DynamicTree_GetAABB
- DynamicTree_GetAreaRatio
- DynamicTree_GetByteCount
- DynamicTree_GetCategoryBits
- DynamicTree_GetHeight
- DynamicTree_GetProxyCount
- DynamicTree_GetRootBounds
- DynamicTree_GetUserData
- DynamicTree_MoveProxy
- DynamicTree_Query
- DynamicTree_RayCast
- DynamicTree_Rebuild
- DynamicTree_SetCategoryBits
- DynamicTree_ShapeCast
- DynamicTree_Validate
- DynamicTree_ValidateNoEnlarged
- GetByteCount
- GetInverse22
- GetLengthAndNormalize
- GetLengthUnitsPerMeter
- GetMilliseconds
- GetMillisecondsAndReset
- GetSweepTransform
- GetTicks
- GetVersion
- Hash
- ID_EQUALS
- IS_NON_NULL
- IS_NULL
- IntegrateRotation
- InvMulRot
- InvMulTransforms
- InvRotateVector
- InvTransformPoint
- IsNormalized
- IsNormalizedRot
- IsValidAABB
- IsValidFloat
- IsValidPlane
- IsValidRay
- IsValidRotation
- IsValidVec2
Joint_… (24)
- Joint_GetAngularSeparation
- Joint_GetBodyA
- Joint_GetBodyB
- Joint_GetCollideConnected
- Joint_GetConstraintForce
- Joint_GetConstraintTorque
- Joint_GetConstraintTuning
- Joint_GetLinearSeparation
- Joint_GetLocalAnchorA
- Joint_GetLocalAnchorB
- Joint_GetLocalAxisA
- Joint_GetReferenceAngle
- Joint_GetType
- Joint_GetUserData
- Joint_GetWorld
- Joint_IsValid
- Joint_SetCollideConnected
- Joint_SetConstraintTuning
- Joint_SetLocalAnchorA
- Joint_SetLocalAnchorB
- Joint_SetLocalAxisA
- Joint_SetReferenceAngle
- Joint_SetUserData
- Joint_WakeBodies
- LeftPerp
- Length
- LengthSquared
- Lerp
- LoadWorldId
- MakeAABB
- MakeBox
- MakeOffsetBox
- MakeOffsetPolygon
- MakeOffsetProxy
- MakeOffsetRoundedBox
- MakeOffsetRoundedPolygon
- MakePolygon
- MakeProxy
- MakeRot
- MakeRoundedBox
- MakeSquare
- Max
MaxFloatMaxInt- Min
MinFloatMinIntMulMulAddMulMV- MulRot
MulSVMulSub- MulTransforms
- NLerp
Neg- Normalize
- NormalizeChecked
- NormalizeRot
- PlaneSeparation
- PointInCapsule
- PointInCircle
- PointInPolygon
PrismaticJoint_… (22)
- PrismaticJoint_EnableLimit
- PrismaticJoint_EnableMotor
- PrismaticJoint_EnableSpring
- PrismaticJoint_GetLowerLimit
- PrismaticJoint_GetMaxMotorForce
- PrismaticJoint_GetMotorForce
- PrismaticJoint_GetMotorSpeed
- PrismaticJoint_GetSpeed
- PrismaticJoint_GetSpringDampingRatio
- PrismaticJoint_GetSpringHertz
- PrismaticJoint_GetTargetTranslation
- PrismaticJoint_GetTranslation
- PrismaticJoint_GetUpperLimit
- PrismaticJoint_IsLimitEnabled
- PrismaticJoint_IsMotorEnabled
- PrismaticJoint_IsSpringEnabled
- PrismaticJoint_SetLimits
- PrismaticJoint_SetMaxMotorForce
- PrismaticJoint_SetMotorSpeed
- PrismaticJoint_SetSpringDampingRatio
- PrismaticJoint_SetSpringHertz
- PrismaticJoint_SetTargetTranslation
- RayCastCapsule
- RayCastCircle
- RayCastPolygon
- RayCastSegment
- RelativeAngle
RevoluteJoint_… (21)
- RevoluteJoint_EnableLimit
- RevoluteJoint_EnableMotor
- RevoluteJoint_EnableSpring
- RevoluteJoint_GetAngle
- RevoluteJoint_GetLowerLimit
- RevoluteJoint_GetMaxMotorTorque
- RevoluteJoint_GetMotorSpeed
- RevoluteJoint_GetMotorTorque
- RevoluteJoint_GetSpringDampingRatio
- RevoluteJoint_GetSpringHertz
- RevoluteJoint_GetTargetAngle
- RevoluteJoint_GetUpperLimit
- RevoluteJoint_IsLimitEnabled
- RevoluteJoint_IsMotorEnabled
- RevoluteJoint_IsSpringEnabled
- RevoluteJoint_SetLimits
- RevoluteJoint_SetMaxMotorTorque
- RevoluteJoint_SetMotorSpeed
- RevoluteJoint_SetSpringDampingRatio
- RevoluteJoint_SetSpringHertz
- RevoluteJoint_SetTargetAngle
- RightPerp
Rot_… (3)
- RotateVector
- SegmentDistance
- SetAllocator
- SetAssertFcn
- SetLengthUnitsPerMeter
- ShapeCast
- ShapeCastCapsule
- ShapeCastCircle
- ShapeCastPolygon
- ShapeCastSegment
- ShapeDistance
Shape_… (46)
- Shape_AreContactEventsEnabled
- Shape_AreHitEventsEnabled
- Shape_ArePreSolveEventsEnabled
- Shape_AreSensorEventsEnabled
- Shape_EnableContactEvents
- Shape_EnableHitEvents
- Shape_EnablePreSolveEvents
- Shape_EnableSensorEvents
- Shape_GetAABB
- Shape_GetBody
- Shape_GetCapsule
- Shape_GetChainSegment
- Shape_GetCircle
- Shape_GetClosestPoint
- Shape_GetContactCapacity
- Shape_GetContactData
- Shape_GetDensity
- Shape_GetFilter
- Shape_GetFriction
- Shape_GetMassData
- Shape_GetMaterial
- Shape_GetParentChain
- Shape_GetPolygon
- Shape_GetRestitution
- Shape_GetSegment
- Shape_GetSensorCapacity
- Shape_GetSensorOverlaps
- Shape_GetSurfaceMaterial
- Shape_GetType
- Shape_GetUserData
- Shape_GetWorld
- Shape_IsSensor
- Shape_IsValid
- Shape_RayCast
- Shape_SetCapsule
- Shape_SetCircle
- Shape_SetDensity
- Shape_SetFilter
- Shape_SetFriction
- Shape_SetMaterial
- Shape_SetPolygon
- Shape_SetRestitution
- Shape_SetSegment
- Shape_SetSurfaceMaterial
- Shape_SetUserData
- Shape_TestPoint
- Solve22
- SolvePlanes
- StoreWorldId
Sub- TimeOfImpact
- TransformPoint
- TransformPolygon
- UnwindAngle
- ValidateHull
WheelJoint_… (18)
- WheelJoint_EnableLimit
- WheelJoint_EnableMotor
- WheelJoint_EnableSpring
- WheelJoint_GetLowerLimit
- WheelJoint_GetMaxMotorTorque
- WheelJoint_GetMotorSpeed
- WheelJoint_GetMotorTorque
- WheelJoint_GetSpringDampingRatio
- WheelJoint_GetSpringHertz
- WheelJoint_GetUpperLimit
- WheelJoint_IsLimitEnabled
- WheelJoint_IsMotorEnabled
- WheelJoint_IsSpringEnabled
- WheelJoint_SetLimits
- WheelJoint_SetMaxMotorTorque
- WheelJoint_SetMotorSpeed
- WheelJoint_SetSpringDampingRatio
- WheelJoint_SetSpringHertz
World_… (41)
- World_CastMover
- World_CastRay
- World_CastRayClosest
- World_CastShape
- World_CollideMover
- World_Draw
- World_DumpMemoryStats
- World_EnableContinuous
- World_EnableSleeping
- World_EnableSpeculative
- World_EnableWarmStarting
- World_Explode
- World_GetAwakeBodyCount
- World_GetBodyEvents
- World_GetContactEvents
- World_GetCounters
- World_GetGravity
- World_GetHitEventThreshold
- World_GetMaximumLinearSpeed
- World_GetProfile
- World_GetRestitutionThreshold
- World_GetSensorEvents
- World_GetUserData
- World_IsContinuousEnabled
- World_IsSleepingEnabled
- World_IsValid
- World_IsWarmStartingEnabled
- World_OverlapAABB
- World_OverlapShape
- World_RebuildStaticTree
- World_SetContactTuning
- World_SetCustomFilterCallback
- World_SetFrictionCallback
- World_SetGravity
- World_SetHitEventThreshold
- World_SetMaximumLinearSpeed
- World_SetPreSolveCallback
- World_SetRestitutionCallback
- World_SetRestitutionThreshold
- World_SetUserData
- World_Step
- Yield
- b2SpringDamper
Procedure Groups (1)
Types
AllocFcn ¶
Prototype for user allocation function
@param size the allocation size in bytes @param alignment the required alignment, guaranteed to be a power of 2
AssertFcn ¶
Prototype for the user assert callback. Return 0 to skip the debugger break.
BodyDef ¶
BodyDef :: struct { // The body type: static, kinematic, or dynamic. type: BodyType, // The initial world position of the body. Bodies should be created with the desired position. // @note Creating bodies at the origin and then moving them nearly doubles the cost of body creation, especially // if the body is moved after shapes have been added. position: [2]f32, // The initial world rotation of the body. Use b2MakeRot() if you have an angle. rotation: Rot, // The initial linear velocity of the body's origin. Usually in meters per second. linearVelocity: [2]f32, // The initial angular velocity of the body. Radians per second. angularVelocity: f32, // Linear damping is used to reduce the linear velocity. The damping parameter // can be larger than 1 but the damping effect becomes sensitive to the // time step when the damping parameter is large. // Generally linear damping is undesirable because it makes objects move slowly // as if they are f32ing. linearDamping: f32, // Angular damping is used to reduce the angular velocity. The damping parameter // can be larger than 1.0f but the damping effect becomes sensitive to the // time step when the damping parameter is large. // Angular damping can be use slow down rotating bodies. angularDamping: f32, // Scale the gravity applied to this body. Non-dimensional. gravityScale: f32, // Sleep speed threshold, default is 0.05 meters per second sleepThreshold: f32, // Optional body name for debugging. Up to 32 characters (excluding null termination) name: cstring, // Use this to store application specific body data. userData: rawptr, // Set this flag to false if this body should never fall asleep. enableSleep: bool, // Is this body initially awake or sleeping? isAwake: bool, // Should this body be prevented from rotating? Useful for characters. fixedRotation: bool, // Treat this body as high speed object that performs continuous collision detection // against dynamic and kinematic bodies, but not other bullet bodies. // @warning Bullets should be used sparingly. They are not a solution for general dynamic-versus-dynamic // continuous collision. They may interfere with joint constraints. isBullet: bool, // Used to disable a body. A disabled body does not move or collide. isEnabled: bool, // This allows this body to bypass rotational speed limits. Should only be used // for circular objects, like wheels. allowFastRotation: bool, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
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
BodyEvents ¶
BodyEvents :: struct { // Array of move events moveEvents: [^]BodyMoveEvent `fmt:"v,moveCount"`, // Number of move events moveCount: i32, }
Body events are buffered in the Box2D world and are available
as event arrays after the time step is complete. Note: this date becomes invalid if bodies are destroyed
BodyId ¶
/ Body id references a body instance. This should be treated as an opaque handle.
External examples raylib/box2d
Related Procedures With Parameters
- Body_ApplyAngularImpulse
- Body_ApplyForce
- Body_ApplyForceToCenter
- Body_ApplyLinearImpulse
- Body_ApplyLinearImpulseToCenter
- Body_ApplyMassFromShapes
- Body_ApplyTorque
- Body_ComputeAABB
- Body_Disable
- Body_Enable
- Body_EnableContactEvents
- Body_EnableHitEvents
- Body_EnableSleep
- Body_GetAngularDamping
- Body_GetAngularVelocity
- Body_GetContactCapacity
- Body_GetContactData
- Body_GetGravityScale
- Body_GetJointCount
- Body_GetJoints
- Body_GetLinearDamping
- Body_GetLinearVelocity
- Body_GetLocalCenterOfMass
- Body_GetLocalPoint
- Body_GetLocalPointVelocity
- Body_GetLocalVector
- Body_GetMass
- Body_GetMassData
- Body_GetName
- Body_GetPosition
- Body_GetRotation
- Body_GetRotationalInertia
- Body_GetShapeCount
- Body_GetShapes
- Body_GetSleepThreshold
- Body_GetTransform
- Body_GetType
- Body_GetUserData
- Body_GetWorld
- Body_GetWorldCenterOfMass
- Body_GetWorldPoint
- Body_GetWorldPointVelocity
- Body_GetWorldVector
- Body_IsAwake
- Body_IsBullet
- Body_IsEnabled
- Body_IsFixedRotation
- Body_IsSleepEnabled
- Body_IsValid
- Body_SetAngularDamping
- Body_SetAngularVelocity
- Body_SetAwake
- Body_SetBullet
- Body_SetFixedRotation
- Body_SetGravityScale
- Body_SetLinearDamping
- Body_SetLinearVelocity
- Body_SetMassData
- Body_SetName
- Body_SetSleepThreshold
- Body_SetTargetTransform
- Body_SetTransform
- Body_SetType
- Body_SetUserData
- CreateCapsuleShape
- CreateChain
- CreateCircleShape
- CreatePolygonShape
- CreateSegmentShape
- DestroyBody
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
BodyMoveEvent ¶
BodyMoveEvent :: struct { transform: Transform, bodyId: BodyId, userData: rawptr, fellAsleep: bool, }
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.
BodyType ¶
BodyType :: enum i32 { // zero mass, zero velocity, may be manually moved staticBody = 0, // zero mass, velocity set by user, moved by solver kinematicBody = 1, // positive mass, velocity determined by forces, moved by solver dynamicBody = 2, }
The body simulation type. Each body is one of these three types. The type determines how the body behaves in the simulation. @ingroup body
Capsule ¶
Capsule :: struct { // Local center of the first semicircle center1: [2]f32, // Local center of the second semicircle center2: [2]f32, // The radius of the semicircles radius: f32, }
A solid capsule can be viewed as two semicircles connected
by a rectangle.
Related Procedures With Parameters
CastOutput ¶
CastOutput :: struct { // The surface normal at the hit point normal: [2]f32, // The surface hit point point: [2]f32, // The fraction of the input translation at collision fraction: f32, // The number of iterations used iterations: i32, // Did the cast hit? hit: bool, }
Low level ray cast or shape-cast output data. Returns a zero fraction and normal in the case of initial overlap.
Related Procedures With Returns
CastResultFcn ¶
CastResultFcn :: proc "c" (shapeId: ShapeId, point: [2]f32, normal: [2]f32, fraction: f32, ctx: rawptr) -> f32
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 f32: 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
Related Procedures With Parameters
ChainDef ¶
ChainDef :: struct { // Use this to store application specific shape data. userData: rawptr, // An array of at least 4 points. These are cloned and may be temporary. points: [^][2]f32 `fmt:"v,count"`, // The point count, must be 4 or more. count: i32, // Surface materials for each segment. These are cloned. materials: [^]SurfaceMaterial `fmt:"v,materialCount"`, // The material count. Must be 1 or count. This allows you to provide one // material for all segments or a unique material per segment. materialCount: i32, // Contact filtering data. filter: Filter, // Indicates a closed chain formed by connecting the first and last points isLoop: bool, // Enable sensors to detect this chain. False by default. enableSensorEvents: bool, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
Used to create a chain of line segments. This is designed to eliminate ghost collisions with some limitations.
- chains are one-sided - chains have no mass and should be used on static bodies - chains have a counter-clockwise winding order (normal points right of segment direction) - chains are either a loop or open
- a chain must have at least 4 points
- the distance between any two points must be greater than B2_LINEAR_SLOP
- a chain shape should not self intersect (this is not validated)
- an open chain shape has NO COLLISION on the first and final edge
- you may overlap two open chains on their first three and/or last three points to get smooth collision
- a chain shape creates multiple line segment shapes on the body https://en.wikipedia.org/wiki/Polygonal_chain Must be initialized using b2DefaultChainDef().
@warning Do not use chain shapes unless you understand the limitations. This is an advanced feature.
@ingroup shape
ChainId ¶
/ Chain id references a chain instances. This should be treated as an opaque handle.
Related Procedures With Parameters
Related Procedures With Returns
Related Constants
ChainSegment ¶
ChainSegment :: struct { // The tail ghost vertex ghost1: [2]f32, // The line segment segment: Segment, // The head ghost vertex ghost2: [2]f32, // The owning chain shape index (internal usage only) chainId: i32, }
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
Related Procedures With Parameters
Circle ¶
A solid circle
CollisionPlane ¶
CollisionPlane :: struct { // The collision plane between the mover and some shape plane: Plane, // Setting this to FLT_MAX makes the plane as rigid as possible. Lower values can // make the plane collision soft. Usually in meters. pushLimit: f32, // The push on the mover determined by b2SolvePlanes. Usually in meters. push: f32, // Indicates if b2ClipVector should clip against this plane. Should be false for soft collision. clipVelocity: bool, }
These are collision planes that can be fed to b2SolvePlanes. Normally this is assembled by the user from plane results in b2PlaneResult
ContactBeginTouchEvent ¶
ContactBeginTouchEvent :: struct { // Id of the first shape shapeIdA: ShapeId, // Id of the second shape shapeIdB: ShapeId, // The initial contact manifold. This is recorded before the solver is called, // so all the impulses will be zero. manifold: Manifold, }
A begin touch event is generated when two shapes begin touching.
ContactData ¶
ContactData :: struct { // Id of the first shape shapeIdA: ShapeId, // Id of the second shape shapeIdB: ShapeId, // The initial contact manifold. This is recorded before the solver is called, // so all the impulses will be zero. manifold: Manifold, }
The contact data for two shapes. By convention the manifold normal points
from shape A to shape B. @see b2Shape_GetContactData() and b2Body_GetContactData()
ContactEndTouchEvent ¶
ContactEndTouchEvent :: struct { // Id of the first shape // @warning this shape may have been destroyed // @see b2Shape_IsValid shapeIdA: ShapeId, // Id of the second shape // @warning this shape may have been destroyed // @see b2Shape_IsValid shapeIdB: ShapeId, }
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.
ContactEvents ¶
ContactEvents :: struct { // Array of begin touch events beginEvents: [^]ContactBeginTouchEvent `fmt:"v,beginCount"`, // Array of end touch events endEvents: [^]ContactEndTouchEvent `fmt:"v,endCount"`, // Array of hit events hitEvents: [^]ContactHitEvent `fmt:"v,hitCount"`, // Number of begin touch events beginCount: i32, // Number of end touch events endCount: i32, // Number of hit events hitCount: i32, }
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
ContactHitEvent ¶
ContactHitEvent :: struct { // Id of the first shape shapeIdA: ShapeId, // Id of the second shape shapeIdB: ShapeId, // Point where the shapes hit at the beginning of the time step. // This is a mid-point between the two surfaces. It could be at speculative // point where the two shapes were not touching at the beginning of the time step. point: [2]f32, // Normal vector pointing from shape A to shape B normal: [2]f32, // The speed the shapes are approaching. Always positive. Typically in meters per second. approachSpeed: f32, }
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.
CosSin ¶
Cosine and sine pair This uses a custom implementation designed for cross-platform determinism
Counters ¶
Counters :: struct { bodyCount: i32, shapeCount: i32, contactCount: i32, jointCount: i32, islandCount: i32, stackUsed: i32, staticTreeHeight: i32, treeHeight: i32, byteCount: i32, taskCount: i32, colorCounts: [12]i32, }
Counters that give details of the simulation size.
CustomFilterFcn ¶
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. @see b2ShapeDef.
Notes:
- this function must be thread-safe - this is only called if one of the two shapes has enabled custom filtering
- this is called only for awake dynamic bodies Return false if you want to disable the collision @warning Do not attempt to modify the world inside this callback @ingroup world
DebugDraw ¶
DebugDraw :: struct { // Draw a closed polygon provided in CCW order. DrawPolygonFcn: proc "c" (vertices: [^][2]f32, vertexCount: i32, color: HexColor, ctx: rawptr), // Draw a solid closed polygon provided in CCW order. DrawSolidPolygonFcn: proc "c" (transform: Transform, vertices: [^][2]f32, vertexCount: i32, radius: f32, colr: HexColor, ctx: rawptr), // Draw a circle. DrawCircleFcn: proc "c" (center: [2]f32, radius: f32, color: HexColor, ctx: rawptr), // Draw a solid circle. DrawSolidCircleFcn: proc "c" (transform: Transform, radius: f32, color: HexColor, ctx: rawptr), // Draw a solid capsule. DrawSolidCapsuleFcn: proc "c" (p1, p2: [2]f32, radius: f32, color: HexColor, ctx: rawptr), // Draw a line segment. DrawSegmentFcn: proc "c" (p1, p2: [2]f32, color: HexColor, ctx: rawptr), // Draw a transform. Choose your own length scale. DrawTransformFcn: proc "c" (transform: Transform, ctx: rawptr), // Draw a point. DrawPointFcn: proc "c" (p: [2]f32, size: f32, color: HexColor, ctx: rawptr), // Draw a string in world space. DrawStringFcn: proc "c" (p: [2]f32, s: cstring, color: HexColor, ctx: rawptr), // Bounds to use if restricting drawing to a rectangular region drawingBounds: AABB, // Option to restrict drawing to a rectangular region. May suffer from unstable depth sorting. useDrawingBounds: bool, // Option to draw shapes drawShapes: bool, // Option to draw joints drawJoints: bool, // Option to draw additional information for joints drawJointExtras: bool, // Option to draw the bounding boxes for shapes drawBounds: bool, // Option to draw the mass and center of mass of dynamic bodies drawMass: bool, // Option to draw body names drawBodyNames: bool, // Option to draw contact points drawContacts: bool, // Option to visualize the graph coloring used for contacts and joints drawGraphColors: bool, // Option to draw contact normals drawContactNormals: bool, // Option to draw contact normal impulses drawContactImpulses: bool, // Option to draw contact feature ids drawContactFeatures: bool, // Option to draw contact friction impulses drawFrictionImpulses: bool, // Option to draw islands as bounding boxes drawIslands: bool, // User context that is passed as an argument to drawing callback functions userContext: rawptr, }
This struct holds callbacks you can implement to draw a Box2D world.
@ingroup world
DistanceInput ¶
DistanceInput :: struct { // The proxy for shape A proxyA: ShapeProxy, // The proxy for shape B proxyB: ShapeProxy, // The world transform for shape A transformA: Transform, // The world transform for shape B transformB: Transform, // Should the proxy radius be considered? useRadii: bool, }
Input for b2ShapeDistance
DistanceJointDef ¶
DistanceJointDef :: struct { // The first attached body bodyIdA: BodyId, // The second attached body bodyIdB: BodyId, // The local anchor point relative to bodyA's origin localAnchorA: [2]f32, // The local anchor point relative to bodyB's origin localAnchorB: [2]f32, // The rest length of this joint. Clamped to a stable minimum value. length: f32, // Enable the distance constraint to behave like a spring. If false // then the distance joint will be rigid, overriding the limit and motor. enableSpring: bool, // The spring linear stiffness Hertz, cycles per second hertz: f32, // The spring linear damping ratio, non-dimensional dampingRatio: f32, // Enable/disable the joint limit enableLimit: bool, // Minimum length. Clamped to a stable minimum value. minLength: f32, // Maximum length. Must be greater than or equal to the minimum length. maxLength: f32, // Enable/disable the joint motor enableMotor: bool, // The maximum motor force, usually in newtons maxMotorForce: f32, // The desired motor speed, usually in meters per second motorSpeed: f32, // Set this flag to true if the attached bodies should collide collideConnected: bool, // User data pointer userData: rawptr, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
Distance joint definition
This requires defining an anchor point on both bodies and the non-zero distance of the distance joint. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. This helps when saving and loading a game. @ingroup distance_joint
DistanceOutput ¶
DistanceOutput :: struct { pointA: [2]f32, // Closest point on shapeA pointB: [2]f32, // Closest point on shapeB normal: [2]f32, // Normal vector that points from A to B. Invalid if distance is zero. distance: f32, // The final distance, zero if overlapped iterations: i32, // Number of GJK iterations used simplexCount: i32, }
Output for b2ShapeDistance
DynamicTree ¶
DynamicTree :: struct { // The tree nodes nodes: rawptr, // The root index root: i32, // The number of nodes nodeCount: i32, // The allocated node space nodeCapacity: i32, // Node free list freeList: i32, // Number of proxies created proxyCount: i32, // Leaf indices for rebuild leafIndices: [^]i32, // Leaf bounding boxes for rebuild leafBoxes: [^]AABB, // Leaf bounding box centers for rebuild leafCenters: [^][2]f32, // Bins for sorting during rebuild binIndices: [^]i32, // Allocated space for rebuilding rebuildCapacity: i32, }
The dynamic tree structure. This should be considered private data. It is placed here for performance reasons.
Related Procedures With Parameters
- DynamicTree_CreateProxy
- DynamicTree_Destroy
- DynamicTree_DestroyProxy
- DynamicTree_EnlargeProxy
- DynamicTree_GetAABB
- DynamicTree_GetAreaRatio
- DynamicTree_GetByteCount
- DynamicTree_GetCategoryBits
- DynamicTree_GetHeight
- DynamicTree_GetProxyCount
- DynamicTree_GetRootBounds
- DynamicTree_GetUserData
- DynamicTree_MoveProxy
- DynamicTree_Query
- DynamicTree_RayCast
- DynamicTree_Rebuild
- DynamicTree_SetCategoryBits
- DynamicTree_ShapeCast
- DynamicTree_Validate
- DynamicTree_ValidateNoEnlarged
EnqueueTaskCallback ¶
EnqueueTaskCallback :: proc "c" (task: TaskCallback, itemCount: i32, minRange: i32, taskContext: rawptr, userContext: rawptr) -> rawptr
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 TaskCallback should obey: endIndex - startIndex >= minRange The exception of course is when itemCount < minRange. @ingroup world
ExplosionDef ¶
ExplosionDef :: struct { // / Mask bits to filter shapes maskBits: u64, // / The center of the explosion in world space position: [2]f32, // / The radius of the explosion radius: f32, // / The falloff distance beyond the radius. Impulse is reduced to zero at this distance. falloff: f32, // / Impulse per unit length. This applies an impulse according to the shape perimeter that // / is facing the explosion. Explosions only apply to circles, capsules, and polygons. This // / may be negative for implosions. impulsePerLength: f32, }
The explosion definition is used to configure options for explosions. Explosions consider shape geometry when computing the impulse. @ingroup world
Filter ¶
Filter :: struct { // The collision category bits. Normally you would just set one bit. The category bits should // represent your application object types. For example: // @code{.odin} // My_Categories :: enum u64 { // Static = 0x00000001, // Dynamic = 0x00000002, // Debris = 0x00000004, // Player = 0x00000008, // // etc // }; // @endcode // Or use a bit_set. categoryBits: u64, // The collision mask bits. This states the categories that this // shape would accept for collision. // For example, you may want your player to only collide with static objects // and other players. // @code{.odin} // maskBits = u64(My_Categories.Static | My_Categories.Player); // @endcode maskBits: u64, // Collision groups allow a certain group of objects to never collide (negative) // or always collide (positive). A group index of zero has no effect. Non-zero group filtering // always wins against the mask bits. // For example, you may want ragdolls to collide with other ragdolls but you don't want // ragdoll self-collision. In this case you would give each ragdoll a unique negative group index // and apply that group index to all shapes on the ragdoll. groupIndex: i32, }
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
Related Procedures With Returns
FilterJointDef ¶
FilterJointDef :: struct { // / The first attached body. bodyIdA: BodyId, // / The second attached body. bodyIdB: BodyId, // / User data pointer userData: rawptr, // / Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
A filter joint is used to disable collision between two specific bodies.
@ingroup filter_joint
FinishTaskCallback ¶
Finishes a user task object that wraps a Box2D task.
@ingroup world
FreeFcn ¶
FreeFcn :: proc "c" (mem: rawptr)
Prototype for user free function
@param mem the memory previously allocated through `b2AllocFcn`
FrictionCallback ¶
FrictionCallback :: proc "c" (frictionA: f32, userMaterialIdA: i32, frictionB: f32, userMaterialIdB: i32) -> f32
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
HexColor ¶
HexColor :: enum i32 { AliceBlue = 0xF0F8FF, AntiqueWhite = 0xFAEBD7, Aqua = 0x00FFFF, Aquamarine = 0x7FFFD4, Azure = 0xF0FFFF, Beige = 0xF5F5DC, Bisque = 0xFFE4C4, Black = 0x000000, BlanchedAlmond = 0xFFEBCD, Blue = 0x0000FF, BlueViolet = 0x8A2BE2, Brown = 0xA52A2A, Burlywood = 0xDEB887, CadetBlue = 0x5F9EA0, Chartreuse = 0x7FFF00, Chocolate = 0xD2691E, Coral = 0xFF7F50, CornflowerBlue = 0x6495ED, Cornsilk = 0xFFF8DC, Crimson = 0xDC143C, Cyan = 0x00FFFF, DarkBlue = 0x00008B, DarkCyan = 0x008B8B, DarkGoldenRod = 0xB8860B, DarkGray = 0xA9A9A9, DarkGreen = 0x006400, DarkKhaki = 0xBDB76B, DarkMagenta = 0x8B008B, DarkOliveGreen = 0x556B2F, DarkOrange = 0xFF8C00, DarkOrchid = 0x9932CC, DarkRed = 0x8B0000, DarkSalmon = 0xE9967A, DarkSeaGreen = 0x8FBC8F, DarkSlateBlue = 0x483D8B, DarkSlateGray = 0x2F4F4F, DarkTurquoise = 0x00CED1, DarkViolet = 0x9400D3, DeepPink = 0xFF1493, DeepSkyBlue = 0x00BFFF, DimGray = 0x696969, DodgerBlue = 0x1E90FF, FireBrick = 0xB22222, FloralWhite = 0xFFFAF0, ForestGreen = 0x228B22, Fuchsia = 0xFF00FF, Gainsboro = 0xDCDCDC, GhostWhite = 0xF8F8FF, Gold = 0xFFD700, GoldenRod = 0xDAA520, Gray = 0x808080, Green = 0x008000, GreenYellow = 0xADFF2F, HoneyDew = 0xF0FFF0, HotPink = 0xFF69B4, IndianRed = 0xCD5C5C, Indigo = 0x4B0082, Ivory = 0xFFFFF0, Khaki = 0xF0E68C, Lavender = 0xE6E6FA, LavenderBlush = 0xFFF0F5, LawnGreen = 0x7CFC00, LemonChiffon = 0xFFFACD, LightBlue = 0xADD8E6, LightCoral = 0xF08080, LightCyan = 0xE0FFFF, LightGoldenRodYellow = 0xFAFAD2, LightGray = 0xD3D3D3, LightGreen = 0x90EE90, LightPink = 0xFFB6C1, LightSalmon = 0xFFA07A, LightSeaGreen = 0x20B2AA, LightSkyBlue = 0x87CEFA, LightSlateGray = 0x778899, LightSteelBlue = 0xB0C4DE, LightYellow = 0xFFFFE0, Lime = 0x00FF00, LimeGreen = 0x32CD32, Linen = 0xFAF0E6, Magenta = 0xFF00FF, Maroon = 0x800000, MediumAquaMarine = 0x66CDAA, MediumBlue = 0x0000CD, MediumOrchid = 0xBA55D3, MediumPurple = 0x9370DB, MediumSeaGreen = 0x3CB371, MediumSlateBlue = 0x7B68EE, MediumSpringGreen = 0x00FA9A, MediumTurquoise = 0x48D1CC, MediumVioletRed = 0xC71585, MidnightBlue = 0x191970, MintCream = 0xF5FFFA, MistyRose = 0xFFE4E1, Moccasin = 0xFFE4B5, NavajoWhite = 0xFFDEAD, Navy = 0x000080, OldLace = 0xFDF5E6, Olive = 0x808000, OliveDrab = 0x6B8E23, Orange = 0xFFA500, OrangeRed = 0xFF4500, Orchid = 0xDA70D6, PaleGoldenRod = 0xEEE8AA, PaleGreen = 0x98FB98, PaleTurquoise = 0xAFEEEE, PaleVioletRed = 0xDB7093, PapayaWhip = 0xFFEFD5, PeachPuff = 0xFFDAB9, Peru = 0xCD853F, Pink = 0xFFC0CB, Plum = 0xDDA0DD, PowderBlue = 0xB0E0E6, Purple = 0x800080, RebeccaPurple = 0x663399, Red = 0xFF0000, RosyBrown = 0xBC8F8F, RoyalBlue = 0x4169E1, SaddleBrown = 0x8B4513, Salmon = 0xFA8072, SandyBrown = 0xF4A460, SeaGreen = 0x2E8B57, SeaShell = 0xFFF5EE, Sienna = 0xA0522D, Silver = 0xC0C0C0, SkyBlue = 0x87CEEB, SlateBlue = 0x6A5ACD, SlateGray = 0x708090, Snow = 0xFFFAFA, SpringGreen = 0x00FF7F, SteelBlue = 0x4682B4, Tan = 0xD2B48C, Teal = 0x008080, Thistle = 0xD8BFD8, Tomato = 0xFF6347, Turquoise = 0x40E0D0, Violet = 0xEE82EE, Wheat = 0xF5DEB3, White = 0xFFFFFF, WhiteSmoke = 0xF5F5F5, Yellow = 0xFFFF00, YellowGreen = 0x9ACD32, Box2DRed = 0xDC3132, Box2DBlue = 0x30AEBF, Box2DGreen = 0x8CC924, Box2DYellow = 0xFFEE8C, }
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
Hull ¶
Hull :: struct { // The final points of the hull points: [8][2]f32 `fmt:"v,count"`, // The number of points count: i32, }
A convex hull. Used to create convex polygons.
@warning Do not modify these values directly, instead use b2ComputeHull()
Related Procedures With Parameters
JointId ¶
/ Joint id references a joint instance. This should be treated as an opaque handle.
Related Procedures With Returns
Related Constants
JointType ¶
JointType :: enum i32 { distanceJoint, filterJoint, motorJoint, mouseJoint, prismaticJoint, revoluteJoint, weldJoint, wheelJoint, }
Joint type enumeration
This is useful because all joint types use b2JointId and sometimes you want to get the type of a joint. @ingroup joint
Manifold ¶
Manifold :: struct { // The unit normal vector in world space, points from shape A to bodyB normal: [2]f32, // Angular impulse applied for rolling resistance. N * m * s = kg * m^2 / s rollingImpulse: f32, // The manifold points, up to two are possible in 2D points: [2]ManifoldPoint, // The number of contacts points, will be 0, 1, or 2 pointCount: i32, }
A contact manifold describes the contact points between colliding shapes. @note Box2D uses speculative collision so some contact points may be separated.
Related Procedures With Returns
ManifoldPoint ¶
ManifoldPoint :: struct { // Location of the contact point in world space. Subject to precision loss at large coordinates. // @note Should only be used for debugging. point: [2]f32, // Location of the contact point relative to shapeA's origin in world space // @note When used internally to the Box2D solver, this is relative to the body center of mass. anchorA: [2]f32, // Location of the contact point relative to shapeB's origin in world space // @note When used internally to the Box2D solver, this is relative to the body center of mass. anchorB: [2]f32, // The separation of the contact point, negative if penetrating separation: f32, // The total normal impulse applied across sub-stepping and restitution. This is important // to identify speculative contact points that had an interaction in the time step. totalNormalImpulse: f32, // The friction impulse tangentImpulse: f32, // The maximum normal impulse applied during sub-stepping // todo not sure this is needed maxNormalImpulse: f32, // Relative normal velocity pre-solve. Used for hit events. If the normal impulse is // zero then there was no hit. Negative means shapes are approaching. normalVelocity: f32, // Uniquely identifies a contact point between two shapes id: u16, // Did this contact point exist the previous step? persisted: bool, }
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.
MassData ¶
MassData :: struct { // The mass of the shape, usually in kilograms. mass: f32, // The position of the shape's centroid relative to the shape's origin. center: [2]f32, // The rotational inertia of the shape about the local origin. rotationalInertia: f32, }
This holds the mass data computed for a shape.
Related Procedures With Returns
MotorJointDef ¶
MotorJointDef :: struct { // The first attached body bodyIdA: BodyId, // The second attached body bodyIdB: BodyId, // Position of bodyB minus the position of bodyA, in bodyA's frame linearOffset: [2]f32, // The bodyB angle minus bodyA angle in radians angularOffset: f32, // The maximum motor force in newtons maxForce: f32, // The maximum motor torque in newton-meters maxTorque: f32, // Position correction factor in the range [0,1] correctionFactor: f32, // Set this flag to true if the attached bodies should collide collideConnected: bool, // User data pointer userData: rawptr, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
A motor joint is used to control the relative motion between two bodies
A typical usage is to control the movement of a dynamic body with respect to the ground. @ingroup motor_joint
MouseJointDef ¶
MouseJointDef :: struct { // The first attached body. This is assumed to be static. bodyIdA: BodyId, // The second attached body. bodyIdB: BodyId, // The initial target point in world space target: [2]f32, // Stiffness in hertz hertz: f32, // Damping ratio, non-dimensional dampingRatio: f32, // Maximum force, typically in newtons maxForce: f32, // Set this flag to true if the attached bodies should collide. collideConnected: bool, // User data pointer userData: rawptr, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
A mouse joint is used to make a point on a body track a specified world point.
This a soft constraint and allows the constraint to stretch without applying huge forces. This also applies rotation constraint heuristic to improve control. @ingroup mouse_joint
OverlapResultFcn ¶
Prototype callback for overlap queries. Called for each shape found in the query. @see b2World_QueryAABB @return false to terminate the query.
@ingroup world
Related Procedures With Parameters
Plane ¶
separation = dot(normal, point) - offset
Related Procedures With Parameters
- IsValidPlane
- PlaneSeparation
- IsValid (procedure groups)
PlaneResult ¶
PlaneResult :: struct { // The collision plane between the mover and convex shape plane: Plane, // The collision point on the shape. point: [2]f32, // Did the collision register a hit? If not this plane should be ignored. hit: bool, }
/ These are the collision planes returned from b2World_CollideMover
PlaneResultFcn ¶
PlaneResultFcn :: proc "c" (shapeId: ShapeId, plane: ^PlaneResult, ctx: rawptr) -> bool
Used to collect collision planes for character movers. Return true to continue gathering planes.
PlaneSolverResult ¶
PlaneSolverResult :: struct { // The translation of the mover translation: [2]f32, // The number of iterations used by the plane solver. For diagnostics. iterationCount: i32, }
Result returned by b2SolvePlanes
Polygon ¶
Polygon :: struct { // The polygon vertices vertices: [8][2]f32 `fmt:"v,count"`, // The outward normal vectors of the polygon sides normals: [8][2]f32 `fmt:"v,count"`, // The centroid of the polygon centroid: [2]f32, // The external radius for rounded polygons radius: f32, // The number of polygon vertices count: i32, }
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 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.
Related Procedures With Parameters
Related Procedures With Returns
PreSolveFcn ¶
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:
- this function must be thread-safe - this is only called if the shape has enabled pre-solve events
- this is called only for awake dynamic bodies
- this is not called for sensors
- the supplied manifold has impulse values from the previous step Return false if you want to disable the contact this step @warning Do not attempt to modify the world inside this callback @ingroup world
PrismaticJointDef ¶
PrismaticJointDef :: struct { // The first attached body bodyIdA: BodyId, // The second attached body bodyIdB: BodyId, // The local anchor point relative to bodyA's origin localAnchorA: [2]f32, // The local anchor point relative to bodyB's origin localAnchorB: [2]f32, // The local translation unit axis in bodyA localAxisA: [2]f32, // The constrained angle between the bodies: bodyB_angle - bodyA_angle referenceAngle: f32, // The target translation for the joint in meters. The spring-damper will drive // to this translation. targetTranslation: f32, // Enable a linear spring along the prismatic joint axis enableSpring: bool, // The spring stiffness Hertz, cycles per second hertz: f32, // The spring damping ratio, non-dimensional dampingRatio: f32, // Enable/disable the joint limit enableLimit: bool, // The lower translation limit lowerTranslation: f32, // The upper translation limit upperTranslation: f32, // Enable/disable the joint motor enableMotor: bool, // The maximum motor force, typically in newtons maxMotorForce: f32, // The desired motor speed, typically in meters per second motorSpeed: f32, // Set this flag to true if the attached bodies should collide collideConnected: bool, // User data pointer userData: rawptr, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
Prismatic joint definition
This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. @ingroup prismatic_joint
Profile ¶
Profile :: struct { step: f32, pairs: f32, collide: f32, solve: f32, mergeIslands: f32, prepareStages: f32, solveConstraints: f32, prepareConstraints: f32, integrateVelocities: f32, warmStart: f32, solveImpulses: f32, integratePositions: f32, relaxImpulses: f32, applyRestitution: f32, storeImpulses: f32, splitIslands: f32, transforms: f32, hitEvents: f32, refit: f32, bullets: f32, sleepIslands: f32, sensors: f32, }
! @cond Profiling data. Times are in milliseconds.
QueryFilter ¶
QueryFilter :: struct { // The collision category bits of this query. Normally you would just set one bit. categoryBits: u64, // The collision mask bits. This states the shape categories that this // query would accept for collision. maskBits: u64, }
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
Related Procedures With Parameters
RayCastInput ¶
RayCastInput :: struct { // Start point of the ray cast origin: [2]f32, // Translation of the ray cast translation: [2]f32, // The maximum fraction of the translation to consider, typically 1 maxFraction: f32, }
Low level ray cast input data
Related Procedures With Parameters
- DynamicTree_RayCast
- IsValidRay
- RayCastCapsule
- RayCastCircle
- RayCastPolygon
- RayCastSegment
- Shape_RayCast
- IsValid (procedure groups)
RayResult ¶
RayResult :: struct { shapeId: ShapeId, point: [2]f32, normal: [2]f32, fraction: f32, nodeVisits: i32, leafVisits: i32, hit: bool, }
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
RestitutionCallback ¶
RestitutionCallback :: proc "c" (restitutionA: f32, userMaterialIdA: i32, restitutionB: f32, userMaterialIdB: i32) -> f32
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
RevoluteJointDef ¶
RevoluteJointDef :: struct { // The first attached body bodyIdA: BodyId, // The second attached body bodyIdB: BodyId, // The local anchor point relative to bodyA's origin localAnchorA: [2]f32, // The local anchor point relative to bodyB's origin localAnchorB: [2]f32, // The bodyB angle minus bodyA angle in the reference state (radians). // This defines the zero angle for the joint limit. referenceAngle: f32, // The target angle for the joint in radians. The spring-damper will drive // to this angle. targetAngle: f32, // Enable a rotational spring on the revolute hinge axis enableSpring: bool, // The spring stiffness Hertz, cycles per second hertz: f32, // The spring damping ratio, non-dimensional dampingRatio: f32, // A flag to enable joint limits enableLimit: bool, // The lower angle for the joint limit in radians. Minimum of -0.99*pi radians. lowerAngle: f32, // The upper angle for the joint limit in radians. Maximum of 0.99*pi radians. upperAngle: f32, // A flag to enable the joint motor enableMotor: bool, // The maximum motor torque, typically in newton-meters maxMotorTorque: f32, // The desired motor speed in radians per second motorSpeed: f32, // Scale the debug draw drawSize: f32, // Set this flag to true if the attached bodies should collide collideConnected: bool, // User data pointer userData: rawptr, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
Revolute joint definition
This requires defining an anchor point where the bodies are joined. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. You also need to specify the initial relative angle for joint limits. This helps when saving and loading a game. The local anchor points are measured from the body's origin rather than the center of mass because:
- you might not know where the center of mass will be
- if you add/remove shapes from a body and recompute the mass, the joints will be broken @ingroup revolute_joint
Rot ¶
Related Procedures With Parameters
- Body_SetTransform
- ComputeAngularVelocity
- IntegrateRotation
- InvMulRot
- InvRotateVector
- IsNormalizedRot
- IsValidRotation
- MakeOffsetBox
- MakeOffsetPolygon
- MakeOffsetProxy
- MakeOffsetRoundedBox
- MakeOffsetRoundedPolygon
- MulRot
- NLerp
- NormalizeRot
- RelativeAngle
- Rot_GetAngle
- Rot_GetXAxis
- Rot_GetYAxis
- RotateVector
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
SegmentDistanceResult ¶
SegmentDistanceResult :: struct { // The closest point on the first segment closest1: [2]f32, // The closest point on the second segment closest2: [2]f32, // The barycentric coordinate on the first segment fraction1: f32, // The barycentric coordinate on the second segment fraction2: f32, // The squared distance between the closest points distanceSquared: f32, }
Result of computing the distance between two line segments
SensorBeginTouchEvent ¶
SensorBeginTouchEvent :: struct { // The id of the sensor shape sensorShapeId: ShapeId, // The id of the dynamic shape that began touching the sensor shape visitorShapeId: ShapeId, }
A begin touch event is generated when a shape starts to overlap a sensor shape.
SensorEndTouchEvent ¶
SensorEndTouchEvent :: struct { // The id of the sensor shape sensorShapeId: ShapeId, // The id of the dynamic shape that began touching the sensor shape visitorShapeId: ShapeId, }
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.
SensorEvents ¶
SensorEvents :: struct { // Array of sensor begin touch events beginEvents: [^]SensorBeginTouchEvent `fmt:"v,beginCount"`, // Array of sensor end touch events endEvents: [^]SensorEndTouchEvent `fmt:"v,endCount"`, // The number of begin touch events beginCount: i32, // The number of end touch events endCount: i32, }
Sensor events are buffered in the Box2D 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
ShapeCastInput ¶
ShapeCastInput :: struct { // A generic shape proxy: ShapeProxy, // The translation of the shape cast translation: [2]f32, // The maximum fraction of the translation to consider, typically 1 maxFraction: f32, // Allow shape cast to encroach when initially touching. This only works if the radius is greater than zero. canEncroach: bool, }
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.
Related Procedures With Parameters
ShapeCastPairInput ¶
ShapeCastPairInput :: struct { proxyA: ShapeProxy, // The proxy for shape A proxyB: ShapeProxy, // The proxy for shape B transformA: Transform, // The world transform for shape A transformB: Transform, // The world transform for shape B translationB: [2]f32, // The translation of shape B maxFraction: f32, // The fraction of the translation to consider, typically 1 canEncroach: bool, }
Input parameters for b2ShapeCast
ShapeDef ¶
ShapeDef :: struct { // Use this to store application specific shape data. userData: rawptr, // The surface material for this shape. material: SurfaceMaterial, // The density, usually in kg/m^2. // This is not part of the surface material because this is for the interior, which may have // other considerations, such as being hollow. For example a wood barrel may be hollow or full of water. density: f32, // Collision filtering data. filter: Filter, // A sensor shape generates overlap events but never generates a collision response. // Sensors do not have continuous collision. Instead, use a ray or shape cast for those scenarios. // Sensors still contribute to the body mass if they have non-zero density. // @note Sensor events are disabled by default. // @see enableSensorEvents isSensor: bool, // Enable sensor events for this shape. This applies to sensors and non-sensors. False by default, even for sensors. enableSensorEvents: bool, // Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. False by default. enableContactEvents: bool, // Enable hit events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. False by default. enableHitEvents: bool, // Enable pre-solve contact events for this shape. Only applies to dynamic bodies. These are expensive // and must be carefully handled due to threading. Ignored for sensors. enablePreSolveEvents: bool, // When shapes are created they will scan the environment for collision the next time step. This can significantly slow down // static body creation when there are many static shapes. // This is flag is ignored for dynamic and kinematic shapes which always invoke contact creation. invokeContactCreation: bool, // Should the body update the mass properties when this shape is created. Default is true. updateBodyMass: bool, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
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
Related Procedures With Parameters
ShapeId ¶
/ Shape id references a shape instance. This should be treated as an opaque handle.
Related Procedures With Parameters
- Chain_GetSegments
- DestroyShape
- Shape_AreContactEventsEnabled
- Shape_AreHitEventsEnabled
- Shape_ArePreSolveEventsEnabled
- Shape_AreSensorEventsEnabled
- Shape_EnableContactEvents
- Shape_EnableHitEvents
- Shape_EnablePreSolveEvents
- Shape_EnableSensorEvents
- Shape_GetAABB
- Shape_GetBody
- Shape_GetCapsule
- Shape_GetChainSegment
- Shape_GetCircle
- Shape_GetClosestPoint
- Shape_GetContactCapacity
- Shape_GetContactData
- Shape_GetDensity
- Shape_GetFilter
- Shape_GetFriction
- Shape_GetMassData
- Shape_GetMaterial
- Shape_GetParentChain
- Shape_GetPolygon
- Shape_GetRestitution
- Shape_GetSegment
- Shape_GetSensorCapacity
- Shape_GetSensorOverlaps
- Shape_GetSurfaceMaterial
- Shape_GetType
- Shape_GetUserData
- Shape_GetWorld
- Shape_IsSensor
- Shape_IsValid
- Shape_RayCast
- Shape_SetCapsule
- Shape_SetCircle
- Shape_SetDensity
- Shape_SetFilter
- Shape_SetFriction
- Shape_SetMaterial
- Shape_SetPolygon
- Shape_SetRestitution
- Shape_SetSegment
- Shape_SetSurfaceMaterial
- Shape_SetUserData
- Shape_TestPoint
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
ShapeProxy ¶
ShapeProxy :: struct { // The point cloud points: [8][2]f32 `fmt:"v,count"`, // The number of points. Must be greater than 0. count: i32, // The external radius of the point cloud. May be zero. radius: f32, }
A distance proxy is used by the GJK algorithm. It encapsulates any shape. You can provide between 1 and MAX_POLYGON_VERTICES and a radius.
Related Procedures With Parameters
Related Procedures With Returns
ShapeType ¶
ShapeType :: enum i32 { // A circle with an offset circleShape, // A capsule is an extruded circle capsuleShape, // A line segment segmentShape, // A convex polygon polygonShape, // A line segment owned by a chain shape chainSegmentShape, }
Shape type @ingroup shape
Simplex ¶
Simplex :: struct { v1: SimplexVertex `fmt:"v,count"`, v2: SimplexVertex `fmt:"v,count"`, v3: SimplexVertex `fmt:"v,count"`, // vertices count: i32, }
Simplex from the GJK algorithm
SimplexCache ¶
SimplexCache :: struct { // The number of stored simplex points count: u16, // The cached simplex indices on shape A indexA: [3]u8 `fmt:"v,count"`, // The cached simplex indices on shape B indexB: [3]u8 `fmt:"v,count"`, }
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.
Related Procedures With Parameters
Related Constants
SimplexVertex ¶
SimplexVertex :: struct { wA: [2]f32, // support point in proxyA wB: [2]f32, // support point in proxyB w: [2]f32, // wB - wA a: f32, // barycentric coordinate for closest point indexA: i32, // wA index indexB: i32, }
Simplex vertex for debugging the GJK algorithm
SurfaceMaterial ¶
SurfaceMaterial :: struct { // The Coulomb (dry) friction coefficient, usually in the range [0,1]. friction: f32, // The coefficient of restitution (bounce) usually in the range [0,1]. // https://en.wikipedia.org/wiki/Coefficient_of_restitution restitution: f32, // The rolling resistance usually in the range [0,1]. rollingResistance: f32, // The tangent speed for conveyor belts tangentSpeed: f32, // User material identifier. This is passed with query results and to friction and restitution // combining functions. It is not used internally. userMaterialId: i32, // Custom debug draw color. customColor: u32, }
Surface materials allow chain shapes to have per segment surface properties. @ingroup shape
Related Procedures With Returns
Sweep ¶
Sweep :: struct { localCenter: [2]f32, // Local center of mass position c1: [2]f32, // Starting center of mass world position c2: [2]f32, // Ending center of mass world position q1: Rot, // Starting world rotation q2: Rot, }
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.
TOIInput ¶
TOIInput :: struct { proxyA: ShapeProxy, // The proxy for shape A proxyB: ShapeProxy, // The proxy for shape B sweepA: Sweep, // The movement of shape A sweepB: Sweep, // The movement of shape B maxFraction: f32, }
Input parameters for b2TimeOfImpact
TOIOutput ¶
Output parameters for b2TimeOfImpact.
TOIState ¶
TOIState :: enum i32 { Unknown, Failed, Overlapped, Hit, Separated, }
Describes the TOI output
TaskCallback ¶
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:
@code{.odin}
for i in startIndex ..< endIndex {
DoWork()
}
@endcode
@ingroup world
Transform ¶
Related Procedures With Parameters
- Body_SetTargetTransform
- CollideCapsuleAndCircle
- CollideCapsules
- CollideChainSegmentAndCapsule
- CollideChainSegmentAndCircle
- CollideChainSegmentAndPolygon
- CollideCircles
- CollidePolygonAndCapsule
- CollidePolygonAndCircle
- CollidePolygons
- CollideSegmentAndCapsule
- CollideSegmentAndCircle
- CollideSegmentAndPolygon
- ComputeCapsuleAABB
- ComputeCircleAABB
- ComputePolygonAABB
- ComputeSegmentAABB
- InvMulTransforms
- InvTransformPoint
- MulTransforms
- TransformPoint
- TransformPolygon
Related Procedures With Returns
Related Constants
TreeQueryCallbackFcn ¶
This function receives proxies found in the AABB query. @return true if the query should continue
TreeRayCastCallbackFcn ¶
TreeRayCastCallbackFcn :: proc "c" (#by_ptr input: RayCastInput, proxyId: i32, userData: u64, ctx: rawptr) -> f32
This function receives clipped raycast input for a proxy. The function returns the new ray fraction.
- return a value of 0 to terminate the ray cast
- return a value less than input->maxFraction to clip the ray
- return a value of input->maxFraction to continue the ray cast without clipping
TreeShapeCastCallbackFcn ¶
TreeShapeCastCallbackFcn :: proc "c" (#by_ptr input: ShapeCastInput, proxyId: i32, userData: u64, ctx: rawptr) -> f32
This function receives clipped ray cast input for a proxy. The function returns the new ray fraction.
- return a value of 0 to terminate the ray cast
- return a value less than input->maxFraction to clip the ray
- return a value of input->maxFraction to continue the ray cast without clipping
TreeStats ¶
TreeStats :: struct { // Number of internal nodes visited during the query nodeVisits: i32, // Number of leaf nodes visited during the query leafVisits: i32, }
These are performance results returned by dynamic tree queries.
Related Procedures With Returns
Vec2 ¶
Vec2 :: [2]f32
External examples raylib/box2d
Related Procedures With Parameters
- Abs
- Add
- Body_ApplyForce
- Body_ApplyForceToCenter
- Body_ApplyLinearImpulse
- Body_ApplyLinearImpulseToCenter
- Body_GetLocalPoint
- Body_GetLocalPointVelocity
- Body_GetLocalVector
- Body_GetWorldPoint
- Body_GetWorldPointVelocity
- Body_GetWorldVector
- Body_SetLinearVelocity
- Body_SetTransform
- Clamp
- ClipVector
- ComputeRotationBetweenUnitVectors
- Cross
- CrossSV
- CrossVS
- Distance
- DistanceSquared
- Dot
- GetLengthAndNormalize
- InvRotateVector
- InvTransformPoint
- IsNormalized
- IsValidVec2
- Joint_SetLocalAnchorA
- Joint_SetLocalAnchorB
- Joint_SetLocalAxisA
- LeftPerp
- Length
- LengthSquared
- Lerp
- MakeOffsetBox
- MakeOffsetPolygon
- MakeOffsetProxy
- MakeOffsetRoundedBox
- MakeOffsetRoundedPolygon
- Max
- Min
- MotorJoint_SetLinearOffset
- MouseJoint_SetTarget
- Mul
- MulAdd
- MulMV
- MulSV
- MulSub
- Neg
- Normalize
- NormalizeChecked
- PlaneSeparation
- PointInCapsule
- PointInCircle
- PointInPolygon
- RightPerp
- RotateVector
- SegmentDistance
- Shape_GetClosestPoint
- Shape_TestPoint
- Solve22
- SolvePlanes
- Sub
- TransformPoint
- World_CastMover
- World_CastRay
- World_CastRayClosest
- World_CastShape
- World_SetGravity
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
Version ¶
WeldJointDef ¶
WeldJointDef :: struct { // The first attached body bodyIdA: BodyId, // The second attached body bodyIdB: BodyId, // The local anchor point relative to bodyA's origin localAnchorA: [2]f32, // The local anchor point relative to bodyB's origin localAnchorB: [2]f32, // The bodyB angle minus bodyA angle in the reference state (radians) referenceAngle: f32, // Linear stiffness expressed as Hertz (cycles per second). Use zero for maximum stiffness. linearHertz: f32, // Angular stiffness as Hertz (cycles per second). Use zero for maximum stiffness. angularHertz: f32, // Linear damping ratio, non-dimensional. Use 1 for critical damping. linearDampingRatio: f32, // Linear damping ratio, non-dimensional. Use 1 for critical damping. angularDampingRatio: f32, // Set this flag to true if the attached bodies should collide collideConnected: bool, // User data pointer userData: rawptr, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
Weld joint definition
A weld joint connect to 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
WheelJointDef ¶
WheelJointDef :: struct { // The first attached body bodyIdA: BodyId, // The second attached body bodyIdB: BodyId, // The local anchor point relative to bodyA's origin localAnchorA: [2]f32, // The local anchor point relative to bodyB's origin localAnchorB: [2]f32, // The local translation unit axis in bodyA localAxisA: [2]f32, // Enable a linear spring along the local axis enableSpring: bool, // Spring stiffness in Hertz hertz: f32, // Spring damping ratio, non-dimensional dampingRatio: f32, // Enable/disable the joint linear limit enableLimit: bool, // The lower translation limit lowerTranslation: f32, // The upper translation limit upperTranslation: f32, // Enable/disable the joint rotational motor enableMotor: bool, // The maximum motor torque, typically in newton-meters maxMotorTorque: f32, // The desired motor speed in radians per second motorSpeed: f32, // Set this flag to true if the attached bodies should collide collideConnected: bool, // User data pointer userData: rawptr, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
Wheel joint definition
This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. @ingroup wheel_joint
WorldDef ¶
WorldDef :: struct { // Gravity vector. Box2D has no up-vector defined. gravity: [2]f32, // Restitution speed threshold, usually in m/s. Collisions above this // speed have restitution applied (will bounce). restitutionThreshold: f32, // Threshold speed for hit events. Usually meters per second. hitEventThreshold: f32, // Contact stiffness. Cycles per second. Increasing this increases the speed of overlap recovery, but can introduce jitter. contactHertz: f32, // Contact bounciness. Non-dimensional. You can speed up overlap recovery by decreasing this with // the trade-off that overlap resolution becomes more energetic. contactDampingRatio: f32, // This parameter controls how fast overlap is resolved and usually has units of meters per second. This only // puts a cap on the resolution speed. The resolution speed is increased by increasing the hertz and/or // decreasing the damping ratio. maxContactPushSpeed: f32, // Maximum linear speed. Usually meters per second. maximumLinearSpeed: f32, // Optional mixing callback for friction. The default uses sqrt(frictionA * frictionB). frictionCallback: FrictionCallback, // Optional mixing callback for restitution. The default uses max(restitutionA, restitutionB). restitutionCallback: RestitutionCallback, // Can bodies go to sleep to improve performance enableSleep: bool, // Enable continuous collision enableContinuous: bool, // Number of workers to use with the provided task system. Box2D performs best when using only // performance cores and accessing a single L2 cache. Efficiency cores and hyper-threading provide // little benefit and may even harm performance. // @note Box2D does not create threads. This is the number of threads your applications has created // that you are allocating to b2World_Step. // @warning Do not modify the default value unless you are also providing a task system and providing // task callbacks (enqueueTask and finishTask). workerCount: i32, // Function to spawn tasks enqueueTask: EnqueueTaskCallback, // Function to finish a task finishTask: FinishTaskCallback, // User context that is provided to enqueueTask and finishTask userTaskContext: rawptr, // User data userData: rawptr, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
World definition used to create a simulation world. Must be initialized using b2DefaultWorldDef(). @ingroup world
WorldId ¶
/ World id references a world instance. This should be treated as an opaque handle.
Related Procedures With Parameters
- CreateBody
- CreateDistanceJoint
- CreateFilterJoint
- CreateMotorJoint
- CreateMouseJoint
- CreatePrismaticJoint
- CreateRevoluteJoint
- CreateWeldJoint
- CreateWheelJoint
- DestroyWorld
- StoreWorldId
- World_CastMover
- World_CastRay
- World_CastRayClosest
- World_CastShape
- World_CollideMover
- World_Draw
- World_DumpMemoryStats
- World_EnableContinuous
- World_EnableSleeping
- World_EnableSpeculative
- World_EnableWarmStarting
- World_Explode
- World_GetAwakeBodyCount
- World_GetBodyEvents
- World_GetContactEvents
- World_GetCounters
- World_GetGravity
- World_GetHitEventThreshold
- World_GetMaximumLinearSpeed
- World_GetProfile
- World_GetRestitutionThreshold
- World_GetSensorEvents
- World_GetUserData
- World_IsContinuousEnabled
- World_IsSleepingEnabled
- World_IsValid
- World_IsWarmStartingEnabled
- World_OverlapAABB
- World_OverlapShape
- World_RebuildStaticTree
- World_SetContactTuning
- World_SetCustomFilterCallback
- World_SetFrictionCallback
- World_SetGravity
- World_SetHitEventThreshold
- World_SetMaximumLinearSpeed
- World_SetPreSolveCallback
- World_SetRestitutionCallback
- World_SetRestitutionThreshold
- World_SetUserData
- World_Step
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
Constants
EPSILON ¶
EPSILON :: math.F32_EPSILON
HASH_INIT ¶
HASH_INIT :: 5381
MAX_POLYGON_VERTICES ¶
MAX_POLYGON_VERTICES :: 8
The maximum number of vertices on a convex polygon. Changing this affects performance even if you
don't use more vertices.
Mat22_zero ¶
Mat22_zero: matrix[2, 2]f32 : Mat22{0, 0, 0, 0}
PI ¶
PI :: math.PI
Rot_identity ¶
Rot_identity :: Rot{1, 0}
Transform_identity ¶
Transform_identity :: Transform{{0, 0}, {1, 0}}
Vec2_zero ¶
Vec2_zero: [2]f32 : Vec2{0, 0}
emptySimplexCache ¶
emptySimplexCache :: SimplexCache{}
nullBodyId ¶
nullBodyId :: BodyId{}
nullChainId ¶
nullChainId :: ChainId{}
nullJointId ¶
nullJointId :: JointId{}
nullShapeId ¶
nullShapeId :: ShapeId{}
nullWorldId ¶
nullWorldId :: WorldId{}
/ Use these to make your identifiers null. / You may also use zero initialization to get null.
Variables
This section is empty.
Procedures
AABB_Center ¶
Get the center of the AABB.
AABB_Contains ¶
Does a fully contain b
AABB_Extents ¶
Get the extents of the AABB (half-widths).
AABB_Overlaps ¶
Do a and b overlap
AABB_Union ¶
Union of two AABBs
Abs ¶
Component-wise absolute vector
AbsFloat ¶
@(deprecated="Prefer the built-in 'abs(a)'") @(require_results) AbsFloat :: proc "c" (a: f32) -> f32 {…}
@return the absolute value of a float
AbsInt ¶
@(deprecated="Prefer the built-in 'abs(a)'") @(require_results) AbsInt :: proc "c" (a: i32) -> i32 {…}
@return the absolute value of an integer
Add ¶
@(deprecated="Prefer 'a + b'") @(require_results) Add :: proc "c" (a, b: [2]f32) -> [2]f32 {…}
Vector addition
Body_ApplyAngularImpulse ¶C · b2Body_ApplyAngularImpulseSource · box2d.odin:831
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 force,
use a force instead, which will work better with the sub-stepping solver.
Body_ApplyForce ¶C · b2Body_ApplyForceSource · box2d.odin:787
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
Body_ApplyForceToCenter ¶C · b2Body_ApplyForceToCenterSource · box2d.odin:794
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
Body_ApplyLinearImpulse ¶C · b2Body_ApplyLinearImpulseSource · box2d.odin:813
Body_ApplyLinearImpulse :: proc "c" ( bodyId: BodyId, impulse: [2]f32, point: [2]f32, wake: bool, ) ---
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.
Body_ApplyLinearImpulseToCenter ¶C · b2Body_ApplyLinearImpulseToCenterSource · box2d.odin:822
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.
Body_ApplyMassFromShapes ¶C · b2Body_ApplyMassFromShapesSource · box2d.odin:858
Body_ApplyMassFromShapes :: proc "c" (bodyId: BodyId) ---
This update 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.
Body_ApplyTorque ¶C · b2Body_ApplyTorqueSource · box2d.odin:801
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
Body_ComputeAABB ¶C · b2Body_ComputeAABBSource · box2d.odin:944
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.
Body_Disable ¶C · b2Body_DisableSource · box2d.odin:903
Body_Disable :: proc "c" (bodyId: BodyId) ---
Disable a body by removing it completely from the simulation. This is expensive.
Body_Enable ¶C · b2Body_EnableSource · box2d.odin:906
Body_Enable :: proc "c" (bodyId: BodyId) ---
Enable a body by adding it to the simulation. This is expensive.
Body_EnableContactEvents ¶C · b2Body_EnableContactEventsSource · box2d.odin:924
Enable/disable contact events on all shapes. @see b2ShapeDef::enableContactEvents @warning changing this at runtime may cause mismatched begin/end touch events
Body_EnableHitEvents ¶C · b2Body_EnableHitEventsSource · box2d.odin:928
Enable/disable hit events on all shapes
@see b2ShapeDef::enableHitEvents
Body_EnableSleep ¶C · b2Body_EnableSleepSource · box2d.odin:888
Enable or disable sleeping for this body. If sleeping is disabled the body will wake.
Body_GetAngularDamping ¶C · b2Body_GetAngularDampingSource · box2d.odin:870
Get the current angular damping.
Body_GetAngularVelocity ¶C · b2Body_GetAngularVelocitySource · box2d.odin:760
Get the angular velocity of a body in radians per second
Body_GetContactCapacity ¶C · b2Body_GetContactCapacitySource · box2d.odin:940
Get the maximum capacity required for retrieving all the touching contacts on a body
Body_GetContactData ¶
@(require_results) Body_GetContactData :: proc "c" (bodyId: BodyId, contactData: []ContactData) -> []ContactData {…}
Get the touching contact data for a body
Body_GetGravityScale ¶C · b2Body_GetGravityScaleSource · box2d.odin:877
Get the current gravity scale
Body_GetJointCount ¶C · b2Body_GetJointCountSource · box2d.odin:937
Get the number of joints on this body
Body_GetJoints ¶
@(require_results) Body_GetJoints :: proc "c" (bodyId: BodyId, jointArray: []JointId) -> []JointId {…}
Get the joint ids for all joints on this body, up to the provided capacity
@returns the joint ids stored in the user array
Body_GetLinearDamping ¶C · b2Body_GetLinearDampingSource · box2d.odin:864
Get the current linear damping.
Body_GetLinearVelocity ¶C · b2Body_GetLinearVelocitySource · box2d.odin:757
Get the linear velocity of a body's center of mass. Usually in meters per second.
Body_GetLocalCenterOfMass ¶C · b2Body_GetLocalCenterOfMassSource · box2d.odin:840
Get the center of mass position of the body in local space
Body_GetLocalPoint ¶C · b2Body_GetLocalPointSource · box2d.odin:745
Get a local point on a body given a world point
Body_GetLocalPointVelocity ¶C · b2Body_GetLocalPointVelocitySource · box2d.odin:775
Get the linear velocity of a local point attached to a body. Usually in meters per second.
Body_GetLocalVector ¶C · b2Body_GetLocalVectorSource · box2d.odin:751
Get a local vector on a body given a world vector
Body_GetMass ¶C · b2Body_GetMassSource · box2d.odin:834
Get the mass of the body, usually in kilograms
Body_GetMassData ¶C · b2Body_GetMassDataSource · box2d.odin:851
Get the mass data for a body
Body_GetName ¶C · b2Body_GetNameSource · box2d.odin:722
Get the body name. May be nil.
Body_GetPosition ¶C · b2Body_GetPositionSource · box2d.odin:731
Get the world position of a body. This is the location of the body origin.
Body_GetRotation ¶C · b2Body_GetRotationSource · box2d.odin:734
Get the world rotation of a body as a cosine/sine pair (complex number)
External examples raylib/box2d
Body_GetRotationalInertia ¶C · b2Body_GetRotationalInertiaSource · box2d.odin:837
Get the rotational inertia of the body, usually in kg*m^2
Body_GetShapeCount ¶C · b2Body_GetShapeCountSource · box2d.odin:934
Get the number of shapes on this body
Body_GetShapes ¶
@(require_results) Body_GetShapes :: proc "c" (bodyId: BodyId, shapeArray: []ShapeId) -> []ShapeId {…}
Get the shape ids for all shapes on this body, up to the provided capacity.
@returns the shape ids stored in the user array
Body_GetSleepThreshold ¶C · b2Body_GetSleepThresholdSource · box2d.odin:897
Get the sleep threshold, usually in meters per second.
Body_GetTransform ¶C · b2Body_GetTransformSource · box2d.odin:737
Get the world transform of a body.
Body_GetType ¶C · b2Body_GetTypeSource · box2d.odin:712
Get the body type: static, kinematic, or dynamic
Body_GetUserData ¶C · b2Body_GetUserDataSource · box2d.odin:728
Get the user data stored in a body
Body_GetWorld ¶C · b2Body_GetWorldSource · box2d.odin:931
Get the world that owns this body
Body_GetWorldCenterOfMass ¶C · b2Body_GetWorldCenterOfMassSource · box2d.odin:843
Get the center of mass position of the body in world space
Body_GetWorldPoint ¶C · b2Body_GetWorldPointSource · box2d.odin:748
Get a world point on a body given a local point
External examples raylib/box2d
Body_GetWorldPointVelocity ¶C · b2Body_GetWorldPointVelocitySource · box2d.odin:778
Get the linear velocity of a world point attached to a body. Usually in meters per second.
Body_GetWorldVector ¶C · b2Body_GetWorldVectorSource · box2d.odin:754
Get a world vector on a body given a local vector
Body_IsAwake ¶C · b2Body_IsAwakeSource · box2d.odin:880
@return true if this body is awake
Body_IsBullet ¶C · b2Body_IsBulletSource · box2d.odin:919
Is this body a bullet?
Body_IsEnabled ¶C · b2Body_IsEnabledSource · box2d.odin:900
Returns true if this body is enabled
Body_IsFixedRotation ¶C · b2Body_IsFixedRotationSource · box2d.odin:912
Does this body have fixed rotation?
Body_IsSleepEnabled ¶C · b2Body_IsSleepEnabledSource · box2d.odin:891
Returns true if sleeping is enabled for this body
Body_IsValid ¶C · b2Body_IsValidSource · box2d.odin:709
Body identifier validation. Can be used to detect orphaned ids. Provides validation for up to 64K allocations.
Body_SetAngularDamping ¶C · b2Body_SetAngularDampingSource · box2d.odin:867
Adjust the angular damping. Normally this is set in BodyDef before creation.
Body_SetAngularVelocity ¶C · b2Body_SetAngularVelocitySource · box2d.odin:766
Set the angular velocity of a body in radians per second
Body_SetAwake ¶C · b2Body_SetAwakeSource · box2d.odin:885
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.
Body_SetBullet ¶C · b2Body_SetBulletSource · box2d.odin:916
Set this body to be a bullet. A bullet does continuous collision detection against dynamic bodies (but not other bullets).
Body_SetFixedRotation ¶C · b2Body_SetFixedRotationSource · box2d.odin:909
Set this body to have fixed rotation. This causes the mass to be reset in all cases.
Body_SetGravityScale ¶C · b2Body_SetGravityScaleSource · box2d.odin:874
Adjust the gravity scale. Normally this is set in BodyDef before creation.
@see BodyDef::gravityScale
Body_SetLinearDamping ¶C · b2Body_SetLinearDampingSource · box2d.odin:861
Adjust the linear damping. Normally this is set in BodyDef before creation.
Body_SetLinearVelocity ¶C · b2Body_SetLinearVelocitySource · box2d.odin:763
Set the linear velocity of a body. Usually in meters per second.
Body_SetMassData ¶C · b2Body_SetMassDataSource · box2d.odin:848
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.
Body_SetName ¶C · b2Body_SetNameSource · box2d.odin:719
Set the body name. Up to 32 characters excluding 0 termination.
Body_SetSleepThreshold ¶C · b2Body_SetSleepThresholdSource · box2d.odin:894
Set the sleep threshold, usually in meters per second
Body_SetTargetTransform ¶C · b2Body_SetTargetTransformSource · box2d.odin:772
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. This will automatically wake the body if asleep.
Body_SetTransform ¶C · b2Body_SetTransformSource · box2d.odin:742
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 BodyDef::position and BodyDef::angle
Body_SetType ¶C · b2Body_SetTypeSource · box2d.odin:716
Change the body type. This is an expensive operation. This automatically updates the mass
properties regardless of the automatic mass setting.
Body_SetUserData ¶C · b2Body_SetUserDataSource · box2d.odin:725
Set the user data for a body
Chain_GetFriction ¶C · b2Chain_GetFrictionSource · box2d.odin:1222
Get the chain friction
Chain_GetMaterial ¶C · b2Chain_GetMaterialSource · box2d.odin:1236
Get the chain material
Chain_GetRestitution ¶C · b2Chain_GetRestitutionSource · box2d.odin:1229
Get the chain restitution
Chain_GetSegmentCount ¶C · b2Chain_GetSegmentCountSource · box2d.odin:1211
Get the number of segments on this chain
Chain_GetSegments ¶C · b2Chain_GetSegmentsSource · box2d.odin:1215
Chain_GetSegments :: proc "c" ( chainId: ChainId, segmentArray: [^]ShapeId, capacity: i32, ) -> i32 ---
Fill a user array with chain segment shape ids up to the specified capacity. Returns the actual number of segments returned.
Chain_GetWorld ¶C · b2Chain_GetWorldSource · box2d.odin:1208
Get the world that owns this chain shape
Chain_IsValid ¶C · b2Chain_IsValidSource · box2d.odin:1239
Chain identifier validation. Provides validation for up to 64K allocations.
Chain_SetFriction ¶C · b2Chain_SetFrictionSource · box2d.odin:1219
Set the chain friction @see b2ChainDef::friction
Chain_SetMaterial ¶C · b2Chain_SetMaterialSource · box2d.odin:1233
Set the chain material @see b2ChainDef::material
Chain_SetRestitution ¶C · b2Chain_SetRestitutionSource · box2d.odin:1226
Set the chain restitution (bounciness) @see b2ChainDef::restitution
Clamp ¶
Component-wise clamp vector v into the range [a, b]
ClampFloat ¶
@(deprecated="Prefer the built-in 'clamp(a, lower, upper)'") @(require_results) ClampFloat :: proc "c" (a, lower, upper: f32) -> f32 {…}
@return a f32 clamped between a lower and upper bound
ClampInt ¶
@(deprecated="Prefer the built-in 'clamp(a, lower, upper)'") @(require_results) ClampInt :: proc "c" (a, lower, upper: i32) -> i32 {…}
@return an integer clamped between a lower and upper bound
ClipVector ¶
@(require_results) ClipVector :: proc(vector: [2]f32, planes: []CollisionPlane) -> [2]f32 {…}
CollideCapsuleAndCircle ¶C · b2CollideCapsuleAndCircleSource · box2d.odin:357
CollideCapsuleAndCircle :: proc "c" ( #by_ptr capsuleA: Capsule, xfA: Transform, #by_ptr circleB: Circle, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between a capsule and circle
CollideCapsules ¶C · b2CollideCapsulesSource · box2d.odin:366
CollideCapsules :: proc "c" ( #by_ptr capsuleA: Capsule, xfA: Transform, #by_ptr capsuleB: Capsule, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between a capsule and circle
CollideChainSegmentAndCapsule ¶C · b2CollideChainSegmentAndCapsuleSource · box2d.odin:384
CollideChainSegmentAndCapsule :: proc "c" ( #by_ptr segmentA: ChainSegment, xfA: Transform, #by_ptr capsuleB: Capsule, xfB: Transform, cache: ^SimplexCache, ) -> Manifold ---
Compute the contact manifold between an segment and a capsule
CollideChainSegmentAndCircle ¶C · b2CollideChainSegmentAndCircleSource · box2d.odin:381
CollideChainSegmentAndCircle :: proc "c" ( #by_ptr segmentA: ChainSegment, xfA: Transform, #by_ptr circleB: Circle, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between a chain segment and a circle
CollideChainSegmentAndPolygon ¶C · b2CollideChainSegmentAndPolygonSource · box2d.odin:387
CollideChainSegmentAndPolygon :: proc "c" ( #by_ptr segmentA: ChainSegment, xfA: Transform, #by_ptr polygonB: Polygon, xfB: Transform, cache: ^SimplexCache, ) -> Manifold ---
Compute the contact manifold between a chain segment and a rounded polygon
CollideCircles ¶C · b2CollideCirclesSource · box2d.odin:354
CollideCircles :: proc "c" ( #by_ptr circleA: Circle, xfA: Transform, #by_ptr circleB: Circle, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between two circles
CollidePolygonAndCapsule ¶C · b2CollidePolygonAndCapsuleSource · box2d.odin:372
CollidePolygonAndCapsule :: proc "c" ( #by_ptr polygonA: Polygon, xfA: Transform, #by_ptr capsuleB: Capsule, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between a polygon and capsule
CollidePolygonAndCircle ¶C · b2CollidePolygonAndCircleSource · box2d.odin:363
CollidePolygonAndCircle :: proc "c" ( #by_ptr polygonA: Polygon, xfA: Transform, #by_ptr circleB: Circle, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between a polygon and a circle
CollidePolygons ¶C · b2CollidePolygonsSource · box2d.odin:375
CollidePolygons :: proc "c" ( #by_ptr polygonA: Polygon, xfA: Transform, #by_ptr polygonB: Polygon, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between two polygons
CollideSegmentAndCapsule ¶C · b2CollideSegmentAndCapsuleSource · box2d.odin:369
CollideSegmentAndCapsule :: proc "c" ( #by_ptr segmentA: Segment, xfA: Transform, #by_ptr capsuleB: Capsule, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between an segment and a capsule
CollideSegmentAndCircle ¶C · b2CollideSegmentAndCircleSource · box2d.odin:360
CollideSegmentAndCircle :: proc "c" ( #by_ptr segmentA: Segment, xfA: Transform, #by_ptr circleB: Circle, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between an segment and a circle
CollideSegmentAndPolygon ¶C · b2CollideSegmentAndPolygonSource · box2d.odin:378
CollideSegmentAndPolygon :: proc "c" ( #by_ptr segmentA: Segment, xfA: Transform, #by_ptr polygonB: Polygon, xfB: Transform, ) -> Manifold ---
Compute the contact manifold between an segment and a polygon
ComputeAngularVelocity ¶
Compute the angular velocity necessary to rotate between two rotations over a give time
@param q1 initial rotation @param q2 final rotation @param inv_h inverse time step
ComputeCapsuleAABB ¶C · b2ComputeCapsuleAABBSource · box2d.odin:228
Compute the bounding box of a transformed capsule
ComputeCapsuleMass ¶C · b2ComputeCapsuleMassSource · box2d.odin:219
Compute mass properties of a capsule
ComputeCircleAABB ¶C · b2ComputeCircleAABBSource · box2d.odin:225
Compute the bounding box of a transformed circle
ComputeCircleMass ¶C · b2ComputeCircleMassSource · box2d.odin:216
Compute mass properties of a circle
ComputeHull ¶
Compute the convex hull of a set of points. Returns an empty hull if it fails. Some failure cases:
- all points very close together
- all points on a line
- less than 3 points
- more than MAX_POLYGON_VERTICES points This welds close points and removes collinear points.
@warning Do not modify a hull once it has been computed
ComputePolygonAABB ¶C · b2ComputePolygonAABBSource · box2d.odin:231
Compute the bounding box of a transformed polygon
ComputePolygonMass ¶C · b2ComputePolygonMassSource · box2d.odin:222
Compute mass properties of a polygon
ComputeRotationBetweenUnitVectors ¶
Compute the rotation between two unit vectors
ComputeSegmentAABB ¶C · b2ComputeSegmentAABBSource · box2d.odin:234
Compute the bounding box of a transformed line segment
CreateBody ¶C · b2CreateBodySource · box2d.odin:702
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{.odin}
body_def := b2.DefaultBodyDef()
my_body_id =: b2.CreateBody(my_world_id, body_def)
@endcode
@warning This function is locked during callbacks.
External examples raylib/box2d
CreateCapsuleShape ¶C · b2CreateCapsuleShapeSource · box2d.odin:1003
CreateCapsuleShape :: proc "c" ( bodyId: BodyId, #by_ptr def: ShapeDef, capsule: ^Capsule, ) -> ShapeId ---
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
CreateChain ¶C · b2CreateChainSource · box2d.odin:1202
Create a chain shape
@see b2ChainDef for details
CreateCircleShape ¶C · b2CreateCircleShapeSource · box2d.odin:993
CreateCircleShape :: proc "c" ( bodyId: BodyId, #by_ptr def: ShapeDef, circle: ^Circle, ) -> ShapeId ---
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
CreateDistanceJoint ¶C · b2CreateDistanceJointSource · box2d.odin:1331
CreateDistanceJoint :: proc "c" (worldId: WorldId, #by_ptr def: DistanceJointDef) -> JointId ---
Create a distance joint
@see b2DistanceJointDef for details
CreateFilterJoint ¶C · b2CreateFilterJointSource · box2d.odin:1500
CreateFilterJoint :: proc "c" (worldId: WorldId, #by_ptr def: FilterJointDef) -> JointId ---
Create a filter joint. @see b2FilterJointDef for details
CreateMotorJoint ¶C · b2CreateMotorJointSource · box2d.odin:1410
CreateMotorJoint :: proc "c" (worldId: WorldId, #by_ptr def: MotorJointDef) -> JointId ---
Create a motor joint
@see b2MotorJointDef for details
CreateMouseJoint ¶C · b2CreateMouseJointSource · box2d.odin:1455
CreateMouseJoint :: proc "c" (worldId: WorldId, #by_ptr def: MouseJointDef) -> JointId ---
Create a mouse joint
@see b2MouseJointDef for details
CreatePolygonShape ¶C · b2CreatePolygonShapeSource · box2d.odin:1008
CreatePolygonShape :: proc "c" ( bodyId: BodyId, #by_ptr def: ShapeDef, polygon: ^Polygon, ) -> ShapeId ---
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
External examples raylib/box2d
CreatePrismaticJoint ¶C · b2CreatePrismaticJointSource · box2d.odin:1514
CreatePrismaticJoint :: proc "c" (worldId: WorldId, #by_ptr def: PrismaticJointDef) -> JointId ---
Create a prismatic (slider) joint.
@see b2PrismaticJointDef for details
CreateRevoluteJoint ¶C · b2CreateRevoluteJointSource · box2d.odin:1588
CreateRevoluteJoint :: proc "c" (worldId: WorldId, #by_ptr def: RevoluteJointDef) -> JointId ---
Create a revolute joint
@see b2RevoluteJointDef for details
CreateSegmentShape ¶C · b2CreateSegmentShapeSource · box2d.odin:998
CreateSegmentShape :: proc "c" ( bodyId: BodyId, #by_ptr def: ShapeDef, segment: ^Segment, ) -> ShapeId ---
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
CreateWeldJoint ¶C · b2CreateWeldJointSource · box2d.odin:1669
CreateWeldJoint :: proc "c" (worldId: WorldId, #by_ptr def: WeldJointDef) -> JointId ---
Create a weld joint
@see b2WeldJointDef for details
CreateWheelJoint ¶C · b2CreateWheelJointSource · box2d.odin:1706
CreateWheelJoint :: proc "c" (worldId: WorldId, #by_ptr def: WheelJointDef) -> JointId ---
Create a wheel joint
@see b2WheelJointDef for details
CreateWorld ¶C · b2CreateWorldSource · box2d.odin:523
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.
External examples raylib/box2d
Cross ¶
Vector cross product. In 2D this yields a scalar.
CrossSV ¶
Perform the cross product on a scalar and a vector. In 2D this produces a vector.
CrossVS ¶
Perform the cross product on a vector and a scalar. In 2D this produces a vector.
DefaultBodyDef ¶C · b2DefaultBodyDefSource · box2d.odin:115
DefaultBodyDef :: proc "c" () -> BodyDef ---
Use this to initialize your body definition @ingroup body
External examples raylib/box2d
DefaultChainDef ¶C · b2DefaultChainDefSource · box2d.odin:135
DefaultChainDef :: proc "c" () -> ChainDef ---
Use this to initialize your chain definition @ingroup shape
DefaultDebugDraw ¶C · b2DefaultDebugDrawSource · box2d.odin:175
DefaultDebugDraw :: proc "c" () -> DebugDraw ---
Use this to initialize your drawing interface. This allows you to implement a sub-set of the drawing functions.
DefaultDistanceJointDef ¶C · b2DefaultDistanceJointDefSource · box2d.odin:139
DefaultDistanceJointDef :: proc "c" () -> DistanceJointDef ---
Use this to initialize your joint definition @ingroup distance_joint
DefaultExplosionDef ¶C · b2DefaultExplosionDefSource · box2d.odin:171
DefaultExplosionDef :: proc "c" () -> ExplosionDef ---
Use this to initialize your explosion definition @ingroup world
DefaultFilter ¶C · b2DefaultFilterSource · box2d.odin:119
DefaultFilter :: proc "c" () -> Filter ---
Use this to initialize your filter @ingroup shape
DefaultFilterJointDef ¶C · b2DefaultFilterJointDefSource · box2d.odin:151
DefaultFilterJointDef :: proc "c" () -> FilterJointDef ---
Use this to initialize your joint definition @ingroup filter_joint
DefaultMotorJointDef ¶C · b2DefaultMotorJointDefSource · box2d.odin:143
DefaultMotorJointDef :: proc "c" () -> MotorJointDef ---
Use this to initialize your joint definition @ingroup motor_joint
DefaultMouseJointDef ¶C · b2DefaultMouseJointDefSource · box2d.odin:147
DefaultMouseJointDef :: proc "c" () -> MouseJointDef ---
Use this to initialize your joint definition @ingroup mouse_joint
DefaultPrismaticJointDef ¶C · b2DefaultPrismaticJointDefSource · box2d.odin:155
DefaultPrismaticJointDef :: proc "c" () -> PrismaticJointDef ---
Use this to initialize your joint definition @ingroupd prismatic_joint
DefaultQueryFilter ¶C · b2DefaultQueryFilterSource · box2d.odin:123
DefaultQueryFilter :: proc "c" () -> QueryFilter ---
Use this to initialize your query filter @ingroup shape
DefaultRevoluteJointDef ¶C · b2DefaultRevoluteJointDefSource · box2d.odin:159
DefaultRevoluteJointDef :: proc "c" () -> RevoluteJointDef ---
Use this to initialize your joint definition. @ingroup revolute_joint
DefaultShapeDef ¶C · b2DefaultShapeDefSource · box2d.odin:131
DefaultShapeDef :: proc "c" () -> ShapeDef ---
Use this to initialize your shape definition @ingroup shape
External examples raylib/box2d
DefaultSurfaceMaterial ¶C · b2DefaultSurfaceMaterialSource · box2d.odin:127
DefaultSurfaceMaterial :: proc "c" () -> SurfaceMaterial ---
Use this to initialize your surface material @ingroup shape
DefaultWeldJointDef ¶C · b2DefaultWeldJointDefSource · box2d.odin:163
DefaultWeldJointDef :: proc "c" () -> WeldJointDef ---
Use this to initialize your joint definition @ingroup weld_joint
DefaultWheelJointDef ¶C · b2DefaultWheelJointDefSource · box2d.odin:167
DefaultWheelJointDef :: proc "c" () -> WheelJointDef ---
Use this to initialize your joint definition @ingroup wheel_joint
DefaultWorldDef ¶C · b2DefaultWorldDefSource · box2d.odin:111
DefaultWorldDef :: proc "c" () -> WorldDef ---
Use this to initialize your world definition @ingroup world
External examples raylib/box2d
DestroyBody ¶C · b2DestroyBodySource · box2d.odin:706
DestroyBody :: proc "c" (bodyId: BodyId) ---
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.
DestroyChain ¶C · b2DestroyChainSource · box2d.odin:1205
DestroyChain :: proc "c" (chainId: ChainId) ---
Destroy a chain shape
DestroyJoint ¶C · b2DestroyJointSource · box2d.odin:1247
DestroyJoint :: proc "c" (jointId: JointId) ---
Destroy a joint
DestroyShape ¶C · b2DestroyShapeSource · box2d.odin:1013
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
DestroyWorld ¶C · b2DestroyWorldSource · box2d.odin:526
DestroyWorld :: proc "c" (worldId: WorldId) ---
Destroy a world
Distance ¶
Get the distance between two points
DistanceJoint_EnableLimit ¶C · b2DistanceJoint_EnableLimitSource · box2d.odin:1361
Enable joint limit. The limit only works if the joint spring is enabled. Otherwise the joint is rigid
and the limit has no effect.
DistanceJoint_EnableMotor ¶C · b2DistanceJoint_EnableMotorSource · box2d.odin:1379
Enable/disable the distance joint motor
DistanceJoint_EnableSpring ¶C · b2DistanceJoint_EnableSpringSource · box2d.odin:1342
Enable/disable the distance joint spring. When disabled the distance joint is rigid.
DistanceJoint_GetCurrentLength ¶C · b2DistanceJoint_GetCurrentLengthSource · box2d.odin:1376
Get the current length of a distance joint
DistanceJoint_GetLength ¶C · b2DistanceJoint_GetLengthSource · box2d.odin:1339
Get the rest length of a distance joint
DistanceJoint_GetMaxLength ¶C · b2DistanceJoint_GetMaxLengthSource · box2d.odin:1373
Get the distance joint maximum length
DistanceJoint_GetMaxMotorForce ¶C · b2DistanceJoint_GetMaxMotorForceSource · box2d.odin:1394
Get the distance joint maximum motor force, usually in newtons
DistanceJoint_GetMinLength ¶C · b2DistanceJoint_GetMinLengthSource · box2d.odin:1370
Get the distance joint minimum length
DistanceJoint_GetMotorForce ¶C · b2DistanceJoint_GetMotorForceSource · box2d.odin:1397
Get the distance joint current motor force, usually in newtons
DistanceJoint_GetMotorSpeed ¶C · b2DistanceJoint_GetMotorSpeedSource · box2d.odin:1388
Get the distance joint motor speed, usually in meters per second
DistanceJoint_GetSpringDampingRatio ¶C · b2DistanceJoint_GetSpringDampingRatioSource · box2d.odin:1357
Get the spring damping ratio
DistanceJoint_GetSpringHertz ¶C · b2DistanceJoint_GetSpringHertzSource · box2d.odin:1354
Get the spring Hertz
DistanceJoint_IsLimitEnabled ¶C · b2DistanceJoint_IsLimitEnabledSource · box2d.odin:1364
Is the distance joint limit enabled?
DistanceJoint_IsMotorEnabled ¶C · b2DistanceJoint_IsMotorEnabledSource · box2d.odin:1382
Is the distance joint motor enabled?
DistanceJoint_IsSpringEnabled ¶C · b2DistanceJoint_IsSpringEnabledSource · box2d.odin:1345
Is the distance joint spring enabled?
DistanceJoint_SetLength ¶C · b2DistanceJoint_SetLengthSource · box2d.odin:1336
Set the rest length of a distance joint @param jointId The id for a distance joint @param length The new distance joint length
DistanceJoint_SetLengthRange ¶C · b2DistanceJoint_SetLengthRangeSource · box2d.odin:1367
Set the minimum and maximum length parameters of a distance joint
DistanceJoint_SetMaxMotorForce ¶C · b2DistanceJoint_SetMaxMotorForceSource · box2d.odin:1391
Set the distance joint maximum motor force, usually in newtons
DistanceJoint_SetMotorSpeed ¶C · b2DistanceJoint_SetMotorSpeedSource · box2d.odin:1385
Set the distance joint motor speed, usually in meters per second
DistanceJoint_SetSpringDampingRatio ¶C · b2DistanceJoint_SetSpringDampingRatioSource · box2d.odin:1351
Set the spring damping ratio, non-dimensional
DistanceJoint_SetSpringHertz ¶C · b2DistanceJoint_SetSpringHertzSource · box2d.odin:1348
Set the spring stiffness in Hertz
DistanceSquared ¶
Get the distance squared between points
Dot ¶
Vector dot product
DynamicTree_Create ¶C · b2DynamicTree_CreateSource · box2d.odin:395
DynamicTree_Create :: proc "c" () -> DynamicTree ---
Constructing the tree initializes the node pool.
DynamicTree_CreateProxy ¶C · b2DynamicTree_CreateProxySource · box2d.odin:401
DynamicTree_CreateProxy :: proc "c" ( tree: ^DynamicTree, aabb: AABB, categoryBits: u64, userData: u64, ) -> i32 ---
Create a proxy. Provide an AABB and a userData value.
DynamicTree_Destroy ¶C · b2DynamicTree_DestroySource · box2d.odin:398
DynamicTree_Destroy :: proc "c" (tree: ^DynamicTree) ---
Destroy the tree, freeing the node pool.
DynamicTree_DestroyProxy ¶C · b2DynamicTree_DestroyProxySource · box2d.odin:404
DynamicTree_DestroyProxy :: proc "c" (tree: ^DynamicTree, proxyId: i32) ---
Destroy a proxy. This asserts if the id is invalid.
DynamicTree_EnlargeProxy ¶C · b2DynamicTree_EnlargeProxySource · box2d.odin:410
DynamicTree_EnlargeProxy :: proc "c" (tree: ^DynamicTree, proxyId: i32, aabb: AABB) ---
Enlarge a proxy and enlarge ancestors as necessary.
DynamicTree_GetAABB ¶C · b2DynamicTree_GetAABBSource · box2d.odin:472
DynamicTree_GetAABB :: proc "c" (#by_ptr tree: DynamicTree, proxyId: i32) -> AABB ---
Get the AABB of a proxy
DynamicTree_GetAreaRatio ¶C · b2DynamicTree_GetAreaRatioSource · box2d.odin:454
DynamicTree_GetAreaRatio :: proc "c" (#by_ptr tree: DynamicTree) -> f32 ---
Get the ratio of the sum of the node areas to the root area.
DynamicTree_GetByteCount ¶C · b2DynamicTree_GetByteCountSource · box2d.odin:466
DynamicTree_GetByteCount :: proc "c" (#by_ptr tree: DynamicTree) -> i32 ---
Get the number of bytes used by this tree
DynamicTree_GetCategoryBits ¶C · b2DynamicTree_GetCategoryBitsSource · box2d.odin:416
DynamicTree_GetCategoryBits :: proc "c" (tree: ^DynamicTree, proxyId: i32) ---
Get the category bits on a proxy.
DynamicTree_GetHeight ¶C · b2DynamicTree_GetHeightSource · box2d.odin:451
DynamicTree_GetHeight :: proc "c" (#by_ptr tree: DynamicTree) -> i32 ---
Get the height of the binary tree.
DynamicTree_GetProxyCount ¶C · b2DynamicTree_GetProxyCountSource · box2d.odin:460
DynamicTree_GetProxyCount :: proc "c" (#by_ptr tree: DynamicTree) -> i32 ---
Get the number of proxies created
DynamicTree_GetRootBounds ¶C · b2DynamicTree_GetRootBoundsSource · box2d.odin:457
DynamicTree_GetRootBounds :: proc "c" (#by_ptr tree: DynamicTree) -> AABB ---
Get the bounding box that contains the entire tree
DynamicTree_GetUserData ¶C · b2DynamicTree_GetUserDataSource · box2d.odin:469
DynamicTree_GetUserData :: proc "c" (#by_ptr tree: DynamicTree, proxyId: i32) -> u64 ---
Get proxy user data
DynamicTree_MoveProxy ¶C · b2DynamicTree_MoveProxySource · box2d.odin:407
DynamicTree_MoveProxy :: proc "c" (tree: ^DynamicTree, proxyId: i32, aabb: AABB) ---
Move a proxy to a new AABB by removing and reinserting into the tree.
DynamicTree_Query ¶C · b2DynamicTree_QuerySource · box2d.odin:420
DynamicTree_Query :: proc "c" ( #by_ptr tree: DynamicTree, aabb: AABB, maskBits: u64, callback: TreeQueryCallbackFcn, ctx: rawptr, ) -> TreeStats ---
Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.
@return performance data
DynamicTree_RayCast ¶C · b2DynamicTree_RayCastSource · box2d.odin:435
DynamicTree_RayCast :: proc "c" ( #by_ptr tree: DynamicTree, #by_ptr input: RayCastInput, maskBits: u64, callback: TreeRayCastCallbackFcn, ctx: rawptr, ) -> TreeStats ---
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
DynamicTree_Rebuild ¶C · b2DynamicTree_RebuildSource · box2d.odin:463
DynamicTree_Rebuild :: proc "c" (tree: ^DynamicTree, fullBuild: bool) -> i32 ---
Rebuild the tree while retaining subtrees that haven't changed. Returns the number of boxes sorted.
DynamicTree_SetCategoryBits ¶C · b2DynamicTree_SetCategoryBitsSource · box2d.odin:413
DynamicTree_SetCategoryBits :: proc "c" (tree: ^DynamicTree, proxyId: i32, categoryBits: u64) ---
Modify the category bits on a proxy. This is an expensive operation.
DynamicTree_ShapeCast ¶C · b2DynamicTree_ShapeCastSource · box2d.odin:448
DynamicTree_ShapeCast :: proc "c" ( #by_ptr tree: DynamicTree, #by_ptr input: ShapeCastInput, maskBits: u32, callback: TreeShapeCastCallbackFcn, ctx: rawptr, ) -> TreeStats ---
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
DynamicTree_Validate ¶C · b2DynamicTree_ValidateSource · box2d.odin:475
DynamicTree_Validate :: proc "c" (#by_ptr tree: DynamicTree) ---
Validate this tree. For testing.
DynamicTree_ValidateNoEnlarged ¶C · b2DynamicTree_ValidateNoEnlargedSource · box2d.odin:478
DynamicTree_ValidateNoEnlarged :: proc "c" (#by_ptr tree: DynamicTree) ---
Validate this tree has no enlarged AABBs. For testing.
GetByteCount ¶C · b2GetByteCountSource · box2d.odin:67
GetByteCount :: proc "c" () -> i32 ---
@return the total bytes allocated by Box2D
GetInverse22 ¶
Get the inverse of a 2-by-2 matrix
GetLengthUnitsPerMeter ¶C · b2GetLengthUnitsPerMeterSource · box2d.odin:104
GetLengthUnitsPerMeter :: proc "c" () -> f32 ---
Get the current length units per meter.
GetMilliseconds ¶C · b2GetMillisecondsSource · box2d.odin:77
Get the milliseconds passed from an initial tick value.
GetMillisecondsAndReset ¶C · b2GetMillisecondsAndResetSource · box2d.odin:80
Get the milliseconds passed from an initial tick value. Resets the passed in value to the current tick value.
GetSweepTransform ¶C · b2GetSweepTransformSource · box2d.odin:342
Evaluate the transform sweep at a specific time.
GetTicks ¶C · b2GetTicksSource · box2d.odin:75
GetTicks :: proc "c" () -> u64 ---
Get the absolute number of system ticks. The value is platform specific.
GetVersion ¶C · b2GetVersionSource · box2d.odin:72
GetVersion :: proc "c" () -> Version ---
Get the current version of Box2D.
Hash ¶C · b2HashSource · box2d.odin:85
Simple djb2 hash function for determinism testing.
ID_EQUALS ¶
ID_EQUALS :: proc "c" (id1, id2: $T) -> bool {…}
/ Compare two ids for equality. Doesn't work for b2WorldId.
IS_NON_NULL ¶
IS_NON_NULL :: proc "c" (id: $T) -> bool {…}
/ Macro to determine if any id is non-null.
IntegrateRotation ¶
Integration rotation from angular velocity
@param q1 initial rotation @param deltaAngle the angular displacement in radians
InvMulRot ¶
Transpose multiply two rotations: qT * r
InvMulTransforms ¶
Creates a transform that converts a local point in frame B to a local point in frame A. v2 = A.q' * (B.q * v1 + B.p - A.p) = A.q' * B.q * v1 + A.q' * (B.p - A.p)
InvRotateVector ¶
Inverse rotate a vector
InvTransformPoint ¶
Inverse transform a point (e.g. world space to local space)
IsNormalizedRot ¶
Is this rotation normalized?
IsValidAABB ¶
Is this a valid bounding box? Not Nan or infinity. Upper bound greater than or equal to lower bound.
IsValidPlane ¶
Is this a valid plane? Normal is a unit vector. Not Nan or infinity.
IsValidRay ¶C · b2IsValidRaySource · box2d.odin:183
IsValidRay :: proc "c" (#by_ptr input: RayCastInput) -> bool ---
Validate ray cast input data (NaN, etc)
Joint_GetAngularSeparation ¶C · b2Joint_GetAngularSeparationSource · box2d.odin:1313
Get the current angular separation error for this joint. Does not consider admissible movement. Usually in meters.
Joint_GetBodyA ¶C · b2Joint_GetBodyASource · box2d.odin:1256
Get body A id on a joint
Joint_GetBodyB ¶C · b2Joint_GetBodyBSource · box2d.odin:1259
Get body B id on a joint
Joint_GetCollideConnected ¶C · b2Joint_GetCollideConnectedSource · box2d.odin:1292
Is collision allowed between connected bodies?
Joint_GetConstraintForce ¶C · b2Joint_GetConstraintForceSource · box2d.odin:1304
Get the current constraint force for this joint. Usually in Newtons.
Joint_GetConstraintTorque ¶C · b2Joint_GetConstraintTorqueSource · box2d.odin:1307
Get the current constraint torque for this joint. Usually in Newton * meters.
Joint_GetConstraintTuning ¶C · b2Joint_GetConstraintTuningSource · box2d.odin:1316
Get the joint constraint tuning. Advanced feature.
Joint_GetLinearSeparation ¶C · b2Joint_GetLinearSeparationSource · box2d.odin:1310
Get the current linear separation error for this joint. Does not consider admissible movement. Usually in meters.
Joint_GetLocalAnchorA ¶C · b2Joint_GetLocalAnchorASource · box2d.odin:1268
Get the local anchor on bodyA
Joint_GetLocalAnchorB ¶C · b2Joint_GetLocalAnchorBSource · box2d.odin:1274
Get the local anchor on bodyB
Joint_GetLocalAxisA ¶C · b2Joint_GetLocalAxisASource · box2d.odin:1286
Get the local axis on bodyA (prismatic and wheel)
Joint_GetReferenceAngle ¶C · b2Joint_GetReferenceAngleSource · box2d.odin:1277
Get the joint reference angle in radians (revolute, prismatic, and weld)
Joint_GetType ¶C · b2Joint_GetTypeSource · box2d.odin:1253
Get the joint type
Joint_GetUserData ¶C · b2Joint_GetUserDataSource · box2d.odin:1298
Get the user data on a joint
Joint_GetWorld ¶C · b2Joint_GetWorldSource · box2d.odin:1262
Get the world that owns this joint
Joint_IsValid ¶C · b2Joint_IsValidSource · box2d.odin:1250
Joint identifier validation. Provides validation for up to 64K allocations.
Joint_SetCollideConnected ¶C · b2Joint_SetCollideConnectedSource · box2d.odin:1289
Toggle collision between connected bodies
Joint_SetConstraintTuning ¶C · b2Joint_SetConstraintTuningSource · box2d.odin:1322
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)
Joint_SetLocalAnchorA ¶C · b2Joint_SetLocalAnchorASource · box2d.odin:1265
Set the local anchor on bodyA
Joint_SetLocalAnchorB ¶C · b2Joint_SetLocalAnchorBSource · box2d.odin:1271
Set the local anchor on bodyB
Joint_SetLocalAxisA ¶C · b2Joint_SetLocalAxisASource · box2d.odin:1283
Set the local axis on bodyA (prismatic and wheel)
Joint_SetReferenceAngle ¶C · b2Joint_SetReferenceAngleSource · box2d.odin:1280
Set the joint reference angle in radians, must be in [-pi,pi]. (revolute, prismatic, and weld)
Joint_SetUserData ¶C · b2Joint_SetUserDataSource · box2d.odin:1295
Set the user data on a joint
Joint_WakeBodies ¶C · b2Joint_WakeBodiesSource · box2d.odin:1301
Joint_WakeBodies :: proc "c" (jointId: JointId) ---
Wake the bodies connect to this joint
LeftPerp ¶
Get a left pointing perpendicular vector. Equivalent to b2CrossSV(1, v)
Length ¶
Get the length of this vector (the norm)
LengthSquared ¶
Get the length squared of this vector
Lerp ¶
Vector linear interpolation https://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/
LoadWorldId ¶
Load a u32 into a world id.
MakeAABB ¶
Compute the bounding box of an array of circles
MakeBox ¶C · b2MakeBoxSource · box2d.odin:201
Make a box (rectangle) polygon, bypassing the need for a convex hull.
External examples raylib/box2d
MakeOffsetBox ¶C · b2MakeOffsetBoxSource · box2d.odin:207
MakeOffsetBox :: proc "c" ( halfWidth, halfHeight: f32, center: [2]f32, rotation: Rot, ) -> Polygon ---
Make an offset box, bypassing the need for a convex hull.
MakeOffsetPolygon ¶C · b2MakeOffsetPolygonSource · box2d.odin:191
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
MakeOffsetProxy ¶
@(require_results) MakeOffsetProxy :: proc "c" ( points: [][2]f32, radius: f32, position: [2]f32, rotation: Rot, ) -> ShapeProxy {…}
Make a proxy with a transform. This is a deep copy of the points.
MakeOffsetRoundedBox ¶C · b2MakeOffsetRoundedBoxSource · box2d.odin:210
MakeOffsetRoundedBox :: proc "c" ( halfWidth, halfHeight: f32, center: [2]f32, rotation: Rot, radius: f32, ) -> Polygon ---
Make an offset rounded box, bypassing the need for a convex hull.
MakeOffsetRoundedPolygon ¶C · b2MakeOffsetRoundedPolygonSource · box2d.odin:195
MakeOffsetRoundedPolygon :: proc "c" ( #by_ptr hull: Hull, position: [2]f32, rotation: Rot, radius: f32, ) -> Polygon ---
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
MakePolygon ¶C · b2MakePolygonSource · box2d.odin:187
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
MakeProxy ¶
@(require_results) MakeProxy :: proc "c" (points: [][2]f32, radius: f32) -> ShapeProxy {…}
Make a proxy for use in overlap, shape cast, and related functions. This is a deep copy of the points.
MakeRot ¶
Make a rotation using an angle in radians
MakeRoundedBox ¶C · b2MakeRoundedBoxSource · box2d.odin:204
Make a rounded box, bypassing the need for a convex hull.
MakeSquare ¶C · b2MakeSquareSource · box2d.odin:198
Make a square polygon, bypassing the need for a convex hull.
Max ¶
Component-wise maximum vector
MaxFloat ¶
@(deprecated="Prefer the built-in 'max(a, b)'") @(require_results) MaxFloat :: proc "c" (a, b: f32) -> f32 {…}
@return the maximum of two floats
MaxInt ¶
@(deprecated="Prefer the built-in 'max(a, b)'") @(require_results) MaxInt :: proc "c" (a, b: i32) -> i32 {…}
@return the maximum of two integers
Min ¶
Component-wise minimum vector
MinFloat ¶
@(deprecated="Prefer the built-in 'min(a, b)'") @(require_results) MinFloat :: proc "c" (a, b: f32) -> f32 {…}
@return the minimum of two floats
MinInt ¶
@(deprecated="Prefer the built-in 'min(a, b)'") @(require_results) MinInt :: proc "c" (a, b: i32) -> i32 {…}
@return the minimum of two integers
MotorJoint_GetAngularOffset ¶C · b2MotorJoint_GetAngularOffsetSource · box2d.odin:1423
Get the motor joint angular offset target in radians
MotorJoint_GetCorrectionFactor ¶C · b2MotorJoint_GetCorrectionFactorSource · box2d.odin:1441
Get the motor joint correction factor, usually in [0, 1]
MotorJoint_GetLinearOffset ¶C · b2MotorJoint_GetLinearOffsetSource · box2d.odin:1416
Get the motor joint linear offset target
MotorJoint_GetMaxForce ¶C · b2MotorJoint_GetMaxForceSource · box2d.odin:1429
Get the motor joint maximum force, usually in newtons
MotorJoint_GetMaxTorque ¶C · b2MotorJoint_GetMaxTorqueSource · box2d.odin:1435
Get the motor joint maximum torque, usually in newton-meters
MotorJoint_SetAngularOffset ¶C · b2MotorJoint_SetAngularOffsetSource · box2d.odin:1420
Set the motor joint angular offset target in radians. This angle will be unwound so the motor will drive along the shortest arc.
MotorJoint_SetCorrectionFactor ¶C · b2MotorJoint_SetCorrectionFactorSource · box2d.odin:1438
Set the motor joint correction factor, usually in [0, 1]
MotorJoint_SetLinearOffset ¶C · b2MotorJoint_SetLinearOffsetSource · box2d.odin:1413
Set the motor joint linear offset target
MotorJoint_SetMaxForce ¶C · b2MotorJoint_SetMaxForceSource · box2d.odin:1426
Set the motor joint maximum force, usually in newtons
MotorJoint_SetMaxTorque ¶C · b2MotorJoint_SetMaxTorqueSource · box2d.odin:1432
Set the motor joint maximum torque, usually in newton-meters
MouseJoint_GetMaxForce ¶C · b2MouseJoint_GetMaxForceSource · box2d.odin:1485
Get the mouse joint maximum force, usually in newtons
MouseJoint_GetSpringDampingRatio ¶C · b2MouseJoint_GetSpringDampingRatioSource · box2d.odin:1473
Get the mouse joint damping ratio, non-dimensional
MouseJoint_GetSpringHertz ¶C · b2MouseJoint_GetSpringHertzSource · box2d.odin:1467
Get the mouse joint spring stiffness in Hertz
MouseJoint_GetTarget ¶C · b2MouseJoint_GetTargetSource · box2d.odin:1461
Get the mouse joint target
MouseJoint_SetMaxForce ¶C · b2MouseJoint_SetMaxForceSource · box2d.odin:1482
Set the mouse joint maximum force, usually in newtons
MouseJoint_SetSpringDampingRatio ¶C · b2MouseJoint_SetSpringDampingRatioSource · box2d.odin:1470
Set the mouse joint spring damping ratio, non-dimensional
MouseJoint_SetSpringHertz ¶C · b2MouseJoint_SetSpringHertzSource · box2d.odin:1464
Set the mouse joint spring stiffness in Hertz
MouseJoint_SetTarget ¶C · b2MouseJoint_SetTargetSource · box2d.odin:1458
Set the mouse joint target
Mul ¶
@(deprecated="Prefer 'a * b'") @(require_results) Mul :: proc "c" (a, b: [2]f32) -> [2]f32 {…}
Component-wise multiplication
MulAdd ¶
@(deprecated="Prefer 'a + s * b'") @(require_results) MulAdd :: proc "c" (a: [2]f32, s: f32, b: [2]f32) -> [2]f32 {…}
a + s * b
MulMV ¶
@(deprecated="Prefer 'A * v'") @(require_results) MulMV :: proc "c" (A: matrix[2, 2]f32, v: [2]f32) -> [2]f32 {…}
Multiply a 2-by-2 matrix times a 2D vector
MulRot ¶
Multiply two rotations: q * r
MulSV ¶
@(deprecated="Prefer 's * v'") @(require_results) MulSV :: proc "c" (s: f32, v: [2]f32) -> [2]f32 {…}
Multiply a scalar and vector
MulSub ¶
@(deprecated="Prefer 'a - s * b'") @(require_results) MulSub :: proc "c" (a: [2]f32, s: f32, b: [2]f32) -> [2]f32 {…}
a - s * b
MulTransforms ¶
Multiply two transforms. If the result is applied to a point p local to frame B, the transform would first convert p to a point local to frame A, then into a point in the world frame. v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p
Neg ¶
@(deprecated="Prefer '-a'") @(require_results) Neg :: proc "c" (a: [2]f32) -> [2]f32 {…}
Vector negation
NormalizeRot ¶
Normalize rotation
PlaneSeparation ¶
Signed separation of a point from a plane
PointInCapsule ¶C · b2PointInCapsuleSource · box2d.odin:240
Test a point for overlap with a capsule in local space
PointInCircle ¶C · b2PointInCircleSource · box2d.odin:237
Test a point for overlap with a circle in local space
PointInPolygon ¶C · b2PointInPolygonSource · box2d.odin:243
Test a point for overlap with a convex polygon in local space
PrismaticJoint_EnableLimit ¶C · b2PrismaticJoint_EnableLimitSource · box2d.odin:1537
Enable/disable a prismatic joint limit
PrismaticJoint_EnableMotor ¶C · b2PrismaticJoint_EnableMotorSource · box2d.odin:1552
Enable/disable a prismatic joint motor
PrismaticJoint_EnableSpring ¶C · b2PrismaticJoint_EnableSpringSource · box2d.odin:1517
Enable/disable the joint spring.
PrismaticJoint_GetLowerLimit ¶C · b2PrismaticJoint_GetLowerLimitSource · box2d.odin:1543
Get the prismatic joint lower limit
PrismaticJoint_GetMaxMotorForce ¶C · b2PrismaticJoint_GetMaxMotorForceSource · box2d.odin:1567
Get the prismatic joint maximum motor force, usually in newtons
PrismaticJoint_GetMotorForce ¶C · b2PrismaticJoint_GetMotorForceSource · box2d.odin:1570
Get the prismatic joint current motor force, usually in newtons
PrismaticJoint_GetMotorSpeed ¶C · b2PrismaticJoint_GetMotorSpeedSource · box2d.odin:1561
Get the prismatic joint motor speed, usually in meters per second
PrismaticJoint_GetSpeed ¶C · b2PrismaticJoint_GetSpeedSource · box2d.odin:1576
Get the current joint translation speed, usually in meters per second.
PrismaticJoint_GetSpringDampingRatio ¶C · b2PrismaticJoint_GetSpringDampingRatioSource · box2d.odin:1534
Get the prismatic spring damping ratio (non-dimensional)
PrismaticJoint_GetSpringHertz ¶C · b2PrismaticJoint_GetSpringHertzSource · box2d.odin:1528
Get the prismatic joint stiffness in Hertz
PrismaticJoint_GetTargetTranslation ¶C · b2PrismaticJoint_GetTargetTranslationSource · box2d.odin:1479
Get the prismatic joint sprint target translation, usually in meters
PrismaticJoint_GetTranslation ¶C · b2PrismaticJoint_GetTranslationSource · box2d.odin:1573
Get the current joint translation, usually in meters.
PrismaticJoint_GetUpperLimit ¶C · b2PrismaticJoint_GetUpperLimitSource · box2d.odin:1546
Get the prismatic joint upper limit
PrismaticJoint_IsLimitEnabled ¶C · b2PrismaticJoint_IsLimitEnabledSource · box2d.odin:1540
Is the prismatic joint limit enabled?
PrismaticJoint_IsMotorEnabled ¶C · b2PrismaticJoint_IsMotorEnabledSource · box2d.odin:1555
Is the prismatic joint motor enabled?
PrismaticJoint_IsSpringEnabled ¶C · b2PrismaticJoint_IsSpringEnabledSource · box2d.odin:1520
Is the prismatic joint spring enabled or not?
PrismaticJoint_SetLimits ¶C · b2PrismaticJoint_SetLimitsSource · box2d.odin:1549
Set the prismatic joint limits
PrismaticJoint_SetMaxMotorForce ¶C · b2PrismaticJoint_SetMaxMotorForceSource · box2d.odin:1564
Set the prismatic joint maximum motor force, usually in newtons
PrismaticJoint_SetMotorSpeed ¶C · b2PrismaticJoint_SetMotorSpeedSource · box2d.odin:1558
Set the prismatic joint motor speed, usually in meters per second
PrismaticJoint_SetSpringDampingRatio ¶C · b2PrismaticJoint_SetSpringDampingRatioSource · box2d.odin:1531
Set the prismatic joint damping ratio (non-dimensional)
PrismaticJoint_SetSpringHertz ¶C · b2PrismaticJoint_SetSpringHertzSource · box2d.odin:1525
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.
PrismaticJoint_SetTargetTranslation ¶C · b2PrismaticJoint_SetTargetTranslationSource · box2d.odin:1476
Set the prismatic joint sprint target angle, usually in meters
RayCastCapsule ¶C · b2RayCastCapsuleSource · box2d.odin:249
RayCastCapsule :: proc "c" (#by_ptr input: RayCastInput, #by_ptr shape: Capsule) -> CastOutput ---
Ray cast versus capsule in shape local space. Initial overlap is treated as a miss.
RayCastCircle ¶C · b2RayCastCircleSource · box2d.odin:246
RayCastCircle :: proc "c" (#by_ptr input: RayCastInput, #by_ptr shape: Circle) -> CastOutput ---
Ray cast versus circle in shape local space. Initial overlap is treated as a miss.
RayCastPolygon ¶C · b2RayCastPolygonSource · box2d.odin:256
RayCastPolygon :: proc "c" (#by_ptr input: RayCastInput, #by_ptr shape: Polygon) -> CastOutput ---
Ray cast versus polygon in shape local space. Initial overlap is treated as a miss.
RayCastSegment ¶C · b2RayCastSegmentSource · box2d.odin:253
RayCastSegment :: proc "c" ( #by_ptr input: RayCastInput, #by_ptr shape: Segment, oneSided: bool, ) -> CastOutput ---
Ray cast versus segment in shape local space. Optionally treat the segment as one-sided with hits from the left side being treated as a miss.
RelativeAngle ¶
relative angle between b and a (rot_b * inv(rot_a))
RevoluteJoint_EnableLimit ¶C · b2RevoluteJoint_EnableLimitSource · box2d.odin:1619
Enable/disable the revolute joint limit
RevoluteJoint_EnableMotor ¶C · b2RevoluteJoint_EnableMotorSource · box2d.odin:1635
Enable/disable a revolute joint motor
RevoluteJoint_EnableSpring ¶C · b2RevoluteJoint_EnableSpringSource · box2d.odin:1591
Enable/disable the revolute joint spring
RevoluteJoint_GetAngle ¶C · b2RevoluteJoint_GetAngleSource · box2d.odin:1616
Get the revolute joint current angle in radians relative to the reference angle
@see b2RevoluteJointDef::referenceAngle
RevoluteJoint_GetLowerLimit ¶C · b2RevoluteJoint_GetLowerLimitSource · box2d.odin:1625
Get the revolute joint lower limit in radians
RevoluteJoint_GetMaxMotorTorque ¶C · b2RevoluteJoint_GetMaxMotorTorqueSource · box2d.odin:1653
Get the revolute joint maximum motor torque, usually in newton-meters
RevoluteJoint_GetMotorSpeed ¶C · b2RevoluteJoint_GetMotorSpeedSource · box2d.odin:1644
Get the revolute joint motor speed in radians per second
RevoluteJoint_GetMotorTorque ¶C · b2RevoluteJoint_GetMotorTorqueSource · box2d.odin:1647
Get the revolute joint current motor torque, usually in newton-meters
RevoluteJoint_GetSpringDampingRatio ¶C · b2RevoluteJoint_GetSpringDampingRatioSource · box2d.odin:1606
Get the revolute joint spring damping ratio, non-dimensional
RevoluteJoint_GetSpringHertz ¶C · b2RevoluteJoint_GetSpringHertzSource · box2d.odin:1600
Get the revolute joint spring stiffness in Hertz
RevoluteJoint_GetTargetAngle ¶C · b2RevoluteJoint_GetTargetAngleSource · box2d.odin:1612
Get the revolute joint spring target angle, radians
RevoluteJoint_GetUpperLimit ¶C · b2RevoluteJoint_GetUpperLimitSource · box2d.odin:1628
Get the revolute joint upper limit in radians
RevoluteJoint_IsLimitEnabled ¶C · b2RevoluteJoint_IsLimitEnabledSource · box2d.odin:1622
Is the revolute joint limit enabled?
RevoluteJoint_IsMotorEnabled ¶C · b2RevoluteJoint_IsMotorEnabledSource · box2d.odin:1638
Is the revolute joint motor enabled?
RevoluteJoint_IsSpringEnabled ¶C · b2RevoluteJoint_IsSpringEnabledSource · box2d.odin:1594
Is the revolute spring enabled?
RevoluteJoint_SetLimits ¶C · b2RevoluteJoint_SetLimitsSource · box2d.odin:1632
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.
RevoluteJoint_SetMaxMotorTorque ¶C · b2RevoluteJoint_SetMaxMotorTorqueSource · box2d.odin:1650
Set the revolute joint maximum motor torque, usually in newton-meters
RevoluteJoint_SetMotorSpeed ¶C · b2RevoluteJoint_SetMotorSpeedSource · box2d.odin:1641
Set the revolute joint motor speed in radians per second
RevoluteJoint_SetSpringDampingRatio ¶C · b2RevoluteJoint_SetSpringDampingRatioSource · box2d.odin:1603
Set the revolute joint spring damping ratio, non-dimensional
RevoluteJoint_SetSpringHertz ¶C · b2RevoluteJoint_SetSpringHertzSource · box2d.odin:1597
Set the revolute joint spring stiffness in Hertz
RevoluteJoint_SetTargetAngle ¶C · b2RevoluteJoint_SetTargetAngleSource · box2d.odin:1609
Set the revolute joint spring target angle, radians
RightPerp ¶
Get a right pointing perpendicular vector. Equivalent to b2CrossVS(v, 1)
Rot_GetXAxis ¶
Get the x-axis
Rot_GetYAxis ¶
Get the y-axis
RotateVector ¶
Rotate a vector
SegmentDistance ¶C · b2SegmentDistanceSource · box2d.odin:301
SegmentDistance :: proc "c" (p1, q1: [2]f32, p2, q2: [2]f32) -> SegmentDistanceResult ---
Compute the distance between two line segments, clamping at the end points if needed.
SetAllocator ¶C · b2SetAllocatorSource · box2d.odin:65
This allows the user to override the allocation functions. These should be
set during application startup.
SetAssertFcn ¶C · b2SetAssertFcnSource · box2d.odin:70
SetAssertFcn :: proc "c" (assertfcn: AssertFcn) ---
Override the default assert callback
@param assertFcn a non-null assert callback
SetLengthUnitsPerMeter ¶C · b2SetLengthUnitsPerMeterSource · box2d.odin:101
SetLengthUnitsPerMeter :: proc "c" (lengthUnits: f32) ---
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
External examples raylib/box2d
ShapeCast ¶C · b2ShapeCastSource · box2d.odin:339
ShapeCast :: proc "c" (#by_ptr input: ShapeCastPairInput) -> CastOutput ---
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.
ShapeCastCapsule ¶C · b2ShapeCastCapsuleSource · box2d.odin:262
ShapeCastCapsule :: proc "c" ( #by_ptr input: ShapeCastInput, #by_ptr shape: Capsule, ) -> CastOutput ---
Shape cast versus a capsule. Initial overlap is treated as a miss.
ShapeCastCircle ¶C · b2ShapeCastCircleSource · box2d.odin:259
ShapeCastCircle :: proc "c" ( #by_ptr input: ShapeCastInput, #by_ptr shape: Circle, ) -> CastOutput ---
Shape cast versus a circle. Initial overlap is treated as a miss.
ShapeCastPolygon ¶C · b2ShapeCastPolygonSource · box2d.odin:268
ShapeCastPolygon :: proc "c" ( #by_ptr input: ShapeCastInput, #by_ptr shape: Polygon, ) -> CastOutput ---
Shape cast versus a convex polygon. Initial overlap is treated as a miss.
ShapeCastSegment ¶C · b2ShapeCastSegmentSource · box2d.odin:265
ShapeCastSegment :: proc "c" ( #by_ptr input: ShapeCastInput, #by_ptr shape: Segment, ) -> CastOutput ---
Shape cast versus a line segment. Initial overlap is treated as a miss.
ShapeDistance ¶
@(require_results) ShapeDistance :: proc "c" ( #by_ptr input: DistanceInput, cache: ^SimplexCache, simplexes: []Simplex, ) -> DistanceOutput {…}
Compute the closest points between two shapes represented as point clouds. SimplexCache cache is input/output. On the first call set SimplexCache.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.
Shape_AreContactEventsEnabled ¶C · b2Shape_AreContactEventsEnabledSource · box2d.odin:1096
Returns true if contact events are enabled
Shape_AreHitEventsEnabled ¶C · b2Shape_AreHitEventsEnabledSource · box2d.odin:1111
Returns true if hit events are enabled
Shape_ArePreSolveEventsEnabled ¶C · b2Shape_ArePreSolveEventsEnabledSource · box2d.odin:1104
Returns true if pre-solve events are enabled
Shape_AreSensorEventsEnabled ¶C · b2Shape_AreSensorEventsEnabledSource · box2d.odin:1088
Returns true if sensor events are enabled
Shape_EnableContactEvents ¶C · b2Shape_EnableContactEventsSource · box2d.odin:1093
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
Shape_EnableHitEvents ¶C · b2Shape_EnableHitEventsSource · box2d.odin:1108
Enable contact hit events for this shape. Ignored for sensors.
@see WorldDef.hitEventThreshold
Shape_EnablePreSolveEvents ¶C · b2Shape_EnablePreSolveEventsSource · box2d.odin:1101
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
Shape_EnableSensorEvents ¶C · b2Shape_EnableSensorEventsSource · box2d.odin:1085
Enable sensor events for this shape.
@see b2ShapeDef::enableSensorEvents
Shape_GetAABB ¶C · b2Shape_GetAABBSource · box2d.odin:1176
Get the current world AABB
Shape_GetBody ¶C · b2Shape_GetBodySource · box2d.odin:1022
Get the id of the body that a shape is attached to
Shape_GetCapsule ¶C · b2Shape_GetCapsuleSource · box2d.odin:1130
Get a copy of the shape's capsule. Asserts the type is correct.
Shape_GetChainSegment ¶C · b2Shape_GetChainSegmentSource · box2d.odin:1127
Shape_GetChainSegment :: proc "c" (shapeId: ShapeId) -> ChainSegment ---
Get a copy of the shape's chain segment. These come from chain shapes. Asserts the type is correct.
Shape_GetCircle ¶C · b2Shape_GetCircleSource · box2d.odin:1120
Get a copy of the shape's circle. Asserts the type is correct.
Shape_GetClosestPoint ¶C · b2Shape_GetClosestPointSource · box2d.odin:1182
Get the closest point on a shape to a target point. Target and result are in world space.
Shape_GetContactCapacity ¶C · b2Shape_GetContactCapacitySource · box2d.odin:1158
Get the maximum capacity required for retrieving all the touching contacts on a shape
Shape_GetContactData ¶
@(require_results) Shape_GetContactData :: proc "c" ( shapeId: ShapeId, contactData: []ContactData, ) -> []ContactData {…}
Get the touching contact data for a shape. The provided shapeId will be either shapeIdA or shapeIdB on the contact data.
Shape_GetDensity ¶C · b2Shape_GetDensitySource · box2d.odin:1045
Get the density of a shape, usually in kg/m^2
Shape_GetFilter ¶C · b2Shape_GetFilterSource · box2d.odin:1075
Get the shape filter
Shape_GetFriction ¶C · b2Shape_GetFrictionSource · box2d.odin:1052
Get the friction of a shape
Shape_GetMassData ¶C · b2Shape_GetMassDataSource · box2d.odin:1179
Get the mass data of a shape
Shape_GetMaterial ¶C · b2Shape_GetMaterialSource · box2d.odin:1066
Get the shape material identifier
Shape_GetParentChain ¶C · b2Shape_GetParentChainSource · box2d.odin:1155
Get the parent chain id if the shape type is a chain segment, otherwise returns b2_nullChainId.
Shape_GetPolygon ¶C · b2Shape_GetPolygonSource · box2d.odin:1133
Get a copy of the shape's convex polygon. Asserts the type is correct.
Shape_GetRestitution ¶C · b2Shape_GetRestitutionSource · box2d.odin:1059
Get the shape restitution
Shape_GetSegment ¶C · b2Shape_GetSegmentSource · box2d.odin:1123
Get a copy of the shape's line segment. Asserts the type is correct.
Shape_GetSensorCapacity ¶C · b2Shape_GetSensorCapacitySource · box2d.odin:1164
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
Shape_GetSensorOverlaps ¶C · b2Shape_GetSensorOverlapsSource · box2d.odin:1173
Shape_GetSensorOverlaps :: proc "c" ( shapeId: ShapeId, overlaps: [^]ShapeId, capacity: i32, ) -> i32 ---
Get the overlapped shapes for a sensor shape. @param shapeId the id of a sensor shape @param overlaps a user allocated array that is filled with the overlapping shapes @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
Shape_GetSurfaceMaterial ¶C · b2Shape_GetSurfaceMaterialSource · box2d.odin:1072
Shape_GetSurfaceMaterial :: proc "c" (shapeId: ShapeId) -> SurfaceMaterial ---
Get the shape surface material
Shape_GetType ¶C · b2Shape_GetTypeSource · box2d.odin:1019
Get the type of a shape
Shape_GetUserData ¶C · b2Shape_GetUserDataSource · box2d.odin:1037
Get the user data for a shape. This is useful when you get a shape id
from an event or query.
Shape_GetWorld ¶C · b2Shape_GetWorldSource · box2d.odin:1025
Get the world that owns this shape.
Shape_IsSensor ¶C · b2Shape_IsSensorSource · box2d.odin:1030
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.
Shape_IsValid ¶C · b2Shape_IsValidSource · box2d.odin:1016
Shape identifier validation. Provides validation for up to 64K allocations.
Shape_RayCast ¶C · b2Shape_RayCastSource · box2d.odin:1117
Shape_RayCast :: proc "c" (shapeId: ShapeId, #by_ptr input: RayCastInput) -> CastOutput ---
Ray cast a shape directly
Shape_SetCapsule ¶C · b2Shape_SetCapsuleSource · box2d.odin:1143
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
Shape_SetCircle ¶C · b2Shape_SetCircleSource · box2d.odin:1138
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
Shape_SetDensity ¶C · b2Shape_SetDensitySource · box2d.odin:1042
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
Shape_SetFilter ¶C · b2Shape_SetFilterSource · box2d.odin:1081
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
Shape_SetFriction ¶C · b2Shape_SetFrictionSource · box2d.odin:1049
Set the friction on a shape
@see b2ShapeDef::friction
Shape_SetMaterial ¶C · b2Shape_SetMaterialSource · box2d.odin:1063
Set the shape material identifier @see b2ShapeDef::material
Shape_SetPolygon ¶C · b2Shape_SetPolygonSource · box2d.odin:1151
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
Shape_SetRestitution ¶C · b2Shape_SetRestitutionSource · box2d.odin:1056
Set the shape restitution (bounciness)
@see b2ShapeDef::restitution
Shape_SetSegment ¶C · b2Shape_SetSegmentSource · box2d.odin:1146
Allows you to change a shape to be a segment or update the current segment.
Shape_SetSurfaceMaterial ¶C · b2Shape_SetSurfaceMaterialSource · box2d.odin:1069
Shape_SetSurfaceMaterial :: proc "c" (shapeId: ShapeId, surfaceMaterial: SurfaceMaterial) ---
Set the shape surface material
Shape_SetUserData ¶C · b2Shape_SetUserDataSource · box2d.odin:1033
Set the user data for a shape
Shape_TestPoint ¶C · b2Shape_TestPointSource · box2d.odin:1114
Test a point for overlap with a shape
Solve22 ¶
Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse in one-shot cases.
SolvePlanes ¶
@(require_results) SolvePlanes :: proc(targetDelta: [2]f32, planes: []CollisionPlane) -> PlaneSolverResult {…}
StoreWorldId ¶
Store a world id into a u32.
Sub ¶
@(deprecated="Prefer 'a - b'") @(require_results) Sub :: proc "c" (a, b: [2]f32) -> [2]f32 {…}
Vector subtraction
TimeOfImpact ¶C · b2TimeOfImpactSource · box2d.odin:348
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.
TransformPoint ¶
Transform a point (e.g. local space to world space)
TransformPolygon ¶C · b2TransformPolygonSource · box2d.odin:213
Transform a polygon. This is useful for transferring a shape from one body to another.
UnwindAngle ¶
Convert any angle into the range [-pi, pi]
ValidateHull ¶C · b2ValidateHullSource · box2d.odin:295
This determines if a hull is valid. Checks for:
- convexity
- collinear points This is expensive and should not be called at runtime.
WeldJoint_GetAngularDampingRatio ¶C · b2WeldJoint_GetAngularDampingRatioSource · box2d.odin:1693
Get the weld joint angular damping ratio, non-dimensional
WeldJoint_GetAngularHertz ¶C · b2WeldJoint_GetAngularHertzSource · box2d.odin:1687
Get the weld joint angular stiffness in Hertz
WeldJoint_GetLinearDampingRatio ¶C · b2WeldJoint_GetLinearDampingRatioSource · box2d.odin:1681
Get the weld joint linear damping ratio (non-dimensional)
WeldJoint_GetLinearHertz ¶C · b2WeldJoint_GetLinearHertzSource · box2d.odin:1675
Get the weld joint linear stiffness in Hertz
WeldJoint_SetAngularDampingRatio ¶C · b2WeldJoint_SetAngularDampingRatioSource · box2d.odin:1690
Set weld joint angular damping ratio, non-dimensional
WeldJoint_SetAngularHertz ¶C · b2WeldJoint_SetAngularHertzSource · box2d.odin:1684
Set the weld joint angular stiffness in Hertz. 0 is rigid.
WeldJoint_SetLinearDampingRatio ¶C · b2WeldJoint_SetLinearDampingRatioSource · box2d.odin:1678
Set the weld joint linear damping ratio (non-dimensional)
WeldJoint_SetLinearHertz ¶C · b2WeldJoint_SetLinearHertzSource · box2d.odin:1672
Set the weld joint linear stiffness in Hertz. 0 is rigid.
WheelJoint_EnableLimit ¶C · b2WheelJoint_EnableLimitSource · box2d.odin:1727
Enable/disable the wheel joint limit
WheelJoint_EnableMotor ¶C · b2WheelJoint_EnableMotorSource · box2d.odin:1742
Enable/disable the wheel joint motor
WheelJoint_EnableSpring ¶C · b2WheelJoint_EnableSpringSource · box2d.odin:1709
Enable/disable the wheel joint spring
WheelJoint_GetLowerLimit ¶C · b2WheelJoint_GetLowerLimitSource · box2d.odin:1733
Get the wheel joint lower limit
WheelJoint_GetMaxMotorTorque ¶C · b2WheelJoint_GetMaxMotorTorqueSource · box2d.odin:1757
Get the wheel joint maximum motor torque, usually in newton-meters
WheelJoint_GetMotorSpeed ¶C · b2WheelJoint_GetMotorSpeedSource · box2d.odin:1751
Get the wheel joint motor speed in radians per second
WheelJoint_GetMotorTorque ¶C · b2WheelJoint_GetMotorTorqueSource · box2d.odin:1760
Get the wheel joint current motor torque, usually in newton-meters
WheelJoint_GetSpringDampingRatio ¶C · b2WheelJoint_GetSpringDampingRatioSource · box2d.odin:1724
Get the wheel joint damping ratio, non-dimensional
WheelJoint_GetSpringHertz ¶C · b2WheelJoint_GetSpringHertzSource · box2d.odin:1718
Get the wheel joint stiffness in Hertz
WheelJoint_GetUpperLimit ¶C · b2WheelJoint_GetUpperLimitSource · box2d.odin:1736
Get the wheel joint upper limit
WheelJoint_IsLimitEnabled ¶C · b2WheelJoint_IsLimitEnabledSource · box2d.odin:1730
Is the wheel joint limit enabled?
WheelJoint_IsMotorEnabled ¶C · b2WheelJoint_IsMotorEnabledSource · box2d.odin:1745
Is the wheel joint motor enabled?
WheelJoint_IsSpringEnabled ¶C · b2WheelJoint_IsSpringEnabledSource · box2d.odin:1712
Is the wheel joint spring enabled?
WheelJoint_SetLimits ¶C · b2WheelJoint_SetLimitsSource · box2d.odin:1739
Set the wheel joint limits
WheelJoint_SetMaxMotorTorque ¶C · b2WheelJoint_SetMaxMotorTorqueSource · box2d.odin:1754
Set the wheel joint maximum motor torque, usually in newton-meters
WheelJoint_SetMotorSpeed ¶C · b2WheelJoint_SetMotorSpeedSource · box2d.odin:1748
Set the wheel joint motor speed in radians per second
WheelJoint_SetSpringDampingRatio ¶C · b2WheelJoint_SetSpringDampingRatioSource · box2d.odin:1721
Set the wheel joint damping ratio, non-dimensional
WheelJoint_SetSpringHertz ¶C · b2WheelJoint_SetSpringHertzSource · box2d.odin:1715
Set the wheel joint stiffness in Hertz
World_CastMover ¶C · b2World_CastMoverSource · box2d.odin:577
World_CastMover :: proc "c" ( worldId: WorldId, #by_ptr mover: Capsule, translation: [2]f32, filter: QueryFilter, ) -> f32 ---
Cast a capsule mover through the world. This is a special shape cast that handles sliding along other shapes while reducing clipping.
World_CastRay ¶C · b2World_CastRaySource · box2d.odin:565
World_CastRay :: proc "c" ( worldId: WorldId, origin: [2]f32, translation: [2]f32, filter: QueryFilter, fcn: CastResultFcn, ctx: rawptr, ) -> TreeStats ---
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
World_CastRayClosest ¶C · b2World_CastRayClosestSource · box2d.odin:569
World_CastRayClosest :: proc "c" ( worldId: WorldId, origin: [2]f32, translation: [2]f32, filter: QueryFilter, ) -> RayResult ---
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.
World_CastShape ¶C · b2World_CastShapeSource · box2d.odin:573
World_CastShape :: proc "c" ( worldId: WorldId, #by_ptr shape: ShapeProxy, translation: [2]f32, filter: QueryFilter, fcn: CastResultFcn, ctx: rawptr, ) -> TreeStats ---
Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a point. @see World_CastRay
World_CollideMover ¶C · b2World_CollideMoverSource · box2d.odin:581
World_CollideMover :: proc "c" ( worldId: WorldId, #by_ptr mover: Capsule, filter: QueryFilter, fcn: PlaneResultFcn, ctx: rawptr, ) ---
Collide a capsule mover with the world, gathering collision planes that can be fed to b2SolvePlanes. Useful for kinematic character movement.
World_Draw ¶C · b2World_DrawSource · box2d.odin:538
Call this to draw shapes and other debug draw data
World_DumpMemoryStats ¶C · b2World_DumpMemoryStatsSource · box2d.odin:678
World_DumpMemoryStats :: proc "c" (worldId: WorldId) ---
Dump memory stats to box2d_memory.txt
World_EnableContinuous ¶C · b2World_EnableContinuousSource · box2d.odin:595
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 WorldDef
World_EnableSleeping ¶C · b2World_EnableSleepingSource · box2d.odin:586
Enable/disable sleep. If your application does not need sleeping, you can gain some performance
by disabling sleep completely at the world level. @see WorldDef
World_EnableSpeculative ¶C · b2World_EnableSpeculativeSource · box2d.odin:684
This is for internal testing
World_EnableWarmStarting ¶C · b2World_EnableWarmStartingSource · box2d.odin:651
Enable/disable constraint warm starting. Advanced feature for testing. Disabling
warm starting greatly reduces stability and provides no performance gain.
World_Explode ¶C · b2World_ExplodeSource · box2d.odin:633
World_Explode :: proc "c" (worldId: WorldId, #by_ptr explosionDef: ExplosionDef) ---
Apply a radial explosion
@param worldId The world id @param explosionDef The explosion definition
World_GetAwakeBodyCount ¶C · b2World_GetAwakeBodyCountSource · box2d.odin:657
Get the number of awake bodies.
World_GetBodyEvents ¶C · b2World_GetBodyEventsSource · box2d.odin:541
World_GetBodyEvents :: proc "c" (worldId: WorldId) -> BodyEvents ---
Get the body events for the current time step. The event data is transient. Do not store a reference to this data.
World_GetContactEvents ¶C · b2World_GetContactEventsSource · box2d.odin:547
World_GetContactEvents :: proc "c" (worldId: WorldId) -> ContactEvents ---
Get contact events for this current time step. The event data is transient. Do not store a reference to this data.
World_GetCounters ¶C · b2World_GetCountersSource · box2d.odin:663
Get world counters and sizes
World_GetGravity ¶C · b2World_GetGravitySource · box2d.odin:628
Get the gravity vector
World_GetHitEventThreshold ¶C · b2World_GetHitEventThresholdSource · box2d.odin:614
Get the hit event speed threshold. Usually in meters per second.
World_GetMaximumLinearSpeed ¶C · b2World_GetMaximumLinearSpeedSource · box2d.odin:647
Get the maximum linear speed. Usually in m/s.
World_GetProfile ¶C · b2World_GetProfileSource · box2d.odin:660
Get the current world performance profile
World_GetRestitutionThreshold ¶C · b2World_GetRestitutionThresholdSource · box2d.odin:606
Get the restitution speed threshold. Usually in meters per second.
World_GetSensorEvents ¶C · b2World_GetSensorEventsSource · box2d.odin:544
World_GetSensorEvents :: proc "c" (worldId: WorldId) -> SensorEvents ---
Get sensor events for the current time step. The event data is transient. Do not store a reference to this data.
World_GetUserData ¶C · b2World_GetUserDataSource · box2d.odin:669
Get the user data pointer.
World_IsContinuousEnabled ¶C · b2World_IsContinuousEnabledSource · box2d.odin:598
Is continuous collision enabled?
World_IsSleepingEnabled ¶C · b2World_IsSleepingEnabledSource · box2d.odin:589
Is body sleeping enabled?
World_IsValid ¶C · b2World_IsValidSource · box2d.odin:529
World id validation. Provides validation for up to 64K allocations.
World_IsWarmStartingEnabled ¶C · b2World_IsWarmStartingEnabledSource · box2d.odin:654
Is constraint warm starting enabled?
World_OverlapAABB ¶C · b2World_OverlapAABBSource · box2d.odin:550
World_OverlapAABB :: proc "c" ( worldId: WorldId, aabb: AABB, filter: QueryFilter, fcn: OverlapResultFcn, ctx: rawptr, ) -> TreeStats ---
Overlap test for all shapes that potentially overlap the provided AABB
World_OverlapShape ¶C · b2World_OverlapShapeSource · box2d.odin:553
World_OverlapShape :: proc "c" ( worldId: WorldId, #by_ptr proxy: ShapeProxy, filter: QueryFilter, fcn: OverlapResultFcn, ctx: rawptr, ) -> TreeStats ---
Overlap test for all shapes that overlap the provided shape proxy.
World_RebuildStaticTree ¶C · b2World_RebuildStaticTreeSource · box2d.odin:681
World_RebuildStaticTree :: proc "c" (worldId: WorldId) ---
This is for internal testing
World_SetContactTuning ¶C · b2World_SetContactTuningSource · box2d.odin:641
World_SetContactTuning :: proc "c" ( worldId: WorldId, hertz: f32, dampingRatio: f32, pushSpeed: f32, ) ---
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
World_SetCustomFilterCallback ¶C · b2World_SetCustomFilterCallbackSource · box2d.odin:617
World_SetCustomFilterCallback :: proc "c" ( worldId: WorldId, fcn: CustomFilterFcn, ctx: rawptr, ) ---
Register the custom filter callback. This is optional.
World_SetFrictionCallback ¶C · b2World_SetFrictionCallbackSource · box2d.odin:672
World_SetFrictionCallback :: proc "c" (worldId: WorldId, callback: FrictionCallback) ---
Set the friction callback. Passing nil resets to default.
World_SetGravity ¶C · b2World_SetGravitySource · box2d.odin:625
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 WorldDef
World_SetHitEventThreshold ¶C · b2World_SetHitEventThresholdSource · box2d.odin:611
Adjust the hit event threshold. This controls the collision velocity needed to generate a b2ContactHitEvent. Usually in meters per second.
@see WorldDef::hitEventThreshold
World_SetMaximumLinearSpeed ¶C · b2World_SetMaximumLinearSpeedSource · box2d.odin:644
Set the maximum linear speed. Usually in m/s.
World_SetPreSolveCallback ¶C · b2World_SetPreSolveCallbackSource · box2d.odin:620
World_SetPreSolveCallback :: proc "c" (worldId: WorldId, fcn: PreSolveFcn, ctx: rawptr) ---
Register the pre-solve callback. This is optional.
World_SetRestitutionCallback ¶C · b2World_SetRestitutionCallbackSource · box2d.odin:675
World_SetRestitutionCallback :: proc "c" (worldId: WorldId, callback: RestitutionCallback) ---
Set the restitution callback. Passing nil resets to default.
World_SetRestitutionThreshold ¶C · b2World_SetRestitutionThresholdSource · box2d.odin:603
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 WorldDef
World_SetUserData ¶C · b2World_SetUserDataSource · box2d.odin:666
Set the user data pointer.
World_Step ¶C · b2World_StepSource · box2d.odin:535
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.
External examples raylib/box2d
b2SpringDamper ¶
@(require_results) b2SpringDamper :: proc "c" (hertz, dampingRatio, position, velocity, timeStep: f32) -> f32 {…}
One-dimensional mass-spring-damper simulation. Returns the new velocity given the position and time step. You can then compute the new position using: position += timeStep * newVelocity This drives towards a zero position. By using implicit integration we get a stable solution that doesn't require transcendental functions.
Procedure Groups
Source Files
Generation Information
Generated with odin version dev-2026-10 (vendor "odin") Windows_amd64 @ 2026-10-12 23:22:57.846843600 +0000 UTC