package vendor:box2d
Index
Types (82)
- AABB
- AllocFcn
- AssertFcn
- BodyDef
- BodyEvents
- BodyId
- BodyMoveEvent
- BodyType
- Capsule
- CastOutput
- CastResultFcn
- ChainDef
- ChainId
- Circle
- ContactBeginTouchEvent
- ContactData
- ContactEndTouchEvent
- ContactEvents
- ContactHitEvent
- Counters
- CustomFilterFcn
- DebugDraw
- DistanceCache
- DistanceInput
- DistanceJointDef
- DistanceOutput
- DistanceProxy
- DynamicTree
- EnqueueTaskCallback
- Filter
- FinishTaskCallback
- FreeFcn
- HexColor
- Hull
- JointId
- JointType
- Manifold
- ManifoldPoint
- MassData
- Mat22
- MotorJointDef
- MouseJointDef
- OverlapResultFcn
- Polygon
- PreSolveFcn
- PrismaticJointDef
- Profile
- QueryFilter
- RayCastInput
- RayResult
- RevoluteJointDef
- Rot
- Segment
- SegmentDistanceResult
- SensorBeginTouchEvent
- SensorEndTouchEvent
- SensorEvents
- ShapeCastInput
- ShapeCastPairInput
- ShapeDef
- ShapeId
- ShapeType
- Simplex
- SimplexVertex
- SmoothSegment
- Sweep
- TOIInput
- TOIOutput
- TOIState
- TaskCallback
- Timer
- Transform
- TreeNode
- TreeQueryCallbackFcn
- TreeRayCastCallbackFcn
- TreeShapeCastCallbackFcn
- Vec2
- Version
- WeldJointDef
- WheelJointDef
- WorldDef
- WorldId
Variables (0)
This section is empty.
Procedures (417)
- AABB_Center
- AABB_Contains
- AABB_Extents
- AABB_Union
- Abs
- AbsFloat
- AbsInt
- Add
- Body_ApplyAngularImpulse
- Body_ApplyForce
- Body_ApplyForceToCenter
- Body_ApplyLinearImpulse
- Body_ApplyLinearImpulseToCenter
- Body_ApplyMassFromShapes
- Body_ApplyTorque
- Body_ComputeAABB
- Body_Disable
- Body_Enable
- Body_EnableHitEvents
- Body_EnableSleep
- Body_GetAngularDamping
- Body_GetAngularVelocity
- Body_GetAutomaticMass
- Body_GetContactCapacity
- Body_GetContactData
- Body_GetGravityScale
- Body_GetInertiaTensor
- Body_GetJointCount
- Body_GetJoints
- Body_GetLinearDamping
- Body_GetLinearVelocity
- Body_GetLocalCenterOfMass
- Body_GetLocalPoint
- Body_GetLocalVector
- Body_GetMass
- Body_GetMassData
- Body_GetPosition
- Body_GetRotation
- Body_GetShapeCount
- Body_GetShapes
- Body_GetSleepThreshold
- Body_GetTransform
- Body_GetType
- Body_GetUserData
- Body_GetWorldCenterOfMass
- Body_GetWorldPoint
- Body_GetWorldVector
- Body_IsAwake
- Body_IsBullet
- Body_IsEnabled
- Body_IsFixedRotation
- Body_IsSleepEnabled
- Body_IsValid
- Body_SetAngularDamping
- Body_SetAngularVelocity
- Body_SetAutomaticMass
- Body_SetAwake
- Body_SetBullet
- Body_SetFixedRotation
- Body_SetGravityScale
- Body_SetLinearDamping
- Body_SetLinearVelocity
- Body_SetMassData
- Body_SetSleepThreshold
- Body_SetTransform
- Body_SetType
- Body_SetUserData
- Chain_IsValid
- Chain_SetFriction
- Chain_SetRestitution
- Clamp
- ClampFloat
- ClampInt
- CollideCapsuleAndCircle
- CollideCapsules
- CollideCircles
- CollidePolygonAndCapsule
- CollidePolygonAndCircle
- CollidePolygons
- CollideSegmentAndCapsule
- CollideSegmentAndCircle
- CollideSegmentAndPolygon
- CollideSmoothSegmentAndCapsule
- CollideSmoothSegmentAndCircle
- CollideSmoothSegmentAndPolygon
- ComputeAngularVelocity
- ComputeCapsuleAABB
- ComputeCapsuleMass
- ComputeCircleAABB
- ComputeCircleMass
- ComputeHull
- ComputePolygonAABB
- ComputePolygonMass
- ComputeSegmentAABB
- CreateBody
- CreateCapsuleShape
- CreateChain
- CreateCircleShape
- CreateDistanceJoint
- CreateMotorJoint
- CreateMouseJoint
- CreatePolygonShape
- CreatePrismaticJoint
- CreateRevoluteJoint
- CreateSegmentShape
- CreateTimer
- CreateWeldJoint
- CreateWheelJoint
- CreateWorld
- Cross
- CrossSV
- CrossVS
- DefaultBodyDef
- DefaultChainDef
- DefaultDistanceJointDef
- DefaultFilter
- DefaultMotorJointDef
- DefaultMouseJointDef
- DefaultPrismaticJointDef
- DefaultQueryFilter
- DefaultRevoluteJointDef
- DefaultShapeDef
- DefaultWeldJointDef
- DefaultWheelJointDef
- DefaultWorldDef
- DestroyBody
- DestroyChain
- DestroyJoint
- DestroyShape
- DestroyWorld
- Distance
- DistanceJoint_EnableLimit
- DistanceJoint_EnableMotor
- DistanceJoint_EnableSpring
- DistanceJoint_GetCurrentLength
- DistanceJoint_GetDampingRatio
- DistanceJoint_GetHertz
- DistanceJoint_GetLength
- DistanceJoint_GetMaxLength
- DistanceJoint_GetMaxMotorForce
- DistanceJoint_GetMinLength
- DistanceJoint_GetMotorForce
- DistanceJoint_GetMotorSpeed
- 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_GetHeight
- DynamicTree_GetMaxBalance
- DynamicTree_GetProxyCount
- DynamicTree_GetUserData
- DynamicTree_MoveProxy
- DynamicTree_Query
- DynamicTree_RayCast
- DynamicTree_Rebuild
- DynamicTree_RebuildBottomUp
- DynamicTree_ShapeCast
- DynamicTree_ShiftOrigin
- DynamicTree_Validate
- Float_IsValid
- GetByteCount
- GetInverse22
- GetLengthAndNormalize
- GetLengthUnitsPerMeter
- GetMilliseconds
- GetMillisecondsAndReset
- GetSweepTransform
- GetTicks
- ID_EQUALS
- IS_NON_NULL
- IS_NULL
- IntegrateRotation
- InvMulRot
- InvMulTransforms
- InvRotateVector
- InvTransformPoint
- IsNormalized
- IsValidRay
- Joint_GetBodyA
- Joint_GetBodyB
- Joint_GetCollideConnected
- Joint_GetConstraintForce
- Joint_GetConstraintTorque
- Joint_GetLocalAnchorA
- Joint_GetLocalAnchorB
- Joint_GetType
- Joint_GetUserData
- Joint_IsValid
- Joint_SetCollideConnected
- Joint_SetUserData
- Joint_WakeBodies
- LeftPerp
- Length
- LengthSquared
- Lerp
- MakeBox
- MakeOffsetBox
- MakeOffsetPolygon
- 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
- PointInCapsule
- PointInCircle
- PointInPolygon
- PrismaticJoint_EnableLimit
- PrismaticJoint_EnableMotor
- PrismaticJoint_EnableSpring
- PrismaticJoint_GetLowerLimit
- PrismaticJoint_GetMaxMotorForce
- PrismaticJoint_GetMotorForce
- PrismaticJoint_GetMotorSpeed
- PrismaticJoint_GetSpringDampingRatio
- PrismaticJoint_GetSpringHertz
- 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_SetLimits
- RevoluteJoint_SetMaxMotorTorque
- RevoluteJoint_SetMotorSpeed
- RevoluteJoint_SetSpringDampingRatio
- RevoluteJoint_SetSpringHertz
- RightPerp
- Rot_GetAngle
- Rot_GetXAxis
- Rot_GetYAxis
- Rot_IsValid
- 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_GetCircle
- Shape_GetClosestPoint
- Shape_GetContactCapacity
- Shape_GetContactData
- Shape_GetDensity
- Shape_GetFilter
- Shape_GetFriction
- Shape_GetParentChain
- Shape_GetPolygon
- Shape_GetRestitution
- Shape_GetSegment
- Shape_GetSmoothSegment
- Shape_GetType
- Shape_GetUserData
- Shape_IsSensor
- Shape_IsValid
- Shape_RayCast
- Shape_SetCapsule
- Shape_SetCircle
- Shape_SetDensity
- Shape_SetFilter
- Shape_SetFriction
- Shape_SetPolygon
- Shape_SetRestitution
- Shape_SetSegment
- Shape_SetUserData
- Shape_TestPoint
- SleepMilliseconds
- Solve22
- Sub
- TimeOfImpact
- TransformPoint
- TransformPolygon
- UnwindAngle
- ValidateHull
- Vec2_IsValid
- WeldJoint_GetAngularDampingRatio
- WeldJoint_GetAngularHertz
- WeldJoint_GetLinearDampingRatio
- WeldJoint_GetLinearHertz
- WeldJoint_SetAngularDampingRatio
- WeldJoint_SetAngularHertz
- WeldJoint_SetLinearDampingRatio
- WeldJoint_SetLinearHertz
- 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_CastCapsule
- World_CastCircle
- World_CastPolygon
- World_CastRay
- World_CastRayClosest
- World_Draw
- World_DumpMemoryStats
- World_EnableContinuous
- World_EnableSleeping
- World_EnableWarmStarting
- World_Explode
- World_GetBodyEvents
- World_GetContactEvents
- World_GetCounters
- World_GetGravity
- World_GetProfile
- World_GetSensorEvents
- World_IsValid
- World_OverlapAABB
- World_OverlapCapsule
- World_OverlapCircle
- World_OverlapPolygon
- World_SetContactTuning
- World_SetCustomFilterCallback
- World_SetGravity
- World_SetHitEventThreshold
- World_SetPreSolveCallback
- World_SetRestitutionThreshold
- 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
- World_OverlapAABB
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. Typically in meters per second. linearVelocity: [2]f32, // The initial angular velocity of the body. Radians per second. angularVelocity: f32, // Linear damping is use 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 use 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 velocity threshold, default is 0.05 meter per second sleepThreshold: f32, // 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, // Automatically compute mass and related properties on this body from shapes. // Triggers whenever a shape is add/removed/changed. Default is true. automaticMass: 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_EnableHitEvents
- Body_EnableSleep
- Body_GetAngularDamping
- Body_GetAngularVelocity
- Body_GetAutomaticMass
- Body_GetContactCapacity
- Body_GetContactData
- Body_GetGravityScale
- Body_GetInertiaTensor
- Body_GetJointCount
- Body_GetJoints
- Body_GetLinearDamping
- Body_GetLinearVelocity
- Body_GetLocalCenterOfMass
- Body_GetLocalPoint
- Body_GetLocalVector
- Body_GetMass
- Body_GetMassData
- Body_GetPosition
- Body_GetRotation
- Body_GetShapeCount
- Body_GetShapes
- Body_GetSleepThreshold
- Body_GetTransform
- Body_GetType
- Body_GetUserData
- Body_GetWorldCenterOfMass
- Body_GetWorldPoint
- Body_GetWorldVector
- Body_IsAwake
- Body_IsBullet
- Body_IsEnabled
- Body_IsFixedRotation
- Body_IsSleepEnabled
- Body_IsValid
- Body_SetAngularDamping
- Body_SetAngularVelocity
- Body_SetAutomaticMass
- Body_SetAwake
- Body_SetBullet
- Body_SetFixedRotation
- Body_SetGravityScale
- Body_SetLinearDamping
- Body_SetLinearVelocity
- Body_SetMassData
- Body_SetSleepThreshold
- Body_SetTransform
- Body_SetType
- Body_SetUserData
- CreateCapsuleShape
- CreateChain
- CreateCircleShape
- CreatePolygonShape
- CreateSegmentShape
- DestroyBody
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
BodyMoveEvent ¶
BodyMoveEvent :: struct { transform: Transform, bodyId: BodyId, userData: rawptr, fellAsleep: bool, }
Body move events triggered when a body moves. Triggered when a body moves due to simulation. Not reported for bodies moved by the user. This also has a flag to indicate that the body went to sleep so the application can also sleep that actor/entity/object associated with the body. On the other hand if the flag does not indicate the body went to sleep then the application can treat the actor/entity/object associated with the body as awake.
This is an efficient way for an application to update game object transforms rather than calling functions such as b2Body_GetTransform() because this data is delivered as a contiguous array and it is only populated with bodies that have moved. @note If sleeping is disabled all dynamic and kinematic bodies will trigger move events.
BodyType ¶
BodyType :: enum i32 { // zero mass, zero velocity, may be manually moved staticBody = 0, // zero mass, velocity set by user, moved by solver kinematicBody = 1, // positive mass, velocity determined by forces, moved by solver dynamicBody = 2, }
The body simulation type. Each body is one of these three types. The type determines how the body behaves in the simulation. @ingroup body
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
- CollidePolygonAndCapsule
- CollideSegmentAndCapsule
- CollideSmoothSegmentAndCapsule
- ComputeCapsuleAABB
- ComputeCapsuleMass
- CreateCapsuleShape
- PointInCapsule
- RayCastCapsule
- ShapeCastCapsule
- Shape_SetCapsule
- World_CastCapsule
- World_OverlapCapsule
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, // The friction coefficient, usually in the range [0,1]. friction: f32, // The restitution (elasticity) usually in the range [0,1]. restitution: f32, // Contact filtering data. filter: Filter, // Indicates a closed chain formed by connecting the first and last points isLoop: bool, // Used internally to detect a valid definition. DO NOT SET. internalValue: i32, }
Used to create a chain of edges. 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 - 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_linearSlop - 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 smooth edges 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_IsValid
- Chain_SetFriction
- Chain_SetRestitution
- DestroyChain
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
Circle ¶
A solid circle
Related Procedures With Parameters
- CollideCapsuleAndCircle
- CollideCircles
- CollidePolygonAndCircle
- CollideSegmentAndCircle
- CollideSmoothSegmentAndCircle
- ComputeCircleAABB
- ComputeCircleMass
- CreateCircleShape
- PointInCircle
- RayCastCircle
- ShapeCastCircle
- Shape_SetCircle
- World_CastCircle
- World_OverlapCircle
Related Procedures With Returns
ContactBeginTouchEvent ¶
ContactBeginTouchEvent :: struct { // Id of the first shape shapeIdA: ShapeId, // Id of the second shape shapeIdB: ShapeId, }
A begin touch event is generated when two shapes begin touching.
ContactData ¶
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 shapeIdA: ShapeId, // Id of the second shape shapeIdB: ShapeId, }
An end touch event is generated when two shapes stop touching.
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.
Counters ¶
Counters :: struct { staticBodyCount: i32, 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. DrawPolygon: proc "c" (vertices: [^][2]f32, vertexCount: i32, color: HexColor, ctx: rawptr), // Draw a solid closed polygon provided in CCW order. DrawSolidPolygon: proc "c" (transform: Transform, vertices: [^][2]f32, vertexCount: i32, radius: f32, colr: HexColor, ctx: rawptr), // Draw a circle. DrawCircle: proc "c" (center: [2]f32, radius: f32, color: HexColor, ctx: rawptr), // Draw a solid circle. DrawSolidCircle: proc "c" (transform: Transform, radius: f32, color: HexColor, ctx: rawptr), // Draw a capsule. DrawCapsule: proc "c" (p1, p2: [2]f32, radius: f32, color: HexColor, ctx: rawptr), // Draw a solid capsule. DrawSolidCapsule: proc "c" (p1, p2: [2]f32, radius: f32, color: HexColor, ctx: rawptr), // Draw a line segment. DrawSegment: proc "c" (p1, p2: [2]f32, color: HexColor, ctx: rawptr), // Draw a transform. Choose your own length scale. DrawTransform: proc "c" (transform: Transform, ctx: rawptr), // Draw a point. DrawPoint: proc "c" (p: [2]f32, size: f32, color: HexColor, ctx: rawptr), // Draw a string. DrawString: proc "c" (p: [2]f32, s: cstring, 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 drawAABBs: bool, // Option to draw the mass and center of mass of dynamic bodies drawMass: 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 friction impulses drawFrictionImpulses: 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
DistanceCache ¶
DistanceCache :: 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 b2Distance. Set count to zero on first call or
use zero initialization.
Related Procedures With Parameters
Related Constants
DistanceInput ¶
DistanceInput :: struct { // The proxy for shape A proxyA: DistanceProxy, // The proxy for shape B proxyB: DistanceProxy, // 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 distance: f32, // The final distance, zero if overlapped iterations: i32, // Number of GJK iterations used simplexCount: i32, }
Output for b2ShapeDistance
Related Procedures With Returns
DistanceProxy ¶
DistanceProxy :: struct { // The point cloud points: [8][2]f32 `fmt:"v,count"`, // The number of points count: i32, // The external radius of the point cloud radius: f32, }
A distance proxy is used by the GJK algorithm. It encapsulates any shape.
Related Procedures With Returns
DynamicTree ¶
DynamicTree :: struct { // The tree nodes nodes: [^]TreeNode `fmt"v,nodeCount"`, // 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_GetHeight
- DynamicTree_GetMaxBalance
- DynamicTree_GetProxyCount
- DynamicTree_GetUserData
- DynamicTree_MoveProxy
- DynamicTree_Query
- DynamicTree_RayCast
- DynamicTree_Rebuild
- DynamicTree_RebuildBottomUp
- DynamicTree_ShapeCast
- DynamicTree_ShiftOrigin
- DynamicTree_Validate
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
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 u32 { // Static = 0x00000001, // Dynamic = 0x00000002, // Debris = 0x00000004, // Player = 0x00000008, // // etc // }; // @endcode // Or use a bit_set. categoryBits: u32, // 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 = u32(My_Categories.Static | My_Categories.Player); // @endcode maskBits: u32, // 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
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
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 = 12500670, Gray1 = 1710618, Gray2 = 3355443, Gray3 = 5066061, Gray4 = 6710886, Gray5 = 8355711, Gray6 = 10066329, Gray7 = 11776947, Gray8 = 13421772, Gray9 = 15066597, Green = 65280, 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, LightGoldenrod = 15654274, LightGoldenrodYellow = 16448210, LightGray = 13882323, LightGreen = 9498256, LightPink = 16758465, LightSalmon = 16752762, LightSeaGreen = 2142890, LightSkyBlue = 8900346, LightSlateBlue = 8679679, LightSlateGray = 7833753, LightSteelBlue = 11584734, LightYellow = 16777184, Lime = 65280, LimeGreen = 3329330, Linen = 16445670, Magenta = 16711935, Maroon = 11546720, 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, NavyBlue = 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 = 10494192, 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, VioletRed = 13639824, 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.
See https://www.rapidtables.com/web/color/index.html
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_GetDampingRatio
- DistanceJoint_GetHertz
- DistanceJoint_GetLength
- DistanceJoint_GetMaxLength
- DistanceJoint_GetMaxMotorForce
- DistanceJoint_GetMinLength
- DistanceJoint_GetMotorForce
- DistanceJoint_GetMotorSpeed
- 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_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_GetSpringDampingRatio
- PrismaticJoint_GetSpringHertz
- 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_SetLimits
- RevoluteJoint_SetMaxMotorTorque
- RevoluteJoint_SetMotorSpeed
- RevoluteJoint_SetSpringDampingRatio
- RevoluteJoint_SetSpringHertz
- WeldJoint_GetAngularDampingRatio
- WeldJoint_GetAngularHertz
- WeldJoint_GetLinearDampingRatio
- WeldJoint_GetLinearHertz
- WeldJoint_SetAngularDampingRatio
- WeldJoint_SetAngularHertz
- WeldJoint_SetLinearDampingRatio
- WeldJoint_SetLinearHertz
- 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
- CreateMotorJoint
- CreateMouseJoint
- CreatePrismaticJoint
- CreateRevoluteJoint
- CreateWeldJoint
- CreateWheelJoint
Related Constants
JointType ¶
JointType :: enum i32 { distanceJoint, 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 manifold points, up to two are possible in 2D points: [2]ManifoldPoint, // The unit normal vector in world space, points from shape A to bodyB normal: [2]f32, // The number of contacts points, will be 0, 1, or 2 pointCount: i32, }
A contact manifold describes the contact points between colliding shapes
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 bodyA's origin in world space // @note When used internally to the Box2D solver, these are relative to the center of mass. anchorA: [2]f32, // Location of the contact point relative to bodyB's origin in world space anchorB: [2]f32, // The separation of the contact point, negative if penetrating separation: f32, // The impulse along the manifold normal vector. normalImpulse: 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.
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. 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
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 maxPolygonVertices. 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
- CollidePolygonAndCapsule
- CollidePolygonAndCircle
- CollidePolygons
- CollideSegmentAndPolygon
- CollideSmoothSegmentAndPolygon
- ComputePolygonAABB
- ComputePolygonMass
- CreatePolygonShape
- PointInPolygon
- RayCastPolygon
- ShapeCastPolygon
- Shape_SetPolygon
- TransformPolygon
- World_CastPolygon
- World_OverlapPolygon
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, buildIslands: f32, solveConstraints: f32, prepareTasks: f32, solverTasks: f32, prepareConstraints: f32, integrateVelocities: f32, warmStart: f32, solveVelocities: f32, integratePositions: f32, relaxVelocities: f32, applyRestitution: f32, storeImpulses: f32, finalizeBodies: f32, splitIslands: f32, sleepIslands: f32, hitEvents: f32, broadphase: f32, continuous: 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: u32, // The collision mask bits. This states the shape categories that this // query would accept for collision. maskBits: u32, }
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_CastCapsule
- World_CastCircle
- World_CastPolygon
- World_CastRay
- World_CastRayClosest
- World_OverlapAABB
- World_OverlapCapsule
- World_OverlapCircle
- World_OverlapPolygon
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
- IsValid (procedure groups)
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 lowerAngle: f32, // The upper angle for the joint limit in 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
- IsNormalized
- MulRot
- NLerp
- NormalizeRot
- RelativeAngle
- Rot_GetAngle
- Rot_GetXAxis
- Rot_GetYAxis
- Rot_IsValid
- 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.
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 point cloud to cast points: [8][2]f32 `fmt:"v,count"`, // The number of points count: i32, // The radius around the point cloud radius: f32, // The translation of the shape cast translation: [2]f32, // The maximum fraction of the translation to consider, typically 1 maxFraction: f32, }
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: DistanceProxy, // The proxy for shape A proxyB: DistanceProxy, // 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, }
Input parameters for b2ShapeCast
Related Procedures With Parameters
ShapeDef ¶
ShapeDef :: struct { // Use this to store application specific shape data. userData: rawptr, // The Coulomb (dry) friction coefficient, usually in the range [0,1]. friction: f32, // The restitution (bounce) usually in the range [0,1]. restitution: f32, // The density, usually in kg/m^2. density: f32, // Collision filtering data. filter: Filter, // Custom debug draw color. customColor: u32, // A sensor shape generates overlap events but never generates a collision response. isSensor: bool, // Enable sensor events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. enableSensorEvents: bool, // Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. enableContactEvents: bool, // Enable hit events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. 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, // Normally shapes on static bodies don't invoke contact creation when they are added to the world. This overrides // that behavior and causes contact creation. This significantly slows down static body creation which can be important // when there are many static shapes. forceContactCreation: 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
- DestroyShape
- Shape_AreContactEventsEnabled
- Shape_AreHitEventsEnabled
- Shape_ArePreSolveEventsEnabled
- Shape_AreSensorEventsEnabled
- Shape_EnableContactEvents
- Shape_EnableHitEvents
- Shape_EnablePreSolveEvents
- Shape_EnableSensorEvents
- Shape_GetAABB
- Shape_GetBody
- Shape_GetCapsule
- Shape_GetCircle
- Shape_GetClosestPoint
- Shape_GetContactCapacity
- Shape_GetContactData
- Shape_GetDensity
- Shape_GetFilter
- Shape_GetFriction
- Shape_GetParentChain
- Shape_GetPolygon
- Shape_GetRestitution
- Shape_GetSegment
- Shape_GetSmoothSegment
- Shape_GetType
- Shape_GetUserData
- Shape_IsSensor
- Shape_IsValid
- Shape_RayCast
- Shape_SetCapsule
- Shape_SetCircle
- Shape_SetDensity
- Shape_SetFilter
- Shape_SetFriction
- Shape_SetPolygon
- Shape_SetRestitution
- Shape_SetSegment
- Shape_SetUserData
- Shape_TestPoint
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
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 smooth segment owned by a chain shape smoothSegmentShape, }
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
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
SmoothSegment ¶
SmoothSegment :: 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 smooth 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
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: DistanceProxy, // The proxy for shape A proxyB: DistanceProxy, // The proxy for shape B sweepA: Sweep, // The movement of shape A sweepB: Sweep, // The movement of shape B tMax: 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
Timer ¶
Timer :: struct { start: i64, }
Timer for profiling. This has platform specific code and may not work on every platform.
Related Procedures With Parameters
Related Procedures With Returns
Transform ¶
Related Procedures With Parameters
- CollideCapsuleAndCircle
- CollideCapsules
- CollideCircles
- CollidePolygonAndCapsule
- CollidePolygonAndCircle
- CollidePolygons
- CollideSegmentAndCapsule
- CollideSegmentAndCircle
- CollideSegmentAndPolygon
- CollideSmoothSegmentAndCapsule
- CollideSmoothSegmentAndCircle
- CollideSmoothSegmentAndPolygon
- ComputeCapsuleAABB
- ComputeCircleAABB
- ComputePolygonAABB
- ComputeSegmentAABB
- InvMulTransforms
- InvTransformPoint
- MakeOffsetPolygon
- MulTransforms
- TransformPoint
- TransformPolygon
- World_CastCapsule
- World_CastCircle
- World_CastPolygon
- World_OverlapCapsule
- World_OverlapCircle
- World_OverlapPolygon
Related Procedures With Returns
Related Constants
TreeNode ¶
TreeNode :: struct { // The node bounding box aabb: AABB, // Category bits for collision filtering categoryBits: u32, // 4 using _: struct #raw_union { // The node parent index parent: i32, // The node freelist next index next: i32, }, // Child 1 index child1: i32, // Child 2 index child2: i32, // User data // todo could be union with child index userData: i32, // Leaf = 0, free node = -1 height: i16, // Has the AABB been enlarged? enlarged: bool, // Padding for clarity _: [9]u8, }
A node in the dynamic tree. This is private data placed here for performance reasons. 16 + 16 + 8 + pad(8)
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: i32, 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: i32, 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
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 velocity threshold, usually in m/s. Collisions above this // speed have restitution applied (will bounce). restitutionThreshold: f32, // This parameter controls how fast overlap is resolved and has units of meters per second contactPushoutVelocity: f32, // Threshold velocity for hit events. Usually meters per second. hitEventThreshold: f32, // Contact stiffness. Cycles per second. contactHertz: f32, // Contact bounciness. Non-dimensional. contactDampingRatio: f32, // Joint stiffness. Cycles per second. jointHertz: f32, // Joint bounciness. Non-dimensional. jointDampingRatio: f32, // Can bodies go to sleep to improve performance enableSleep: bool, // Enable continuous collision enableContinous: 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. 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, // 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
- CreateMotorJoint
- CreateMouseJoint
- CreatePrismaticJoint
- CreateRevoluteJoint
- CreateWeldJoint
- CreateWheelJoint
- DestroyWorld
- World_CastCapsule
- World_CastCircle
- World_CastPolygon
- World_CastRay
- World_CastRayClosest
- World_Draw
- World_DumpMemoryStats
- World_EnableContinuous
- World_EnableSleeping
- World_EnableWarmStarting
- World_Explode
- World_GetBodyEvents
- World_GetContactEvents
- World_GetCounters
- World_GetGravity
- World_GetProfile
- World_GetSensorEvents
- World_IsValid
- World_OverlapAABB
- World_OverlapCapsule
- World_OverlapCircle
- World_OverlapPolygon
- World_SetContactTuning
- World_SetCustomFilterCallback
- World_SetGravity
- World_SetHitEventThreshold
- World_SetPreSolveCallback
- World_SetRestitutionThreshold
- World_Step
- IsValid (procedure groups)
Related Procedures With Returns
Related Constants
Constants
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}
defaultCategoryBits ¶
defaultCategoryBits :: 0x00000001
The default category bit for a tree proxy. Used for collision filtering.
defaultMaskBits ¶
defaultMaskBits :: 0xFFFFFFFF
Convenience mask bits to use when you don't need collision filtering and just want
all results.
emptyDistanceCache ¶
emptyDistanceCache :: DistanceCache{}
maxPolygonVertices ¶
maxPolygonVertices :: 8
The maximum number of vertices on a convex polygon. Changing this affects performance even if you
don't use more vertices.
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, typically 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, typically 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, typically 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, typically 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), typically 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_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_GetAutomaticMass ¶
Get the automatic mass setting
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_GetInertiaTensor ¶
Get the inertia tensor of the body, typically in kg*m^2
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. Typically 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_GetLocalVector ¶
Get a local vector on a body given a world vector
Body_GetMass ¶
Get the mass of the body, typically in kilograms
Body_GetMassData ¶
Get the mass data for a body
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_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, typically 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_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_SetAutomaticMass ¶
Set the automatic mass setting. Normally this is set in BodyDef before creation.
@see BodyDef::automaticMass
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. Typically 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_SetSleepThreshold ¶
Set the sleep threshold, typically in meters per second
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_IsValid ¶
Chain identifier validation. Provides validation for up to 64K allocations.
Chain_SetFriction ¶
Set the chain friction @see b2ChainDef::friction
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
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
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
CollideSmoothSegmentAndCapsule ¶
CollideSmoothSegmentAndCapsule :: proc "c" (#by_ptr smoothSegmentA: SmoothSegment, xfA: Transform, #by_ptr capsuleB: Capsule, xfB: Transform, cache: ^DistanceCache) -> Manifold ---
Compute the contact manifold between an segment and a capsule
CollideSmoothSegmentAndCircle ¶
CollideSmoothSegmentAndCircle :: proc "c" (#by_ptr smoothSegmentA: SmoothSegment, xfA: Transform, #by_ptr circleB: Circle, xfB: Transform) -> Manifold ---
Compute the contact manifold between a smooth segment and a circle
CollideSmoothSegmentAndPolygon ¶
CollideSmoothSegmentAndPolygon :: proc "c" (#by_ptr smoothSegmentA: SmoothSegment, xfA: Transform, #by_ptr polygonB: Polygon, xfB: Transform, cache: ^DistanceCache) -> Manifold ---
Compute the contact manifold between a smooth segment and a rounded 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 maxPolygonVertices 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
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
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
CreateTimer ¶
CreateTimer :: proc "c" () -> Timer ---
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
DefaultDistanceJointDef ¶
DefaultDistanceJointDef :: proc "c" () -> DistanceJointDef ---
Use this to initialize your joint definition @ingroup distance_joint
DefaultFilter ¶
DefaultFilter :: proc "c" () -> Filter ---
Use this to initialize your filter @ingroup shape
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
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.
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_GetDampingRatio ¶
Get the spring damping ratio
DistanceJoint_GetHertz ¶
Get the spring Hertz
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, typically in newtons
DistanceJoint_GetMinLength ¶
Get the distance joint minimum length
DistanceJoint_GetMotorForce ¶
Get the distance joint current motor force, typically in newtons
DistanceJoint_GetMotorSpeed ¶
Get the distance joint motor speed, typically in meters per second
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, typically in newtons
DistanceJoint_SetMotorSpeed ¶
Set the distance joint motor speed, typically 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: u32, userData: i32) -> 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 "contextless" (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_GetHeight ¶
DynamicTree_GetHeight :: proc "c" (#by_ptr tree: DynamicTree) -> i32 ---
Compute the height of the binary tree in O(N) time. Should not be called often.
DynamicTree_GetMaxBalance ¶
DynamicTree_GetMaxBalance :: proc "c" (#by_ptr tree: DynamicTree) -> i32 ---
Get the maximum balance of the tree. The balance is the difference in height of the two children of a node.
DynamicTree_GetProxyCount ¶
DynamicTree_GetProxyCount :: proc "c" (#by_ptr tree: DynamicTree) -> i32 ---
Get the number of proxies created
DynamicTree_GetUserData ¶
DynamicTree_GetUserData :: proc "contextless" (tree: DynamicTree, proxyId: i32) -> i32 {…}
Get proxy user data @return the proxy user data or 0 if the id is invalid
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: u32, callback: TreeQueryCallbackFcn, ctx: rawptr) ---
Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.
DynamicTree_RayCast ¶
DynamicTree_RayCast :: proc "c" (#by_ptr tree: DynamicTree, #by_ptr input: RayCastInput, maskBits: u32, callback: TreeRayCastCallbackFcn, ctx: rawptr) ---
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. @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 ray
@param context user context that is passed to the callback
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_RebuildBottomUp ¶
DynamicTree_RebuildBottomUp :: proc "c" (tree: ^DynamicTree) ---
Build an optimal tree. Very expensive. For testing.
DynamicTree_ShapeCast ¶
DynamicTree_ShapeCast :: proc "c" (#by_ptr tree: DynamicTree, #by_ptr input: ShapeCastInput, maskBits: u32, callback: TreeShapeCastCallbackFcn, ctx: rawptr) ---
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
DynamicTree_ShiftOrigin ¶
DynamicTree_ShiftOrigin :: proc "c" (tree: ^DynamicTree, newOrigin: [2]f32) ---
Shift the world origin. Useful for large worlds. The shift formula is: position -= newOrigin @param tree the tree to shift @param newOrigin the new origin with respect to the old origin
DynamicTree_Validate ¶
DynamicTree_Validate :: proc "c" (#by_ptr tree: DynamicTree) ---
Validate this tree. For testing.
GetInverse22 ¶
Get the inverse of a 2-by-2 matrix
GetLengthUnitsPerMeter ¶
GetLengthUnitsPerMeter :: proc "c" () -> f32 ---
Get the current length units per meter.
GetSweepTransform ¶
Evaluate the transform sweep at a specific time.
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 ¶
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)
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
Joint_GetConstraintTorque ¶
Get the current constraint torque for this joint
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_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/
MakeBox ¶
Make a box (rectangle) polygon, bypassing the need for a convex hull.
MakeOffsetBox ¶
Make an offset box, bypassing the need for a convex hull.
MakeOffsetPolygon ¶
MakeOffsetPolygon :: proc "c" (#by_ptr hull: Hull, radius: f32, transform: Transform) -> 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" (vertices: [][2]f32, radius: f32) -> DistanceProxy {…}
Make a proxy for use in GJK and related functions.
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, typically in [0, 1]
MotorJoint_GetLinearOffset ¶
Get the motor joint linear offset target
MotorJoint_GetMaxForce ¶
Get the motor joint maximum force, typically in newtons
MotorJoint_GetMaxTorque ¶
Get the motor joint maximum torque, typically in newton-meters
MotorJoint_SetAngularOffset ¶
Set the motor joint angular offset target in radians
MotorJoint_SetCorrectionFactor ¶
Set the motor joint correction factor, typically in [0, 1]
MotorJoint_SetLinearOffset ¶
Set the motor joint linear offset target
MotorJoint_SetMaxForce ¶
Set the motor joint maximum force, typically in newtons
MotorJoint_SetMaxTorque ¶
Set the motor joint maximum torque, typically in newton-meters
MouseJoint_GetMaxForce ¶
Get the mouse joint maximum force, typically 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, typically 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 ¶
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/
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, typically in newtons
PrismaticJoint_GetMotorForce ¶
Get the prismatic joint current motor force, typically in newtons
PrismaticJoint_GetMotorSpeed ¶
Get the prismatic joint motor speed, typically in meters per second
PrismaticJoint_GetSpringDampingRatio ¶
Get the prismatic spring damping ratio (non-dimensional)
PrismaticJoint_GetSpringHertz ¶
Get the prismatic joint stiffness in Hertz
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, typically in newtons
PrismaticJoint_SetMotorSpeed ¶
Set the prismatic joint motor speed, typically 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, typically in newton-meters
RevoluteJoint_GetMotorSpeed ¶
Get the revolute joint motor speed in radians per second
RevoluteJoint_GetMotorTorque ¶
Get the revolute joint current motor torque, typically 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_SetLimits ¶
Set the revolute joint limits in radians
RevoluteJoint_SetMaxMotorTorque ¶
Set the revolute joint maximum motor torque, typically 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. @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.
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" (cache: ^DistanceCache, #by_ptr input: DistanceInput, simplexes: []Simplex) -> DistanceOutput {…}
Compute the closest points between two shapes represented as point clouds. DistanceCache cache is input/output. On the first call set DistanceCache.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
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. Only applies to kinematic and dynamic bodies. Ignored for sensors.
@see b2ShapeDef::isSensor
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_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, typically in kg/m^2
Shape_GetFilter ¶
Get the shape filter
Shape_GetFriction ¶
Get the friction of a shape
Shape_GetParentChain ¶
Get the parent chain id if the shape type is b2_smoothSegmentShape, 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_GetSmoothSegment ¶
Shape_GetSmoothSegment :: proc "c" (shapeId: ShapeId) -> SmoothSegment ---
Get a copy of the shape's smooth line segment. These come from chain shapes. Asserts the type is correct.
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_IsSensor ¶
Returns true If the shape is a sensor
Shape_IsValid ¶
Shape identifier validation. Provides validation for up to 64K allocations.
Shape_RayCast ¶
Shape_RayCast :: proc "c" (shapeId: ShapeId, origin: [2]f32, translation: [2]f32) -> 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, typically in kg/m^2.
This will not 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.
@see b2ShapeDef::filter
Shape_SetFriction ¶
Set the friction on a shape
@see b2ShapeDef::friction
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
SleepMilliseconds ¶
SleepMilliseconds :: proc "c" (milliseconds: i32) ---
Solve22 ¶
Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse in one-shot cases.
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]
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_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.
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, typically in newton-meters
WheelJoint_GetMotorSpeed ¶
Get the wheel joint motor speed in radians per second
WheelJoint_GetMotorTorque ¶
Get the wheel joint current motor torque, typically 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, typically 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_CastCapsule ¶
World_CastCapsule :: proc "c" ( worldId: WorldId, #by_ptr capsule: Capsule, originTransform: Transform, translation: [2]f32, filter: QueryFilter, fcn: CastResultFcn, ctx: rawptr, ) ---
Cast a capsule through the world. Similar to a cast ray except that a capsule is cast instead of a point.
World_CastCircle ¶
World_CastCircle :: proc "c" ( worldId: WorldId, #by_ptr circle: Circle, originTransform: Transform, translation: [2]f32, filter: QueryFilter, fcn: CastResultFcn, ctx: rawptr, ) ---
Cast a circle through the world. Similar to a cast ray except that a circle is cast instead of a point.
World_CastPolygon ¶
World_CastPolygon :: proc "c" ( worldId: WorldId, #by_ptr polygon: Polygon, originTransform: Transform, translation: [2]f32, filter: QueryFilter, fcn: CastResultFcn, ctx: rawptr, ) ---
Cast a polygon through the world. Similar to a cast ray except that a polygon is cast instead of a point.
World_CastRay ¶
World_CastRay :: proc "c" ( worldId: WorldId, origin: [2]f32, translation: [2]f32, filter: QueryFilter, fcn: CastResultFcn, ctx: rawptr, ) ---
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.
@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
@note The callback function may receive shapes in any order
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_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_EnableWarmStarting ¶
Enable/disable constraint warm starting. Advanced feature for testing. Disabling
sleeping greatly reduces stability and provides no performance gain.
World_Explode ¶
Apply a radial explosion
@param worldId The world id @param position The center of the explosion @param radius The radius of the explosion @param impulse The impulse of the explosion, typically in kg * m / s or N * s.
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_GetProfile ¶
Get the current world performance profile
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_IsValid ¶
World id validation. Provides validation for up to 64K allocations.
World_OverlapAABB ¶
World_OverlapAABB :: proc "c" (worldId: WorldId, aabb: AABB, filter: QueryFilter, fcn: OverlapResultFcn, ctx: rawptr) ---
Overlap test for all shapes that potentially overlap the provided AABB
World_OverlapCapsule ¶
World_OverlapCapsule :: proc "c" ( worldId: WorldId, #by_ptr capsule: Capsule, transform: Transform, filter: QueryFilter, fcn: OverlapResultFcn, ctx: rawptr, ) ---
Overlap test for all shapes that overlap the provided capsule
World_OverlapCircle ¶
World_OverlapCircle :: proc "c" ( worldId: WorldId, #by_ptr circle: Circle, transform: Transform, filter: QueryFilter, fcn: OverlapResultFcn, ctx: rawptr, ) ---
Overlap test for for all shapes that overlap the provided circle
World_OverlapPolygon ¶
World_OverlapPolygon :: proc "c" ( worldId: WorldId, #by_ptr polygon: Polygon, transform: Transform, filter: QueryFilter, fcn: OverlapResultFcn, ctx: rawptr, ) ---
Overlap test for all shapes that overlap the provided polygon
World_SetContactTuning ¶
World_SetContactTuning :: proc "c" (worldId: WorldId, hertz: f32, dampingRatio: f32, pushVelocity: 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 pushVelocity The maximum contact constraint push out velocity (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_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. Typically in m/s^2.
@see WorldDef
World_SetHitEventThreshold ¶
Adjust the hit event threshold. This controls the collision velocity needed to generate a b2ContactHitEvent. Typically in meters per second.
@see WorldDef::hitEventThreshold
World_SetPreSolveCallback ¶
World_SetPreSolveCallback :: proc "c" (worldId: WorldId, fcn: PreSolveFcn, ctx: rawptr) ---
Register the pre-solve callback. This is optional.
World_SetRestitutionThreshold ¶
Adjust the restitution threshold. It is recommended not to make this value very small
because it will prevent bodies from sleeping. Typically in meters per second. @see WorldDef
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. Typically 1/60. @param subStepCount The number of sub-steps, increasing the sub-step count can increase accuracy. Typically 4.
Procedure Groups
IsValid ¶
IsValid :: proc{ Float_IsValid, Vec2_IsValid, Rot_IsValid, World_IsValid, Body_IsValid, Shape_IsValid, Chain_IsValid, Joint_IsValid, IsValidRay, }
Source Files
Generation Information
Generated with odin version dev-2024-11 (vendor "odin") Windows_amd64 @ 2024-11-20 21:11:51.693633600 +0000 UTC