Skip to main content

Module body

Module body 

Source
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)
BodyCastResult
Body cast result for ray and shape casts. (b3BodyCastResult)
BodyPlaneResult
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)
BodyState
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 capacity entries. (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 capacity joint 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 capacity shape 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 target in time_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 u64 instead of void*.
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_connected override. (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)