pub struct World {Show 62 fields
pub broad_phase: BroadPhase,
pub constraint_graph: ConstraintGraph,
pub body_id_pool: IdPool,
pub bodies: Vec<Body>,
pub solver_set_id_pool: IdPool,
pub solver_sets: Vec<SolverSet>,
pub joint_id_pool: IdPool,
pub joints: Vec<Joint>,
pub contact_id_pool: IdPool,
pub contacts: Vec<Contact>,
pub island_id_pool: IdPool,
pub islands: Vec<Island>,
pub shape_id_pool: IdPool,
pub chain_id_pool: IdPool,
pub shapes: Vec<Shape>,
pub chain_shapes: Vec<ChainShape>,
pub sensors: Vec<Sensor>,
pub task_contexts: Vec<TaskContext>,
pub sensor_task_contexts: Vec<SensorTaskContext>,
pub body_move_events: Vec<BodyMoveEvent>,
pub sensor_begin_events: Vec<SensorBeginTouchEvent>,
pub contact_begin_events: Vec<ContactBeginTouchEvent>,
pub sensor_end_events: [Vec<SensorEndTouchEvent>; 2],
pub contact_end_events: [Vec<ContactEndTouchEvent>; 2],
pub end_event_array_index: i32,
pub contact_hit_events: Vec<ContactHitEvent>,
pub joint_events: Vec<JointEvent>,
pub debug_body_set: BitSet,
pub debug_joint_set: BitSet,
pub debug_contact_set: BitSet,
pub debug_island_set: BitSet,
pub step_index: u64,
pub split_island_id: i32,
pub gravity: Vec2,
pub hit_event_threshold: f32,
pub restitution_threshold: f32,
pub max_linear_speed: f32,
pub contact_speed: f32,
pub contact_hertz: f32,
pub contact_damping_ratio: f32,
pub contact_recycle_distance: f32,
pub friction_callback: Option<FrictionCallback>,
pub restitution_callback: Option<RestitutionCallback>,
pub generation: u16,
pub profile: Profile,
pub max_capacity: Capacity,
pub pre_solve_fcn: Option<PreSolveFcn>,
pub pre_solve_context: u64,
pub custom_filter_fcn: Option<CustomFilterFcn>,
pub custom_filter_context: u64,
pub worker_count: i32,
pub user_data: u64,
pub inv_h: f32,
pub inv_dt: f32,
pub world_id: u16,
pub enable_sleep: bool,
pub locked: bool,
pub enable_warm_starting: bool,
pub enable_contact_softening: bool,
pub enable_continuous: bool,
pub enable_speculative: bool,
pub in_use: bool,
}Expand description
The world struct manages all physics entities, dynamic simulation, and asynchronous queries. (b2World)
Fields§
§broad_phase: BroadPhase§constraint_graph: ConstraintGraph§body_id_pool: IdPoolThe body id pool allocates and recycles body ids. Body ids provide a
stable identifier for users. Aligns with bodies.
bodies: Vec<Body>Sparse array mapping body ids to the body data stored in solver sets.
solver_set_id_pool: IdPoolProvides free list for solver sets.
solver_sets: Vec<SolverSet>Solver sets store sims in contiguous arrays. Set 0 is static, set 1 is disabled, set 2 is awake; the rest are sleeping islands.
joint_id_pool: IdPoolUsed to create stable ids for joints.
joints: Vec<Joint>Sparse array mapping joint ids to joints in the constraint graph or solver sets.
contact_id_pool: IdPoolUsed to create stable ids for contacts.
contacts: Vec<Contact>Sparse array mapping contact ids to contacts in the constraint graph or solver sets.
island_id_pool: IdPoolUsed to create stable ids for islands.
islands: Vec<Island>Persistent islands.
shape_id_pool: IdPool§chain_id_pool: IdPool§shapes: Vec<Shape>Sparse arrays that point into the pools above.
chain_shapes: Vec<ChainShape>§sensors: Vec<Sensor>Dense array of sensor data.
task_contexts: Vec<TaskContext>Per thread storage (one entry in the single-threaded port).
sensor_task_contexts: Vec<SensorTaskContext>§body_move_events: Vec<BodyMoveEvent>§sensor_begin_events: Vec<SensorBeginTouchEvent>§contact_begin_events: Vec<ContactBeginTouchEvent>§sensor_end_events: [Vec<SensorEndTouchEvent>; 2]End events are double buffered so that the user doesn’t need to flush events.
contact_end_events: [Vec<ContactEndTouchEvent>; 2]§end_event_array_index: i32§contact_hit_events: Vec<ContactHitEvent>§joint_events: Vec<JointEvent>§debug_body_set: BitSetUsed to track debug draw.
debug_joint_set: BitSet§debug_contact_set: BitSet§debug_island_set: BitSet§step_index: u64Id that is incremented every time step.
split_island_id: i32Identify islands for splitting.
gravity: Vec2§hit_event_threshold: f32§restitution_threshold: f32§max_linear_speed: f32§contact_speed: f32§contact_hertz: f32§contact_damping_ratio: f32§contact_recycle_distance: f32§friction_callback: Option<FrictionCallback>§restitution_callback: Option<RestitutionCallback>§generation: u16§profile: Profile§max_capacity: Capacity§pre_solve_fcn: Option<PreSolveFcn>§pre_solve_context: u64§custom_filter_fcn: Option<CustomFilterFcn>§custom_filter_context: u64§worker_count: i32§user_data: u64§inv_h: f32Inverse sub-step, remembered for reporting forces and torques.
inv_dt: f32Inverse full-step.
world_id: u16§enable_sleep: bool§locked: bool§enable_warm_starting: bool§enable_contact_softening: bool§enable_continuous: bool§enable_speculative: bool§in_use: boolImplementations§
Source§impl World
impl World
Sourcepub fn validate_contacts(&self)
pub fn validate_contacts(&self)
(b2ValidateContacts — C compiles the body under B2_ENABLE_VALIDATION; here the whole check runs in debug builds only)
Source§impl World
impl World
Sourcepub fn new(def: &WorldDef) -> World
pub fn new(def: &WorldDef) -> World
Create a world. (b2CreateWorld)
Differences from C, all documented in the module header: there is no
global world registry (the returned World is owned; world_id stays 0
unless the embedder assigns one), no arena stack, and the serial task
path is always used (worker_count = 1 with one task context), which is
the C fallback when no task system is supplied.
Sourcepub fn validate_solver_sets(&self)
pub fn validate_solver_sets(&self)
Validate the solver-set bookkeeping. (b2ValidateSolverSets)
bring-up: the C version (physics_world.c, compiled only with B2_ENABLE_VALIDATION) also cross-checks contacts, joints, and graph colors; those checks are added as their slices land. This subset validates the body <-> sim <-> set <-> island mapping.