Skip to main content

Module body

Module body 

Source

Modules§

body_flags

Structs§

Body
Body organizational details that are not used in the solver. (b2Body)
BodySim
Body simulation data used for integration of position and velocity. Transform data used for collision and solver preparation. (b2BodySim)
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. (b2BodyState, 32 bytes)

Constants§

IDENTITY_BODY_STATE
Identity body state, notice the delta_rotation is {1, 0}. (b2_identityBodyState)

Functions§

body_apply_angular_impulse
(b2Body_ApplyAngularImpulse)
body_apply_force
(b2Body_ApplyForce)
body_apply_force_to_center
(b2Body_ApplyForceToCenter)
body_apply_linear_impulse
(b2Body_ApplyLinearImpulse)
body_apply_linear_impulse_to_center
(b2Body_ApplyLinearImpulseToCenter)
body_apply_mass_from_shapes
(b2Body_ApplyMassFromShapes)
body_apply_torque
(b2Body_ApplyTorque)
body_clear_forces
(b2Body_ClearForces)
body_compute_aabb
(b2Body_ComputeAABB)
body_disable
Disabling a body requires a lot of detailed bookkeeping, but it is a valuable feature. The most challenging aspect is that joints may connect to bodies that are not disabled. (b2Body_Disable)
body_enable
(b2Body_Enable)
body_enable_contact_events
(b2Body_EnableContactEvents)
body_enable_contact_recycling
(b2Body_EnableContactRecycling)
body_enable_hit_events
(b2Body_EnableHitEvents)
body_enable_sleep
(b2Body_EnableSleep)
body_get_angular_damping
(b2Body_GetAngularDamping)
body_get_angular_velocity
(b2Body_GetAngularVelocity)
body_get_contact_capacity
Conservative and fast. (b2Body_GetContactCapacity)
body_get_contact_data
Touching contact data for a body, at most capacity entries. (b2Body_GetContactData)
body_get_gravity_scale
(b2Body_GetGravityScale)
body_get_joint_count
(b2Body_GetJointCount)
body_get_joints
Fills at most capacity joint ids. (b2Body_GetJoints)
body_get_linear_damping
(b2Body_GetLinearDamping)
body_get_linear_velocity
(b2Body_GetLinearVelocity)
body_get_local_center
(b2Body_GetLocalCenter)
body_get_local_point
(b2Body_GetLocalPoint)
body_get_local_point_velocity
(b2Body_GetLocalPointVelocity)
body_get_local_vector
(b2Body_GetLocalVector)
body_get_mass
(b2Body_GetMass)
body_get_mass_data
(b2Body_GetMassData)
body_get_motion_locks
(b2Body_GetMotionLocks)
body_get_name
(b2Body_GetName)
body_get_position
(b2Body_GetPosition)
body_get_rotation
(b2Body_GetRotation)
body_get_rotational_inertia
(b2Body_GetRotationalInertia)
body_get_shape_count
(b2Body_GetShapeCount)
body_get_shapes
Fills at most capacity shape ids. (b2Body_GetShapes)
body_get_sleep_threshold
(b2Body_GetSleepThreshold)
body_get_transform
(b2Body_GetTransform)
body_get_type
(b2Body_GetType)
body_get_user_data
(b2Body_GetUserData)
body_get_world_center
(b2Body_GetWorldCenter)
body_get_world_point
(b2Body_GetWorldPoint)
body_get_world_point_velocity
(b2Body_GetWorldPointVelocity)
body_get_world_vector
(b2Body_GetWorldVector)
body_is_awake
(b2Body_IsAwake)
body_is_bullet
(b2Body_IsBullet)
body_is_contact_recycling_enabled
(b2Body_IsContactRecyclingEnabled)
body_is_enabled
(b2Body_IsEnabled)
body_is_sleep_enabled
(b2Body_IsSleepEnabled)
body_is_valid
Body identifier validation. Can be used to detect orphaned ids. Provides validation for up to 64K allocations. (b2Body_IsValid — the world registry checks collapse to the world argument)
body_set_angular_damping
(b2Body_SetAngularDamping)
body_set_angular_velocity
(b2Body_SetAngularVelocity)
body_set_awake
(b2Body_SetAwake)
body_set_bullet
(b2Body_SetBullet)
body_set_gravity_scale
(b2Body_SetGravityScale)
body_set_linear_damping
(b2Body_SetLinearDamping)
body_set_linear_velocity
(b2Body_SetLinearVelocity)
body_set_mass_data
(b2Body_SetMassData)
body_set_motion_locks
(b2Body_SetMotionLocks)
body_set_name
(b2Body_SetName — takes &str; truncation matches the C strncpy to B2_NAME_LENGTH)
body_set_sleep_threshold
(b2Body_SetSleepThreshold)
body_set_target_transform
(b2Body_SetTargetTransform)
body_set_transform
(b2Body_SetTransform)
body_set_type
This should follow similar steps as you would get destroying and recreating the body, shapes, and joints. Contacts are difficult to preserve because the broad-phase pairs change, so they are destroyed. (b2Body_SetType — see the C comment block for the staged plan)
body_set_user_data
(b2Body_SetUserData)
body_sim_location
Location of a body’s sim data: (set_index, local_index). Use to borrow the BodySim through world.solver_sets. (b2GetBodySim resolves to a pointer in C; the index pair is the borrow-safe equivalent.)
body_wake_touching
(b2Body_WakeTouching)
create_body
Create a rigid body given a definition. (b2CreateBody)
destroy_body
Destroy a rigid body and everything attached to it: joints, contacts, shapes, and chains. (b2DestroyBody)
get_body_full_id
Get a validated body index from an id. (b2GetBodyFullId — C returns a pointer; Rust returns the raw index into world.bodies)
get_body_sim
Borrow a body’s sim data mutably. (b2GetBodySim)
get_body_state
Borrow a body’s state if it is in the awake set. (b2GetBodyState)
get_body_transform
(b2GetBodyTransform)
get_body_transform_quick
(b2GetBodyTransformQuick)
make_body_id
Create a BodyId from a raw id. (b2MakeBodyId)
make_relative_sweep
Build a sweep relative to a base position so continuous collision keeps float precision far from the origin. The base cancels out of the relative motion the TOI actually solves. (b2MakeRelativeSweep)
remove_body_sim
Remove a body sim from a set with swap-removal, fixing the moved body’s local index. (b2RemoveBodySim)
should_bodies_collide
(b2ShouldBodiesCollide)
sync_body_flags
(b2SyncBodyFlags)
update_body_mass_data
Update a body’s mass, center of mass, rotational inertia, and extents from its shapes. (b2UpdateBodyMassData)
wake_body
Wake a body’s solver set if it is sleeping. Returns true if the set was woken. (b2WakeBody)