Expand description
Rigid bodies: create, destroy, and configure simulation state.
Use create_body with a crate::types::BodyDef (from
crate::types::default_body_def) to add a body to a crate::world::World.
Attach collision with crate::shape, then apply forces / set transforms
through the accessors in this module.
Port of body.h / body.c (lifecycle, mass, velocity, and query API).
SPDX-FileCopyrightText: 2025 Erin Catto SPDX-License-Identifier: MIT
Modules§
- body_
flags - Body flag bits. (enum b3BodyFlags)
Structs§
- Body
- Body organizational details that are not used in the solver. (b3Body)
- Body
Cast Result - Body cast result for ray and shape casts. (b3BodyCastResult)
- Body
Plane Result - Body plane result for movers. (b3BodyPlaneResult)
- BodySim
- Body simulation data used for integration of position and velocity. Transform data used for collision and solver preparation. (b3BodySim)
- Body
State - Body state designed for fast conversion to and from SIMD via scatter-gather. Only awake dynamic and kinematic bodies have a body state. Used in the performance critical constraint solver. (b3BodyState, 56 bytes)
Constants§
- IDENTITY_
BODY_ STATE - Identity body state; notice delta_rotation is identity. (b3_identityBodyState)
Functions§
- body_
apply_ angular_ impulse - (b3Body_ApplyAngularImpulse)
- body_
apply_ force - (b3Body_ApplyForce)
- body_
apply_ force_ to_ center - (b3Body_ApplyForceToCenter)
- body_
apply_ linear_ impulse - (b3Body_ApplyLinearImpulse)
- body_
apply_ linear_ impulse_ to_ center - (b3Body_ApplyLinearImpulseToCenter)
- body_
apply_ mass_ from_ shapes - This updates the mass properties to the sum of the mass properties of the shapes. (b3Body_ApplyMassFromShapes)
- body_
apply_ torque - (b3Body_ApplyTorque)
- body_
cast_ ray - Cast a ray against a body’s shapes. Results are in world space relative to
origin;body_transform(not the body’s stored pose) drives the geometry. (b3Body_CastRay) - body_
cast_ shape - Cast a shape proxy against a body’s shapes. (b3Body_CastShape)
- body_
collide_ mover - Collide a capsule mover against a single body’s sphere/capsule/hull shapes. (b3Body_CollideMover)
- body_
compute_ aabb - Union of shape AABBs, or a degenerate AABB at the body position when shapeless. (b3Body_ComputeAABB)
- body_
disable - Disable a body (move to the disabled set, remove proxies). (b3Body_Disable)
- body_
enable - Enable a disabled body. (b3Body_Enable)
- body_
enable_ contact_ recycling - (b3Body_EnableContactRecycling)
- body_
enable_ hit_ events - Enable hit events on all shapes attached to this body. (b3Body_EnableHitEvents)
- body_
enable_ sleep - (b3Body_EnableSleep)
- body_
get_ angular_ damping - (b3Body_GetAngularDamping)
- body_
get_ angular_ velocity - (b3Body_GetAngularVelocity)
- body_
get_ contact_ capacity - Conservative and fast. (b3Body_GetContactCapacity)
- body_
get_ contact_ data - Touching contact data for a body, at most
capacityentries. (b3Body_GetContactData) - body_
get_ gravity_ scale - (b3Body_GetGravityScale)
- body_
get_ inverse_ mass - (b3Body_GetInverseMass)
- body_
get_ joint_ count - (b3Body_GetJointCount)
- body_
get_ joints - Fills at most
capacityjoint ids. (b3Body_GetJoints) - body_
get_ linear_ damping - (b3Body_GetLinearDamping)
- body_
get_ linear_ velocity - (b3Body_GetLinearVelocity)
- body_
get_ local_ center - (b3Body_GetLocalCenter)
- body_
get_ local_ point - (b3Body_GetLocalPoint)
- body_
get_ local_ point_ velocity - (b3Body_GetLocalPointVelocity)
- body_
get_ local_ rotational_ inertia - (b3Body_GetLocalRotationalInertia)
- body_
get_ local_ vector - (b3Body_GetLocalVector)
- body_
get_ mass - (b3Body_GetMass)
- body_
get_ mass_ data - (b3Body_GetMassData)
- body_
get_ motion_ locks - (b3Body_GetMotionLocks)
- body_
get_ name - (b3Body_GetName)
- body_
get_ position - (b3Body_GetPosition)
- body_
get_ shape_ count - (b3Body_GetShapeCount)
- body_
get_ shapes - Fills at most
capacityshape ids. (b3Body_GetShapes) - body_
get_ sleep_ threshold - (b3Body_GetSleepThreshold)
- body_
get_ transform - body_
get_ type - (b3Body_GetType)
- body_
get_ user_ data - (b3Body_GetUserData)
- body_
get_ world_ center - (b3Body_GetWorldCenter)
- body_
get_ world_ inverse_ rotational_ inertia - (b3Body_GetWorldInverseRotationalInertia)
- body_
get_ world_ point - (b3Body_GetWorldPoint)
- body_
get_ world_ point_ velocity - (b3Body_GetWorldPointVelocity)
- body_
get_ world_ vector - (b3Body_GetWorldVector)
- body_
is_ awake - (b3Body_IsAwake)
- body_
is_ bullet - (b3Body_IsBullet)
- body_
is_ contact_ recycling_ enabled - (b3Body_IsContactRecyclingEnabled)
- body_
is_ enabled - (b3Body_IsEnabled)
- body_
is_ sleep_ enabled - (b3Body_IsSleepEnabled)
- body_
is_ valid - Body identifier validation. (b3Body_IsValid — world registry checks collapse to the world argument)
- body_
overlap_ shape - Test whether a shape proxy overlaps any of a body’s shapes. (b3Body_OverlapShape)
- body_
set_ angular_ damping - (b3Body_SetAngularDamping)
- body_
set_ angular_ velocity - (b3Body_SetAngularVelocity)
- body_
set_ awake - (b3Body_SetAwake)
- body_
set_ bullet - (b3Body_SetBullet)
- body_
set_ gravity_ scale - (b3Body_SetGravityScale)
- body_
set_ linear_ damping - body_
set_ linear_ velocity - (b3Body_SetLinearVelocity)
- body_
set_ mass_ data - (b3Body_SetMassData)
- body_
set_ motion_ locks - (b3Body_SetMotionLocks)
- body_
set_ name - Set the body name (truncated to
BODY_NAME_LENGTH). Uses the world name cache rather than C’s fixed char buffer. (b3Body_SetName) - body_
set_ sleep_ threshold - (b3Body_SetSleepThreshold)
- body_
set_ target_ transform - Set a kinematic/dynamic body velocity so it reaches
targetintime_step. (b3Body_SetTargetTransform) - body_
set_ transform - (b3Body_SetTransform)
- body_
set_ type - Change a body’s simulation type. (b3Body_SetType)
- body_
set_ user_ data - (b3Body_SetUserData) — Rust stores
u64instead ofvoid*. - create_
body - Create a rigid body given a definition. (b3CreateBody)
- destroy_
body - Destroy a rigid body. (b3DestroyBody)
- get_
body_ full_ id - Resolve a BodyId to the body index. (b3GetBodyFullId)
- get_
body_ sim - (b3GetBodySim)
- get_
body_ sim_ mut - (b3GetBodySim) mutable
- get_
body_ state_ index - (b3GetBodyState) — None when the body is not in the awake set.
- get_
body_ transform - Transform by body index. (b3GetBodyTransform)
- get_
body_ transform_ quick - Quick transform lookup. (b3GetBodyTransformQuick)
- is_
body_ awake - True when the body is in the awake set. (b3IsBodyAwake)
- make_
body_ id - Create a BodyId from a raw body index. (b3MakeBodyId)
- should_
bodies_ collide - Joint
collide_connectedoverride. (b3ShouldBodiesCollide) - sync_
body_ flags - Sync non-transient flags from Body onto BodySim / BodyState. (b3SyncBodyFlags)
- update_
body_ mass_ data - Recompute mass, inertia, and extents from the body’s shapes. (b3UpdateBodyMassData)
- wake_
body - Wake a sleeping body. (b3WakeBody)
- wake_
body_ with_ lock - Wake with world lock. (b3WakeBodyWithLock)