package vendor:box2d
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 (473)
- AABB_Center
- AABB_Contains
- AABB_Extents
- AABB_Union
- Abs
- AbsFloat
- AbsInt
- Add
- Atan2
- 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_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
- Chain_GetFriction
- Chain_GetMaterial
- Chain_GetRestitution
- Chain_GetSegmentCount
- Chain_GetSegments
- Chain_GetWorld
- Chain_IsValid
- Chain_SetFriction
- Chain_SetMaterial
- Chain_SetRestitution
- Clamp
- ClampFloat
- ClampInt
- 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_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_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
- GetWorldPointVelocity
- Hash
- ID_EQUALS
- IS_NON_NULL
- IS_NULL
- IntegrateRotation
- InvMulRot
- InvMulTransforms
- InvRotateVector
- InvTransformPoint
- IsNormalized
- IsNormalizedRot
- IsValidAABB
- IsValidFloat
- IsValidPlane
- IsValidRay
- IsValidRotation
- IsValidVec2
- Joint_GetBodyA
- Joint_GetBodyB
- Joint_GetCollideConnected
- Joint_GetConstraintForce
- Joint_GetConstraintTorque
- Joint_GetLocalAnchorA
- Joint_GetLocalAnchorB
- Joint_GetType
- Joint_GetUserData
- Joint_GetWorld
- Joint_IsValid
- Joint_SetCollideConnected
- Joint_SetUserData
- Joint_WakeBodies
- LeftPerp
- Length
- LengthSquared
- Lerp
- MakeAABB
- MakeBox
- MakeOffsetBox
- MakeOffsetPolygon
- MakeOffsetProxy
- MakeOffsetRoundedBox
- MakeOffsetRoundedPolygon
- MakePolygon
- MakeProxy
- MakeRot
- MakeRoundedBox
- MakeSquare
- Max
- MaxFloat
- MaxInt
- Min
- MinFloat
- MinInt
- MotorJoint_GetAngularOffset
- MotorJoint_GetCorrectionFactor
- MotorJoint_GetLinearOffset
- MotorJoint_GetMaxForce
- MotorJoint_GetMaxTorque
- MotorJoint_SetAngularOffset
- MotorJoint_SetCorrectionFactor
- MotorJoint_SetLinearOffset
- MotorJoint_SetMaxForce
- MotorJoint_SetMaxTorque
- MouseJoint_GetMaxForce
- MouseJoint_GetSpringDampingRatio
- MouseJoint_GetSpringHertz
- MouseJoint_GetTarget
- MouseJoint_SetMaxForce
- MouseJoint_SetSpringDampingRatio
- MouseJoint_SetSpringHertz
- MouseJoint_SetTarget
- Mul
- MulAdd
- MulMV
- MulRot
- MulSV
- MulSub
- MulTransforms
- NLerp
- Neg
- Normalize
- NormalizeChecked
- NormalizeRot
- PlaneSeparation
- PointInCapsule
- PointInCircle
- PointInPolygon
- PrismaticJoint_EnableLimit
- PrismaticJoint_EnableMotor
- PrismaticJoint_EnableSpring
- PrismaticJoint_GetLowerLimit
- PrismaticJoint_GetMaxMotorForce
- PrismaticJoint_GetMotorForce
- PrismaticJoint_GetMotorSpeed
- PrismaticJoint_GetSpeed
- PrismaticJoint_GetSpringDampingRatio
- PrismaticJoint_GetSpringHertz
- PrismaticJoint_GetTranslation
- PrismaticJoint_GetUpperLimit
- PrismaticJoint_IsLimitEnabled
- PrismaticJoint_IsMotorEnabled
- PrismaticJoint_IsSpringEnabled
- PrismaticJoint_SetLimits
- PrismaticJoint_SetMaxMotorForce
- PrismaticJoint_SetMotorSpeed
- PrismaticJoint_SetSpringDampingRatio
- PrismaticJoint_SetSpringHertz
- RayCastCapsule
- RayCastCircle
- RayCastPolygon
- RayCastSegment
- RelativeAngle
- RevoluteJoint_EnableLimit
- RevoluteJoint_EnableMotor
- RevoluteJoint_EnableSpring
- RevoluteJoint_GetAngle
- RevoluteJoint_GetLowerLimit
- RevoluteJoint_GetMaxMotorTorque
- RevoluteJoint_GetMotorSpeed
- RevoluteJoint_GetMotorTorque
- RevoluteJoint_GetSpringDampingRatio
- RevoluteJoint_GetSpringHertz
- RevoluteJoint_GetUpperLimit
- RevoluteJoint_IsLimitEnabled
- RevoluteJoint_IsMotorEnabled
- RevoluteJoint_IsSpringEnabled
- RevoluteJoint_SetLimits
- RevoluteJoint_SetMaxMotorTorque
- RevoluteJoint_SetMotorSpeed
- RevoluteJoint_SetSpringDampingRatio
- RevoluteJoint_SetSpringHertz
- RightPerp
- Rot_GetAngle
- Rot_GetXAxis
- Rot_GetYAxis
- RotateVector
- SegmentDistance
- SetAllocator
- SetAssertFcn
- SetLengthUnitsPerMeter
- ShapeCast
- ShapeCastCapsule
- ShapeCastCircle
- ShapeCastPolygon
- ShapeCastSegment
- ShapeDistance
- 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_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_SetUserData
- Shape_TestPoint
- Solve22
- SolvePlanes
- Sub
- TimeOfImpact
- TransformPoint
- TransformPolygon
- UnwindAngle
- UnwindLargeAngle
- ValidateHull
- WeldJoint_GetAngularDampingRatio
- WeldJoint_GetAngularHertz
- WeldJoint_GetLinearDampingRatio
- WeldJoint_GetLinearHertz
- WeldJoint_GetReferenceAngle
- WeldJoint_SetAngularDampingRatio
- WeldJoint_SetAngularHertz
- WeldJoint_SetLinearDampingRatio
- WeldJoint_SetLinearHertz
- WeldJoint_SetReferenceAngle
- 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_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_SetJointTuning
- World_SetMaximumLinearSpeed
- World_SetPreSolveCallback
- World_SetRestitutionCallback
- World_SetRestitutionThreshold
- World_SetUserData
- World_Step
- Yield
Procedure Groups (1)
Types
AABB ¶
Related Procedures With Parameters
- AABB_Center
- AABB_Contains
- AABB_Extents
- AABB_Union
- DynamicTree_CreateProxy
- DynamicTree_EnlargeProxy
- DynamicTree_MoveProxy
- DynamicTree_Query
- IsValidAABB
- World_OverlapAABB
- IsValid (procedure groups)
Related Procedures With Returns
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
Related Procedures With Parameters
AssertFcn ¶
Prototype for the user assert callback. Return 0 to skip the debugger break.
Related Procedures With Parameters
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
Related Procedures With Parameters
Related Procedures With Returns
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
Related Procedures With Returns
BodyId ¶
/ Body id references a body instance. This should be treated as an opaque handle.
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_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
- GetWorldPointVelocity
- 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
Related Procedures With Parameters
Related Procedures With Returns
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
- CollideCapsuleAndCircle
- CollideCapsules
- CollideChainSegmentAndCapsule
- CollidePolygonAndCapsule
- CollideSegmentAndCapsule
- ComputeCapsuleAABB
- ComputeCapsuleMass
- CreateCapsuleShape
- PointInCapsule
- RayCastCapsule
- ShapeCastCapsule
- Shape_SetCapsule
- World_CastMover
- World_CollideMover
Related Procedures With Returns
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
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 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 @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 @param fraction the fraction along the ray at the point of intersection
@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
Related Procedures With Parameters
Related Procedures With Returns
ChainId ¶
/ Chain id references a chain instances. This should be treated as an opaque handle.
Related Procedures With Parameters
- Chain_GetFriction
- Chain_GetMaterial
- Chain_GetRestitution
- Chain_GetSegmentCount
- Chain_GetSegments
- Chain_GetWorld
- Chain_IsValid
- Chain_SetFriction
- Chain_SetMaterial
- Chain_SetRestitution
- DestroyChain
- IsValid (procedure groups)
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
Related Procedures With Returns
Circle ¶
A solid circle
Related Procedures With Parameters
- CollideCapsuleAndCircle
- CollideChainSegmentAndCircle
- CollideCircles
- CollidePolygonAndCircle
- CollideSegmentAndCircle
- ComputeCircleAABB
- ComputeCircleMass
- CreateCircleShape
- PointInCircle
- RayCastCircle
- ShapeCastCircle
- Shape_SetCircle
Related Procedures With Returns
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
Related Procedures With Returns
ContactHitEvent ¶
ContactHitEvent :: struct { // Id of the first shape shapeIdA: ShapeId, // Id of the second shape shapeIdB: ShapeId, // Point where the shapes hit 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.
CosSin ¶
Cosine and sine pair This uses a custom implementation designed for cross-platform determinism
Related Procedures With Returns
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.
Related Procedures With Returns
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
Related Procedures With Parameters
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
Related Procedures With Parameters
Related Procedures With Returns
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
Related Procedures With Parameters
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
Related Procedures With Parameters
Related Procedures With Returns
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 distance: f32, // The final distance, zero if overlapped iterations: i32, // Number of GJK iterations used simplexCount: i32, }
Output for b2ShapeDistance
Related Procedures With Returns
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
Related Procedures With Returns
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
Related Procedures With Parameters
Related Procedures With Returns
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 Parameters
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
Related Procedures With Parameters
Related Procedures With Returns
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`
Related Procedures With Parameters
FrictionCallback ¶
FrictionCallback :: proc "c" (frictionA: f32, userMaterialIdA: i32, frictionB: f32, userMaterialIdB: i32)
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
Related Procedures With Parameters
HexColor ¶
HexColor :: enum i32 { AliceBlue = 15792383, AntiqueWhite = 16444375, Aqua = 65535, Aquamarine = 8388564, Azure = 15794175, Beige = 16119260, Bisque = 16770244, Black = 0, BlanchedAlmond = 16772045, Blue = 255, BlueViolet = 9055202, Brown = 10824234, Burlywood = 14596231, CadetBlue = 6266528, Chartreuse = 8388352, Chocolate = 13789470, Coral = 16744272, CornflowerBlue = 6591981, Cornsilk = 16775388, Crimson = 14423100, Cyan = 65535, DarkBlue = 139, DarkCyan = 35723, DarkGoldenRod = 12092939, DarkGray = 11119017, DarkGreen = 25600, DarkKhaki = 12433259, DarkMagenta = 9109643, DarkOliveGreen = 5597999, DarkOrange = 16747520, DarkOrchid = 10040012, DarkRed = 9109504, DarkSalmon = 15308410, DarkSeaGreen = 9419919, DarkSlateBlue = 4734347, DarkSlateGray = 3100495, DarkTurquoise = 52945, DarkViolet = 9699539, DeepPink = 16716947, DeepSkyBlue = 49151, DimGray = 6908265, DodgerBlue = 2003199, FireBrick = 11674146, FloralWhite = 16775920, ForestGreen = 2263842, Fuchsia = 16711935, Gainsboro = 14474460, GhostWhite = 16316671, Gold = 16766720, GoldenRod = 14329120, Gray = 8421504, Green = 32768, GreenYellow = 11403055, HoneyDew = 15794160, HotPink = 16738740, IndianRed = 13458524, Indigo = 4915330, Ivory = 16777200, Khaki = 15787660, Lavender = 15132410, LavenderBlush = 16773365, LawnGreen = 8190976, LemonChiffon = 16775885, LightBlue = 11393254, LightCoral = 15761536, LightCyan = 14745599, LightGoldenRodYellow = 16448210, LightGray = 13882323, LightGreen = 9498256, LightPink = 16758465, LightSalmon = 16752762, LightSeaGreen = 2142890, LightSkyBlue = 8900346, LightSlateGray = 7833753, LightSteelBlue = 11584734, LightYellow = 16777184, Lime = 65280, LimeGreen = 3329330, Linen = 16445670, Magenta = 16711935, Maroon = 8388608, MediumAquaMarine = 6737322, MediumBlue = 205, MediumOrchid = 12211667, MediumPurple = 9662683, MediumSeaGreen = 3978097, MediumSlateBlue = 8087790, MediumSpringGreen = 64154, MediumTurquoise = 4772300, MediumVioletRed = 13047173, MidnightBlue = 1644912, MintCream = 16121850, MistyRose = 16770273, Moccasin = 16770229, NavajoWhite = 16768685, Navy = 128, OldLace = 16643558, Olive = 8421376, OliveDrab = 7048739, Orange = 16753920, OrangeRed = 16729344, Orchid = 14315734, PaleGoldenRod = 15657130, PaleGreen = 10025880, PaleTurquoise = 11529966, PaleVioletRed = 14381203, PapayaWhip = 16773077, PeachPuff = 16767673, Peru = 13468991, Pink = 16761035, Plum = 14524637, PowderBlue = 11591910, Purple = 8388736, RebeccaPurple = 6697881, Red = 16711680, RosyBrown = 12357519, RoyalBlue = 4286945, SaddleBrown = 9127187, Salmon = 16416882, SandyBrown = 16032864, SeaGreen = 3050327, SeaShell = 16774638, Sienna = 10506797, Silver = 12632256, SkyBlue = 8900331, SlateBlue = 6970061, SlateGray = 7372944, Snow = 16775930, SpringGreen = 65407, SteelBlue = 4620980, Tan = 13808780, Teal = 32896, Thistle = 14204888, Tomato = 16737095, Turquoise = 4251856, Violet = 15631086, Wheat = 16113331, White = 16777215, WhiteSmoke = 16119285, Yellow = 16776960, YellowGreen = 10145074, Box2DRed = 14430514, Box2DBlue = 3190463, Box2DGreen = 9226532, Box2DYellow = 16772748, }
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
Related Procedures With Returns
JointId ¶
/ Joint id references a joint instance. This should be treated as an opaque handle.
Related Procedures With Parameters
- DestroyJoint
- 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
- Joint_GetBodyA
- Joint_GetBodyB
- Joint_GetCollideConnected
- Joint_GetConstraintForce
- Joint_GetConstraintTorque
- Joint_GetLocalAnchorA
- Joint_GetLocalAnchorB
- Joint_GetType
- Joint_GetUserData
- Joint_GetWorld
- Joint_IsValid
- Joint_SetCollideConnected
- Joint_SetUserData
- Joint_WakeBodies
- MotorJoint_GetAngularOffset
- MotorJoint_GetCorrectionFactor
- MotorJoint_GetLinearOffset
- MotorJoint_GetMaxForce
- MotorJoint_GetMaxTorque
- MotorJoint_SetAngularOffset
- MotorJoint_SetCorrectionFactor
- MotorJoint_SetLinearOffset
- MotorJoint_SetMaxForce
- MotorJoint_SetMaxTorque
- MouseJoint_GetMaxForce
- MouseJoint_GetSpringDampingRatio
- MouseJoint_GetSpringHertz
- MouseJoint_GetTarget
- MouseJoint_SetMaxForce
- MouseJoint_SetSpringDampingRatio
- MouseJoint_SetSpringHertz
- MouseJoint_SetTarget
- PrismaticJoint_EnableLimit
- PrismaticJoint_EnableMotor
- PrismaticJoint_EnableSpring
- PrismaticJoint_GetLowerLimit
- PrismaticJoint_GetMaxMotorForce
- PrismaticJoint_GetMotorForce
- PrismaticJoint_GetMotorSpeed
- PrismaticJoint_GetSpeed
- PrismaticJoint_GetSpringDampingRatio
- PrismaticJoint_GetSpringHertz
- PrismaticJoint_GetTranslation
- PrismaticJoint_GetUpperLimit
- PrismaticJoint_IsLimitEnabled
- PrismaticJoint_IsMotorEnabled
- PrismaticJoint_IsSpringEnabled
- PrismaticJoint_SetLimits
- PrismaticJoint_SetMaxMotorForce
- PrismaticJoint_SetMotorSpeed
- PrismaticJoint_SetSpringDampingRatio
- PrismaticJoint_SetSpringHertz
- RevoluteJoint_EnableLimit
- RevoluteJoint_EnableMotor
- RevoluteJoint_EnableSpring
- RevoluteJoint_GetAngle
- RevoluteJoint_GetLowerLimit
- RevoluteJoint_GetMaxMotorTorque
- RevoluteJoint_GetMotorSpeed
- RevoluteJoint_GetMotorTorque
- RevoluteJoint_GetSpringDampingRatio
- RevoluteJoint_GetSpringHertz
- RevoluteJoint_GetUpperLimit
- RevoluteJoint_IsLimitEnabled
- RevoluteJoint_IsMotorEnabled
- RevoluteJoint_IsSpringEnabled
- RevoluteJoint_SetLimits
- RevoluteJoint_SetMaxMotorTorque
- RevoluteJoint_SetMotorSpeed
- RevoluteJoint_SetSpringDampingRatio
- RevoluteJoint_SetSpringHertz
- WeldJoint_GetAngularDampingRatio
- WeldJoint_GetAngularHertz
- WeldJoint_GetLinearDampingRatio
- WeldJoint_GetLinearHertz
- WeldJoint_GetReferenceAngle
- WeldJoint_SetAngularDampingRatio
- WeldJoint_SetAngularHertz
- WeldJoint_SetLinearDampingRatio
- WeldJoint_SetLinearHertz
- WeldJoint_SetReferenceAngle
- 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
- IsValid (procedure groups)
Related Procedures With Returns
- CreateDistanceJoint
- CreateFilterJoint
- CreateMotorJoint
- CreateMouseJoint
- CreatePrismaticJoint
- CreateRevoluteJoint
- CreateWeldJoint
- CreateWheelJoint
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
Related Procedures With Returns
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 Parameters
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
Related Procedures With Parameters
Related Procedures With Returns
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
Related Procedures With Parameters
Related Procedures With Returns
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, // 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.
Related Procedures With Parameters
PlaneSolverResult ¶
PlaneSolverResult :: struct { // The final position of the mover position: [2]f32, // The number of iterations used by the plane solver. For diagnostics. iterationCount: i32, }
Result returned by b2SolvePlanes
Related Procedures With Returns
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
- CollideChainSegmentAndPolygon
- CollidePolygonAndCapsule
- CollidePolygonAndCircle
- CollidePolygons
- CollideSegmentAndPolygon
- ComputePolygonAABB
- ComputePolygonMass
- CreatePolygonShape
- PointInPolygon
- RayCastPolygon
- ShapeCastPolygon
- Shape_SetPolygon
- TransformPolygon
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
Related Procedures With Parameters
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, // 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
Related Procedures With Parameters
Related Procedures With Returns
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.
Related Procedures With Returns
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
- World_CastMover
- World_CastRay
- World_CastRayClosest
- World_CastShape
- World_CollideMover
- World_OverlapAABB
- World_OverlapShape
Related Procedures With Returns
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 @ingroup world
Related Procedures With Returns
RestitutionCallback ¶
RestitutionCallback :: proc "c" (restitutionA: f32, userMaterialIdA: i32, restitutuionB: f32, userMaterialIdB: i32)
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
Related Procedures With Parameters
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, // 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.95*pi radians. lowerAngle: f32, // The upper angle for the joint limit in radians. Maximum of 0.95*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: 1. you might not know where the center of mass will be 2. if you add/remove shapes from a body and recompute the mass, the joints will be broken @ingroup revolute_joint
Related Procedures With Parameters
Related Procedures With Returns
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
Segment ¶
A line segment with two-sided collision.
Related Procedures With Parameters
- CollideSegmentAndCapsule
- CollideSegmentAndCircle
- CollideSegmentAndPolygon
- ComputeSegmentAABB
- CreateSegmentShape
- RayCastSegment
- ShapeCastSegment
- Shape_SetSegment
Related Procedures With Returns
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
Related Procedures With Returns
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
Related Procedures With Returns
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
Related Procedures With Parameters
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
Related Procedures With Returns
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_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_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
Related Procedures With Returns
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.
Related Procedures With Parameters
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
Related Procedures With Parameters
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
Related Procedures With Parameters
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
Related Procedures With Parameters
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
Related Procedures With Parameters
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
Version ¶
Version :: struct { major: i32, // Significant changes minor: i32, // Incremental changes revision: i32, }
Version numbering scheme.
See https://semver.org/
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
Related Procedures With Parameters
Related Procedures With Returns
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
Related Procedures With Parameters
Related Procedures With Returns
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, // Joint stiffness. Cycles per second. jointHertz: f32, // Joint bounciness. Non-dimensional. jointDampingRatio: 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
Related Procedures With Parameters
Related Procedures With Returns
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
- 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_SetJointTuning
- World_SetMaximumLinearSpeed
- World_SetPreSolveCallback
- World_SetRestitutionCallback
- World_SetRestitutionThreshold
- World_SetUserData
- World_Step
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
Constants
HASH_INIT ¶
HASH_INIT: int : 5381
MAX_POLYGON_VERTICES ¶
MAX_POLYGON_VERTICES: int : 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}
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_Extents ¶
Get the extents of the AABB (half-widths).
Body_ApplyAngularImpulse ¶
Apply an angular impulse. The impulse is ignored if the body is not awake. This optionally wakes the body.
@param bodyId The body id
@param impulse the angular impulse, usually in units of kgmm/s @param wake also wake up the body
@warning This should be used for one-shot impulses. If you need a steady force,
use a force instead, which will work better with the sub-stepping solver.
Body_ApplyForce ¶
Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This optionally wakes up the body.
The force is ignored if the body is not awake. @param bodyId The body id
@param force The world force vector, usually in newtons (N) @param point The world position of the point of application @param wake Option to wake up the body
Body_ApplyForceToCenter ¶
Apply a force to the center of mass. This optionally wakes up the body.
The force is ignored if the body is not awake. @param bodyId The body id
@param force the world force vector, usually in newtons (N). @param wake also wake up the body
Body_ApplyLinearImpulse ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Body_Disable :: proc "c" (bodyId: BodyId) ---
Disable a body by removing it completely from the simulation. This is expensive.
Body_Enable ¶
Body_Enable :: proc "c" (bodyId: BodyId) ---
Enable a body by adding it to the simulation. This is expensive.
Body_EnableContactEvents ¶
Enable/disable contact events on all shapes. @see b2ShapeDef::enableContactEvents @warning changing this at runtime may cause mismatched begin/end touch events
Body_EnableHitEvents ¶
Enable/disable hit events on all shapes
@see b2ShapeDef::enableHitEvents
Body_EnableSleep ¶
Enable or disable sleeping for this body. If sleeping is disabled the body will wake.
Body_GetAngularDamping ¶
Get the current angular damping.
Body_GetAngularVelocity ¶
Get the angular velocity of a body in radians per second
Body_GetContactCapacity ¶
Get the maximum capacity required for retrieving all the touching contacts on a body
Body_GetContactData ¶
Body_GetContactData :: proc "c" (bodyId: BodyId, contactData: []ContactData) -> []ContactData {…}
Get the touching contact data for a body
Body_GetGravityScale ¶
Get the current gravity scale
Body_GetJointCount ¶
Get the number of joints on this body
Body_GetJoints ¶
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 ¶
Get the current linear damping.
Body_GetLinearVelocity ¶
Get the linear velocity of a body's center of mass. Usually in meters per second.
Body_GetLocalCenterOfMass ¶
Get the center of mass position of the body in local space
Body_GetLocalPoint ¶
Get a local point on a body given a world point
Body_GetLocalPointVelocity ¶
Get the linear velocity of a local point attached to a body. Usually in meters per second.
Body_GetLocalVector ¶
Get a local vector on a body given a world vector
Body_GetMass ¶
Get the mass of the body, usually in kilograms
Body_GetMassData ¶
Get the mass data for a body
Body_GetName ¶
Get the body name. May be nil.
Body_GetPosition ¶
Get the world position of a body. This is the location of the body origin.
Body_GetRotation ¶
Get the world rotation of a body as a cosine/sine pair (complex number)
Body_GetRotationalInertia ¶
Get the rotational inertia of the body, usually in kg*m^2
Body_GetShapeCount ¶
Get the number of shapes on this body
Body_GetShapes ¶
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 ¶
Get the sleep threshold, usually in meters per second.
Body_GetTransform ¶
Get the world transform of a body.
Body_GetType ¶
Get the body type: static, kinematic, or dynamic
Body_GetUserData ¶
Get the user data stored in a body
Body_GetWorld ¶
Get the world that owns this body
Body_GetWorldCenterOfMass ¶
Get the center of mass position of the body in world space
Body_GetWorldPoint ¶
Get a world point on a body given a local point
Body_GetWorldVector ¶
Get a world vector on a body given a local vector
Body_IsAwake ¶
@return true if this body is awake
Body_IsEnabled ¶
Returns true if this body is enabled
Body_IsFixedRotation ¶
Does this body have fixed rotation?
Body_IsSleepEnabled ¶
Returns true if sleeping is enabled for this body
Body_IsValid ¶
Body identifier validation. Can be used to detect orphaned ids. Provides validation for up to 64K allocations.
Body_SetAngularDamping ¶
Adjust the angular damping. Normally this is set in BodyDef before creation.
Body_SetAngularVelocity ¶
Set the angular velocity of a body in radians per second
Body_SetAwake ¶
Wake a body from sleep. This wakes the entire island the body is touching.
@warning Putting a body to sleep will put the entire island of bodies touching this body to sleep, which can be expensive and possibly unintuitive.
Body_SetBullet ¶
Set this body to be a bullet. A bullet does continuous collision detection against dynamic bodies (but not other bullets).
Body_SetFixedRotation ¶
Set this body to have fixed rotation. This causes the mass to be reset in all cases.
Body_SetGravityScale ¶
Adjust the gravity scale. Normally this is set in BodyDef before creation.
@see BodyDef::gravityScale
Body_SetLinearDamping ¶
Adjust the linear damping. Normally this is set in BodyDef before creation.
Body_SetLinearVelocity ¶
Set the linear velocity of a body. Usually in meters per second.
Body_SetMassData ¶
Override the body's mass properties. Normally this is computed automatically using the
shape geometry and density. This information is lost if a shape is added or removed or if the body type changes.
Body_SetName ¶
Set the body name. Up to 32 characters excluding 0 termination.
Body_SetSleepThreshold ¶
Set the sleep threshold, usually in meters per second
Body_SetTargetTransform ¶
Set the velocity to reach the given transform after a given time step. The result will be close but maybe not exact. This is meant for kinematic bodies. This will automatically wake the body if asleep.
Body_SetTransform ¶
Set the world transform of a body. This acts as a teleport and is fairly expensive. @note Generally you should create a body with then intended transform.
@see BodyDef::position and BodyDef::angle
Body_SetType ¶
Change the body type. This is an expensive operation. This automatically updates the mass
properties regardless of the automatic mass setting.
Body_SetUserData ¶
Set the user data for a body
Chain_GetFriction ¶
Get the chain friction
Chain_GetMaterial ¶
Get the chain material
Chain_GetRestitution ¶
Get the chain restitution
Chain_GetSegmentCount ¶
Get the number of segments on this chain
Chain_GetSegments ¶
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 ¶
Get the world that owns this chain shape
Chain_IsValid ¶
Chain identifier validation. Provides validation for up to 64K allocations.
Chain_SetFriction ¶
Set the chain friction @see b2ChainDef::friction
Chain_SetMaterial ¶
Set the chain material @see b2ChainDef::material
Chain_SetRestitution ¶
Set the chain restitution (bounciness) @see b2ChainDef::restitution
Clamp ¶
Component-wise clamp vector v into the range [a, b]
ClampFloat ¶
@return a f32 clamped between a lower and upper bound
ClampInt ¶
@return an integer clamped between a lower and upper bound
ClipVector ¶
ClipVector :: proc(vector: [2]f32, planes: []CollisionPlane) -> [2]f32 {…}
CollideCapsuleAndCircle ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
CollideCircles :: proc "c" (#by_ptr circleA: Circle, xfA: Transform, #by_ptr circleB: Circle, xfB: Transform) -> Manifold ---
Compute the contact manifold between two circles
CollidePolygonAndCapsule ¶
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 ¶
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 ¶
CollidePolygons :: proc "c" (#by_ptr polygonA: Polygon, xfA: Transform, #by_ptr polygonB: Polygon, xfB: Transform) -> Manifold ---
Compute the contact manifold between two polygons
CollideSegmentAndCapsule ¶
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 ¶
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 ¶
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 ¶
Compute the bounding box of a transformed capsule
ComputeCapsuleMass ¶
Compute mass properties of a capsule
ComputeCircleAABB ¶
Compute the bounding box of a transformed circle
ComputeCircleMass ¶
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 ¶
Compute the bounding box of a transformed polygon
ComputePolygonMass ¶
Compute mass properties of a polygon
ComputeRotationBetweenUnitVectors ¶
Compute the rotation between two unit vectors
ComputeSegmentAABB ¶
Compute the bounding box of a transformed line segment
CreateBody ¶
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.
CreateCapsuleShape ¶
CreateCapsuleShape :: proc "c" (bodyId: BodyId, #by_ptr def: ShapeDef, #by_ptr 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 ¶
Create a chain shape
@see b2ChainDef for details
CreateCircleShape ¶
CreateCircleShape :: proc "c" (bodyId: BodyId, #by_ptr def: ShapeDef, #by_ptr 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 ¶
CreateDistanceJoint :: proc "c" (worldId: WorldId, #by_ptr def: DistanceJointDef) -> JointId ---
Create a distance joint
@see b2DistanceJointDef for details
CreateFilterJoint ¶
CreateFilterJoint :: proc "c" (worldId: WorldId, #by_ptr def: FilterJointDef) -> JointId ---
Create a filter joint. @see b2FilterJointDef for details
CreateMotorJoint ¶
CreateMotorJoint :: proc "c" (worldId: WorldId, def: MotorJointDef) -> JointId ---
Create a motor joint
@see b2MotorJointDef for details
CreateMouseJoint ¶
CreateMouseJoint :: proc "c" (worldId: WorldId, #by_ptr def: MouseJointDef) -> JointId ---
Create a mouse joint
@see b2MouseJointDef for details
CreatePolygonShape ¶
CreatePolygonShape :: proc "c" (bodyId: BodyId, #by_ptr def: ShapeDef, #by_ptr 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
CreatePrismaticJoint ¶
CreatePrismaticJoint :: proc "c" (worldId: WorldId, #by_ptr def: PrismaticJointDef) -> JointId ---
Create a prismatic (slider) joint.
@see b2PrismaticJointDef for details
CreateRevoluteJoint ¶
CreateRevoluteJoint :: proc "c" (worldId: WorldId, #by_ptr def: RevoluteJointDef) -> JointId ---
Create a revolute joint
@see b2RevoluteJointDef for details
CreateSegmentShape ¶
CreateSegmentShape :: proc "c" (bodyId: BodyId, #by_ptr def: ShapeDef, #by_ptr 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 ¶
CreateWeldJoint :: proc "c" (worldId: WorldId, #by_ptr def: WeldJointDef) -> JointId ---
Create a weld joint
@see b2WeldJointDef for details
CreateWheelJoint ¶
CreateWheelJoint :: proc "c" (worldId: WorldId, #by_ptr def: WheelJointDef) -> JointId ---
Create a wheel joint
@see b2WheelJointDef for details
CreateWorld ¶
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.
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 ¶
DefaultBodyDef :: proc "c" () -> BodyDef ---
Use this to initialize your body definition @ingroup body
DefaultChainDef ¶
DefaultChainDef :: proc "c" () -> ChainDef ---
Use this to initialize your chain definition @ingroup shape
DefaultDebugDraw ¶
DefaultDebugDraw :: proc "c" () -> DebugDraw ---
Use this to initialize your drawing interface. This allows you to implement a sub-set of the drawing functions.
DefaultDistanceJointDef ¶
DefaultDistanceJointDef :: proc "c" () -> DistanceJointDef ---
Use this to initialize your joint definition @ingroup distance_joint
DefaultExplosionDef ¶
DefaultExplosionDef :: proc "c" () -> ExplosionDef ---
Use this to initialize your explosion definition @ingroup world
DefaultFilter ¶
DefaultFilter :: proc "c" () -> Filter ---
Use this to initialize your filter @ingroup shape
DefaultFilterJointDef ¶
DefaultFilterJointDef :: proc "c" () -> FilterJointDef ---
Use this to initialize your joint definition @ingroup filter_joint
DefaultMotorJointDef ¶
DefaultMotorJointDef :: proc "c" () -> MotorJointDef ---
Use this to initialize your joint definition @ingroup motor_joint
DefaultMouseJointDef ¶
DefaultMouseJointDef :: proc "c" () -> MouseJointDef ---
Use this to initialize your joint definition @ingroup mouse_joint
DefaultPrismaticJointDef ¶
DefaultPrismaticJointDef :: proc "c" () -> PrismaticJointDef ---
Use this to initialize your joint definition @ingroupd prismatic_joint
DefaultQueryFilter ¶
DefaultQueryFilter :: proc "c" () -> QueryFilter ---
Use this to initialize your query filter @ingroup shape
DefaultRevoluteJointDef ¶
DefaultRevoluteJointDef :: proc "c" () -> RevoluteJointDef ---
Use this to initialize your joint definition. @ingroup revolute_joint
DefaultShapeDef ¶
DefaultShapeDef :: proc "c" () -> ShapeDef ---
Use this to initialize your shape definition @ingroup shape
DefaultSurfaceMaterial ¶
DefaultSurfaceMaterial :: proc "c" () -> SurfaceMaterial ---
Use this to initialize your surface material @ingroup shape
DefaultWeldJointDef ¶
DefaultWeldJointDef :: proc "c" () -> WeldJointDef ---
Use this to initialize your joint definition @ingroup weld_joint
DefaultWheelJointDef ¶
DefaultWheelJointDef :: proc "c" () -> WheelJointDef ---
Use this to initialize your joint definition @ingroup wheel_joint
DefaultWorldDef ¶
DefaultWorldDef :: proc "c" () -> WorldDef ---
Use this to initialize your world definition @ingroup world
DestroyBody ¶
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.
DestroyShape ¶
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
DistanceJoint_EnableLimit ¶
Enable joint limit. The limit only works if the joint spring is enabled. Otherwise the joint is rigid
and the limit has no effect.
DistanceJoint_EnableMotor ¶
Enable/disable the distance joint motor
DistanceJoint_EnableSpring ¶
Enable/disable the distance joint spring. When disabled the distance joint is rigid.
DistanceJoint_GetCurrentLength ¶
Get the current length of a distance joint
DistanceJoint_GetLength ¶
Get the rest length of a distance joint
DistanceJoint_GetMaxLength ¶
Get the distance joint maximum length
DistanceJoint_GetMaxMotorForce ¶
Get the distance joint maximum motor force, usually in newtons
DistanceJoint_GetMinLength ¶
Get the distance joint minimum length
DistanceJoint_GetMotorForce ¶
Get the distance joint current motor force, usually in newtons
DistanceJoint_GetMotorSpeed ¶
Get the distance joint motor speed, usually in meters per second
DistanceJoint_GetSpringDampingRatio ¶
Get the spring damping ratio
DistanceJoint_GetSpringHertz ¶
Get the spring Hertz
DistanceJoint_IsLimitEnabled ¶
Is the distance joint limit enabled?
DistanceJoint_IsMotorEnabled ¶
Is the distance joint motor enabled?
DistanceJoint_IsSpringEnabled ¶
Is the distance joint spring enabled?
DistanceJoint_SetLength ¶
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 ¶
Set the minimum and maximum length parameters of a distance joint
DistanceJoint_SetMaxMotorForce ¶
Set the distance joint maximum motor force, usually in newtons
DistanceJoint_SetMotorSpeed ¶
Set the distance joint motor speed, usually in meters per second
DistanceJoint_SetSpringDampingRatio ¶
Set the spring damping ratio, non-dimensional
DistanceJoint_SetSpringHertz ¶
Set the spring stiffness in Hertz
DistanceSquared ¶
Get the distance squared between points
DynamicTree_Create ¶
DynamicTree_Create :: proc "c" () -> DynamicTree ---
Constructing the tree initializes the node pool.
DynamicTree_CreateProxy ¶
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 ¶
DynamicTree_Destroy :: proc "c" (tree: ^DynamicTree) ---
Destroy the tree, freeing the node pool.
DynamicTree_DestroyProxy ¶
DynamicTree_DestroyProxy :: proc "c" (tree: ^DynamicTree, proxyId: i32) ---
Destroy a proxy. This asserts if the id is invalid.
DynamicTree_EnlargeProxy ¶
DynamicTree_EnlargeProxy :: proc "c" (tree: ^DynamicTree, proxyId: i32, aabb: AABB) ---
Enlarge a proxy and enlarge ancestors as necessary.
DynamicTree_GetAABB ¶
DynamicTree_GetAABB :: proc "c" (#by_ptr tree: DynamicTree, proxyId: i32) -> AABB ---
Get the AABB of a proxy
DynamicTree_GetAreaRatio ¶
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 ¶
DynamicTree_GetByteCount :: proc "c" (#by_ptr tree: DynamicTree) -> i32 ---
Get the number of bytes used by this tree
DynamicTree_GetCategoryBits ¶
DynamicTree_GetCategoryBits :: proc "c" (tree: ^DynamicTree, proxyId: i32) ---
Get the category bits on a proxy.
DynamicTree_GetHeight ¶
DynamicTree_GetHeight :: proc "c" (#by_ptr tree: DynamicTree) -> i32 ---
Get the height of the binary tree.
DynamicTree_GetProxyCount ¶
DynamicTree_GetProxyCount :: proc "c" (#by_ptr tree: DynamicTree) -> i32 ---
Get the number of proxies created
DynamicTree_GetRootBounds ¶
DynamicTree_GetRootBounds :: proc "c" (#by_ptr tree: DynamicTree) -> AABB ---
Get the bounding box that contains the entire tree
DynamicTree_GetUserData ¶
DynamicTree_GetUserData :: proc "c" (#by_ptr tree: DynamicTree, proxyId: i32) -> u64 ---
Get proxy user data
DynamicTree_MoveProxy ¶
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 ¶
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 ¶
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 ¶
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 ¶
DynamicTree_SetCategoryBits :: proc "c" (tree: ^DynamicTree, proxyId: i32, categoryBits: u64) ---
Modify the category bits on a proxy. This is an expensive operation.
DynamicTree_ShapeCast ¶
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 ¶
DynamicTree_Validate :: proc "c" (#by_ptr tree: DynamicTree) ---
Validate this tree. For testing.
DynamicTree_ValidateNoEnlarged ¶
DynamicTree_ValidateNoEnlarged :: proc "c" (#by_ptr tree: DynamicTree) ---
Validate this tree has no enlarged AABBs. For testing.
GetInverse22 ¶
Get the inverse of a 2-by-2 matrix
GetLengthUnitsPerMeter ¶
GetLengthUnitsPerMeter :: proc "c" () -> f32 ---
Get the current length units per meter.
GetMilliseconds ¶
Get the milliseconds passed from an initial tick value.
GetMillisecondsAndReset ¶
Get the milliseconds passed from an initial tick value. Resets the passed in value to the current tick value.
GetSweepTransform ¶
Evaluate the transform sweep at a specific time.
GetTicks ¶
GetTicks :: proc "c" () -> u64 ---
Get the absolute number of system ticks. The value is platform specific.
GetWorldPointVelocity ¶
Get the linear velocity of a world point attached to a body. Usually in meters per second.
Hash ¶
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 ¶
IsValidRay :: proc "c" (#by_ptr input: RayCastInput) -> bool ---
Validate ray cast input data (NaN, etc)
Joint_GetBodyA ¶
Get body A id on a joint
Joint_GetBodyB ¶
Get body B id on a joint
Joint_GetCollideConnected ¶
Is collision allowed between connected bodies?
Joint_GetConstraintForce ¶
Get the current constraint force for this joint. Usually in Newtons.
Joint_GetConstraintTorque ¶
Get the current constraint torque for this joint. Usually in Newton * meters.
Joint_GetLocalAnchorA ¶
Get the local anchor on bodyA
Joint_GetLocalAnchorB ¶
Get the local anchor on bodyB
Joint_GetType ¶
Get the joint type
Joint_GetUserData ¶
Get the user data on a joint
Joint_GetWorld ¶
Get the world that owns this joint
Joint_IsValid ¶
Joint identifier validation. Provides validation for up to 64K allocations.
Joint_SetCollideConnected ¶
Toggle collision between connected bodies
Joint_SetUserData ¶
Set the user data on a joint
Joint_WakeBodies ¶
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)
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/
MakeAABB ¶
Compute the bounding box of an array of circles
MakeBox ¶
Make a box (rectangle) polygon, bypassing the need for a convex hull.
MakeOffsetBox ¶
MakeOffsetBox :: proc "c" (halfWidth, halfHeight: f32, center: [2]f32, rotation: Rot) -> Polygon ---
Make an offset box, bypassing the need for a convex hull.
MakeOffsetPolygon ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Make a rounded box, bypassing the need for a convex hull.
MakeSquare ¶
Make a square polygon, bypassing the need for a convex hull.
MotorJoint_GetAngularOffset ¶
Get the motor joint angular offset target in radians
MotorJoint_GetCorrectionFactor ¶
Get the motor joint correction factor, usually in [0, 1]
MotorJoint_GetLinearOffset ¶
Get the motor joint linear offset target
MotorJoint_GetMaxForce ¶
Get the motor joint maximum force, usually in newtons
MotorJoint_GetMaxTorque ¶
Get the motor joint maximum torque, usually in newton-meters
MotorJoint_SetAngularOffset ¶
Set the motor joint angular offset target in radians
MotorJoint_SetCorrectionFactor ¶
Set the motor joint correction factor, usually in [0, 1]
MotorJoint_SetLinearOffset ¶
Set the motor joint linear offset target
MotorJoint_SetMaxForce ¶
Set the motor joint maximum force, usually in newtons
MotorJoint_SetMaxTorque ¶
Set the motor joint maximum torque, usually in newton-meters
MouseJoint_GetMaxForce ¶
Get the mouse joint maximum force, usually in newtons
MouseJoint_GetSpringDampingRatio ¶
Get the mouse joint damping ratio, non-dimensional
MouseJoint_GetSpringHertz ¶
Get the mouse joint spring stiffness in Hertz
MouseJoint_GetTarget ¶
Get the mouse joint target
MouseJoint_SetMaxForce ¶
Set the mouse joint maximum force, usually in newtons
MouseJoint_SetSpringDampingRatio ¶
Set the mouse joint spring damping ratio, non-dimensional
MouseJoint_SetSpringHertz ¶
Set the mouse joint spring stiffness in Hertz
MouseJoint_SetTarget ¶
Set the mouse joint target
MulMV ¶
Multiply a 2-by-2 matrix times a 2D vector
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
NLerp ¶
Normalized linear interpolation https://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/ https://web.archive.org/web/20170825184056/http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/
PlaneSeparation ¶
Signed separation of a point from a plane
PointInCapsule ¶
Test a point for overlap with a capsule in local space
PointInCircle ¶
Test a point for overlap with a circle in local space
PointInPolygon ¶
Test a point for overlap with a convex polygon in local space
PrismaticJoint_EnableLimit ¶
Enable/disable a prismatic joint limit
PrismaticJoint_EnableMotor ¶
Enable/disable a prismatic joint motor
PrismaticJoint_EnableSpring ¶
Enable/disable the joint spring.
PrismaticJoint_GetLowerLimit ¶
Get the prismatic joint lower limit
PrismaticJoint_GetMaxMotorForce ¶
Get the prismatic joint maximum motor force, usually in newtons
PrismaticJoint_GetMotorForce ¶
Get the prismatic joint current motor force, usually in newtons
PrismaticJoint_GetMotorSpeed ¶
Get the prismatic joint motor speed, usually in meters per second
PrismaticJoint_GetSpeed ¶
Get the current joint translation speed, usually in meters per second.
PrismaticJoint_GetSpringDampingRatio ¶
Get the prismatic spring damping ratio (non-dimensional)
PrismaticJoint_GetSpringHertz ¶
Get the prismatic joint stiffness in Hertz
PrismaticJoint_GetTranslation ¶
Get the current joint translation, usually in meters.
PrismaticJoint_GetUpperLimit ¶
Get the prismatic joint upper limit
PrismaticJoint_IsLimitEnabled ¶
Is the prismatic joint limit enabled?
PrismaticJoint_IsMotorEnabled ¶
Is the prismatic joint motor enabled?
PrismaticJoint_IsSpringEnabled ¶
Is the prismatic joint spring enabled or not?
PrismaticJoint_SetLimits ¶
Set the prismatic joint limits
PrismaticJoint_SetMaxMotorForce ¶
Set the prismatic joint maximum motor force, usually in newtons
PrismaticJoint_SetMotorSpeed ¶
Set the prismatic joint motor speed, usually in meters per second
PrismaticJoint_SetSpringDampingRatio ¶
Set the prismatic joint damping ratio (non-dimensional)
PrismaticJoint_SetSpringHertz ¶
Set the prismatic joint stiffness in Hertz. This should usually be less than a quarter of the simulation rate. For example, if the simulation runs at 60Hz then the joint stiffness should be 15Hz or less.
RayCastCapsule ¶
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 ¶
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 ¶
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 ¶
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 ¶
Enable/disable the revolute joint limit
RevoluteJoint_EnableMotor ¶
Enable/disable a revolute joint motor
RevoluteJoint_EnableSpring ¶
Enable/disable the revolute joint spring
RevoluteJoint_GetAngle ¶
Get the revolute joint current angle in radians relative to the reference angle
@see b2RevoluteJointDef::referenceAngle
RevoluteJoint_GetLowerLimit ¶
Get the revolute joint lower limit in radians
RevoluteJoint_GetMaxMotorTorque ¶
Get the revolute joint maximum motor torque, usually in newton-meters
RevoluteJoint_GetMotorSpeed ¶
Get the revolute joint motor speed in radians per second
RevoluteJoint_GetMotorTorque ¶
Get the revolute joint current motor torque, usually in newton-meters
RevoluteJoint_GetSpringDampingRatio ¶
Get the revolute joint spring damping ratio, non-dimensional
RevoluteJoint_GetSpringHertz ¶
Get the revolute joint spring stiffness in Hertz
RevoluteJoint_GetUpperLimit ¶
Get the revolute joint upper limit in radians
RevoluteJoint_IsLimitEnabled ¶
Is the revolute joint limit enabled?
RevoluteJoint_IsMotorEnabled ¶
Is the revolute joint motor enabled?
RevoluteJoint_IsSpringEnabled ¶
Is the revolute spring enabled?
RevoluteJoint_SetLimits ¶
Set the revolute joint limits in radians. It is expected that lower <= upper and that -0.95 B2_PI <= lower && upper <= -0.95 B2_PI.
RevoluteJoint_SetMaxMotorTorque ¶
Set the revolute joint maximum motor torque, usually in newton-meters
RevoluteJoint_SetMotorSpeed ¶
Set the revolute joint motor speed in radians per second
RevoluteJoint_SetSpringDampingRatio ¶
Set the revolute joint spring damping ratio, non-dimensional
RevoluteJoint_SetSpringHertz ¶
Set the revolute joint spring stiffness in Hertz
RightPerp ¶
Get a right pointing perpendicular vector. Equivalent to b2CrossVS(v, 1)
Rot_GetAngle ¶
Get the angle in radians in the range [-pi, pi]
SegmentDistance ¶
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 ¶
This allows the user to override the allocation functions. These should be
set during application startup.
SetAssertFcn ¶
SetAssertFcn :: proc "c" (assertfcn: AssertFcn) ---
Override the default assert callback
@param assertFcn a non-null assert callback
SetLengthUnitsPerMeter ¶
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
ShapeCast ¶
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. You may optionally supply an array to hold debug data.
ShapeCastCapsule ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Returns true if contact events are enabled
Shape_AreHitEventsEnabled ¶
Returns true if hit events are enabled
Shape_ArePreSolveEventsEnabled ¶
Returns true if pre-solve events are enabled
Shape_AreSensorEventsEnabled ¶
Returns true if sensor events are enabled
Shape_EnableContactEvents ¶
Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors.
@see b2ShapeDef::enableContactEvents
@warning changing this at run-time may lead to lost begin/end events
Shape_EnableHitEvents ¶
Enable contact hit events for this shape. Ignored for sensors.
@see WorldDef.hitEventThreshold
Shape_EnablePreSolveEvents ¶
Enable pre-solve contact events for this shape. Only applies to dynamic bodies. These are expensive
and must be carefully handled due to multithreading. Ignored for sensors. @see b2PreSolveFcn
Shape_EnableSensorEvents ¶
Enable sensor events for this shape.
@see b2ShapeDef::enableSensorEvents
Shape_GetAABB ¶
Get the current world AABB
Shape_GetBody ¶
Get the id of the body that a shape is attached to
Shape_GetCapsule ¶
Get a copy of the shape's capsule. Asserts the type is correct.
Shape_GetChainSegment ¶
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 ¶
Get a copy of the shape's circle. Asserts the type is correct.
Shape_GetClosestPoint ¶
Get the closest point on a shape to a target point. Target and result are in world space.
Shape_GetContactCapacity ¶
Get the maximum capacity required for retrieving all the touching contacts on a shape
Shape_GetContactData ¶
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 ¶
Get the density of a shape, usually in kg/m^2
Shape_GetFilter ¶
Get the shape filter
Shape_GetFriction ¶
Get the friction of a shape
Shape_GetMassData ¶
Get the mass data of a shape
Shape_GetMaterial ¶
Get the shape material identifier
Shape_GetParentChain ¶
Get the parent chain id if the shape type is a chain segment, otherwise returns b2_nullChainId.
Shape_GetPolygon ¶
Get a copy of the shape's convex polygon. Asserts the type is correct.
Shape_GetRestitution ¶
Get the shape restitution
Shape_GetSegment ¶
Get a copy of the shape's line segment. Asserts the type is correct.
Shape_GetSensorCapacity ¶
Get the maximum capacity required for retrieving all the overlapped shapes on a sensor shape. This returns 0 if the provided shape is not a sensor. @param shapeId the id of a sensor shape @returns the required capacity to get all the overlaps in b2Shape_GetSensorOverlaps
Shape_GetSensorOverlaps ¶
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_GetType ¶
Get the type of a shape
Shape_GetUserData ¶
Get the user data for a shape. This is useful when you get a shape id
from an event or query.
Shape_GetWorld ¶
Get the world that owns this shape.
Shape_IsSensor ¶
Returns true if the shape is a sensor. It is not possible to change a shape from sensor to solid dynamically because this breaks the contract for sensor events.
Shape_IsValid ¶
Shape identifier validation. Provides validation for up to 64K allocations.
Shape_RayCast ¶
Shape_RayCast :: proc "c" (shapeId: ShapeId, #by_ptr input: RayCastInput) -> CastOutput ---
Ray cast a shape directly
Shape_SetCapsule ¶
Allows you to change a shape to be a capsule or update the current capsule. This does not modify the mass properties.
@see b2Body_ApplyMassFromShapes
Shape_SetCircle ¶
Allows you to change a shape to be a circle or update the current circle. This does not modify the mass properties.
@see b2Body_ApplyMassFromShapes
Shape_SetDensity ¶
Set the mass density of a shape, usually in kg/m^2.
This will optionally update the mass properties on the parent body. @see b2ShapeDef::density, b2Body_ApplyMassFromShapes
Shape_SetFilter ¶
Set the current filter. This is almost as expensive as recreating the shape. This may cause contacts to be immediately destroyed. However contacts are not created until the next world step. Sensor overlap state is also not updated until the next world step. @see b2ShapeDef::filter
Shape_SetFriction ¶
Set the friction on a shape
@see b2ShapeDef::friction
Shape_SetMaterial ¶
Set the shape material identifier @see b2ShapeDef::material
Shape_SetPolygon ¶
Allows you to change a shape to be a polygon or update the current polygon. This does not modify the mass properties.
@see b2Body_ApplyMassFromShapes
Shape_SetRestitution ¶
Set the shape restitution (bounciness)
@see b2ShapeDef::restitution
Shape_SetSegment ¶
Allows you to change a shape to be a segment or update the current segment.
Shape_SetUserData ¶
Set the user data for a shape
Shape_TestPoint ¶
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 ¶
SolvePlanes :: proc(position: [2]f32, planes: []CollisionPlane) -> PlaneSolverResult {…}
TimeOfImpact ¶
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 ¶
Transform a polygon. This is useful for transferring a shape from one body to another.
UnwindAngle ¶
Convert an angle in the range [-2pi, 2pi] into the range [-pi, pi]
UnwindLargeAngle ¶
Convert any into the range [-pi, pi] (slow)
ValidateHull ¶
This determines if a hull is valid. Checks for: convexity collinear points This is expensive and should not be called at runtime.
WeldJoint_GetAngularDampingRatio ¶
Get the weld joint angular damping ratio, non-dimensional
WeldJoint_GetAngularHertz ¶
Get the weld joint angular stiffness in Hertz
WeldJoint_GetLinearDampingRatio ¶
Get the weld joint linear damping ratio (non-dimensional)
WeldJoint_GetLinearHertz ¶
Get the weld joint linear stiffness in Hertz
WeldJoint_GetReferenceAngle ¶
Get the weld joint reference angle in radians
WeldJoint_SetAngularDampingRatio ¶
Set weld joint angular damping ratio, non-dimensional
WeldJoint_SetAngularHertz ¶
Set the weld joint angular stiffness in Hertz. 0 is rigid.
WeldJoint_SetLinearDampingRatio ¶
Set the weld joint linear damping ratio (non-dimensional)
WeldJoint_SetLinearHertz ¶
Set the weld joint linear stiffness in Hertz. 0 is rigid.
WeldJoint_SetReferenceAngle ¶
Set the weld joint reference angle in radians, must be in [-pi,pi].
WheelJoint_EnableLimit ¶
Enable/disable the wheel joint limit
WheelJoint_EnableMotor ¶
Enable/disable the wheel joint motor
WheelJoint_EnableSpring ¶
Enable/disable the wheel joint spring
WheelJoint_GetLowerLimit ¶
Get the wheel joint lower limit
WheelJoint_GetMaxMotorTorque ¶
Get the wheel joint maximum motor torque, usually in newton-meters
WheelJoint_GetMotorSpeed ¶
Get the wheel joint motor speed in radians per second
WheelJoint_GetMotorTorque ¶
Get the wheel joint current motor torque, usually in newton-meters
WheelJoint_GetSpringDampingRatio ¶
Get the wheel joint damping ratio, non-dimensional
WheelJoint_GetSpringHertz ¶
Get the wheel joint stiffness in Hertz
WheelJoint_GetUpperLimit ¶
Get the wheel joint upper limit
WheelJoint_IsLimitEnabled ¶
Is the wheel joint limit enabled?
WheelJoint_IsMotorEnabled ¶
Is the wheel joint motor enabled?
WheelJoint_IsSpringEnabled ¶
Is the wheel joint spring enabled?
WheelJoint_SetLimits ¶
Set the wheel joint limits
WheelJoint_SetMaxMotorTorque ¶
Set the wheel joint maximum motor torque, usually in newton-meters
WheelJoint_SetMotorSpeed ¶
Set the wheel joint motor speed in radians per second
WheelJoint_SetSpringDampingRatio ¶
Set the wheel joint damping ratio, non-dimensional
WheelJoint_SetSpringHertz ¶
Set the wheel joint stiffness in Hertz
World_CastMover ¶
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 ¶
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. The ray-cast ignores shapes that contain the starting point.
@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 ¶
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. This is less general than b2World_CastRay() and does not allow for custom filtering.
World_CastShape ¶
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 ¶
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 ¶
Call this to draw shapes and other debug draw data
World_DumpMemoryStats ¶
World_DumpMemoryStats :: proc "c" (worldId: WorldId) ---
Dump memory stats to box2d_memory.txt
World_EnableContinuous ¶
Enable/disable continuous collision between dynamic and static bodies. Generally you should keep continuous collision enabled to prevent fast moving objects from going through static objects. The performance gain from
disabling continuous collision is minor. @see WorldDef
World_EnableSleeping ¶
Enable/disable sleep. If your application does not need sleeping, you can gain some performance
by disabling sleep completely at the world level. @see WorldDef
World_EnableSpeculative ¶
This is for internal testing
World_EnableWarmStarting ¶
Enable/disable constraint warm starting. Advanced feature for testing. Disabling
warm starting greatly reduces stability and provides no performance gain.
World_Explode ¶
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 ¶
Get the number of awake bodies.
World_GetBodyEvents ¶
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 ¶
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 ¶
Get world counters and sizes
World_GetGravity ¶
Get the gravity vector
World_GetHitEventThreshold ¶
Get the hit event speed threshold. Usually in meters per second.
World_GetMaximumLinearSpeed ¶
Get the maximum linear speed. Usually in m/s.
World_GetProfile ¶
Get the current world performance profile
World_GetRestitutionThreshold ¶
Get the restitution speed threshold. Usually in meters per second.
World_GetSensorEvents ¶
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 ¶
Get the user data pointer.
World_IsContinuousEnabled ¶
Is continuous collision enabled?
World_IsSleepingEnabled ¶
Is body sleeping enabled?
World_IsValid ¶
World id validation. Provides validation for up to 64K allocations.
World_IsWarmStartingEnabled ¶
Is constraint warm starting enabled?
World_OverlapAABB ¶
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 ¶
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 ¶
World_RebuildStaticTree :: proc "c" (worldId: WorldId) ---
This is for internal testing
World_SetContactTuning ¶
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 ¶
World_SetCustomFilterCallback :: proc "c" (worldId: WorldId, fcn: CustomFilterFcn, ctx: rawptr) ---
Register the custom filter callback. This is optional.
World_SetFrictionCallback ¶
World_SetFrictionCallback :: proc "c" (worldId: WorldId, callback: FrictionCallback) ---
Set the friction callback. Passing nil resets to default.
World_SetGravity ¶
Set the gravity vector for the entire world. Box2D has no concept of an up direction and this is left as a decision for the application. Usually in m/s^2.
@see WorldDef
World_SetHitEventThreshold ¶
Adjust the hit event threshold. This controls the collision velocity needed to generate a b2ContactHitEvent. Usually in meters per second.
@see WorldDef::hitEventThreshold
World_SetJointTuning ¶
Adjust joint 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) @note Advanced feature
World_SetMaximumLinearSpeed ¶
Set the maximum linear speed. Usually in m/s.
World_SetPreSolveCallback ¶
World_SetPreSolveCallback :: proc "c" (worldId: WorldId, fcn: PreSolveFcn, ctx: rawptr) ---
Register the pre-solve callback. This is optional.
World_SetRestitutionCallback ¶
World_SetRestitutionCallback :: proc "c" (worldId: WorldId, callback: RestitutionCallback) ---
Set the restitution callback. Passing nil resets to default.
World_SetRestitutionThreshold ¶
Adjust the restitution threshold. It is recommended not to make this value very small
because it will prevent bodies from sleeping. Usually in meters per second. @see WorldDef
World_SetUserData ¶
Set the user data pointer.
World_Step ¶
Simulate a world for one time step. This performs collision detection, integration, and constraint solution. @param worldId The world to simulate @param timeStep The amount of time to simulate, this should be a fixed number. Usually 1/60. @param subStepCount The number of sub-steps, increasing the sub-step count can increase accuracy. Usually 4.
Procedure Groups
IsValid ¶
IsValid :: proc{ IsValidFloat, IsValidVec2, IsValidRotation, IsValidAABB, IsValidPlane, World_IsValid, Body_IsValid, Shape_IsValid, Chain_IsValid, Joint_IsValid, IsValidRay, }
Source Files
Generation Information
Generated with odin version dev-2025-05 (vendor "odin") Windows_amd64 @ 2025-05-06 21:13:12.590521300 +0000 UTC