Skip to main content

World

Struct World 

Source
pub struct World {
Show 68 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 shapes: Vec<Shape>, pub hull_database: HullDatabase, pub names: NameCache, 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: Vec3, 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 sat_call_count: i32, pub sat_cache_hit_count: i32, pub manifold_counts: [i32; 8], 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 create_debug_shape: Option<CreateDebugShapeCallback>, pub destroy_debug_shape: Option<DestroyDebugShapeCallback>, pub user_debug_shape_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_continuous: bool, pub enable_speculative: bool, pub in_use: bool, pub recording: Option<*mut Recording>,
}
Expand description

The world struct manages all physics entities, dynamic simulation, and asynchronous queries. (b3World)

Fields§

§broad_phase: BroadPhase§constraint_graph: ConstraintGraph§body_id_pool: IdPool

The body id pool allocates and recycles body ids. Aligns with bodies.

§bodies: Vec<Body>

Sparse array mapping body ids to body data stored in solver sets.

§solver_set_id_pool: IdPool

Provides 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: IdPool

Used 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: IdPool

Used to create stable ids for contacts.

§contacts: Vec<Contact>

Sparse array mapping contact ids to contacts.

§island_id_pool: IdPool

Used to create stable ids for islands.

§islands: Vec<Island>

Persistent islands.

§shape_id_pool: IdPool§shapes: Vec<Shape>

Sparse array of shapes.

§hull_database: HullDatabase

Content-keyed shared hull store. (world->hullDatabase)

§names: NameCache

Name cache for shape and body names.

§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 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: BitSet

Used to track debug draw.

§debug_joint_set: BitSet§debug_contact_set: BitSet§debug_island_set: BitSet§step_index: u64

Id that is incremented every time step.

§split_island_id: i32

Identify islands for splitting.

§gravity: Vec3§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§sat_call_count: i32§sat_cache_hit_count: i32§manifold_counts: [i32; 8]§max_capacity: Capacity§pre_solve_fcn: Option<PreSolveFcn>§pre_solve_context: u64§custom_filter_fcn: Option<CustomFilterFcn>§custom_filter_context: u64§create_debug_shape: Option<CreateDebugShapeCallback>

Create GPU/user shapes for debug draw. (createDebugShape)

§destroy_debug_shape: Option<DestroyDebugShapeCallback>

Destroy GPU/user shapes. (destroyDebugShape)

§user_debug_shape_context: u64

Context for the debug-shape callbacks. (userDebugShapeContext)

§worker_count: i32§user_data: u64§inv_h: f32

Inverse sub-step, remembered for reporting forces and torques.

§inv_dt: f32

Inverse full-step.

§world_id: u16§enable_sleep: bool§locked: bool§enable_warm_starting: bool§enable_continuous: bool§enable_speculative: bool§in_use: bool§recording: Option<*mut Recording>

Non-null while a recording session is active. Set by crate::recording::start_recording, cleared by crate::recording::stop_recording. (world->recording)

Implementations§

Source§

impl World

Source

pub fn step(&mut self, time_step: f32, sub_step_count: i32)

Advance the world simulation by one time step. (b3World_Step)

Source§

impl World

Source

pub fn validate_solver_sets(&self)

Debug validation of solver set bookkeeping. (b3ValidateSolverSets)

C gates this behind B3_VALIDATE; here it always runs and asserts in debug builds (release builds compile the checks away).

Source§

impl World

Source

pub fn new(def: &WorldDef) -> World

Create a world. (b3CreateWorld)

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 / manifold block allocator yet, 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.

Source

pub fn enable_continuous(&mut self, flag: bool)

(b3World_EnableContinuous)

Source

pub fn is_continuous_enabled(&self) -> bool

(b3World_IsContinuousEnabled)

Source

pub fn get_sensor_events(&self) -> SensorEvents<'_>

Sensor begin/end events from the previous step. End events come from the previous double-buffer slot. (b3World_GetSensorEvents)

Trait Implementations§

Source§

impl Debug for World

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Send for World

§

impl !Sync for World

§

impl Freeze for World

§

impl RefUnwindSafe for World

§

impl Unpin for World

§

impl UnsafeUnpin for World

§

impl UnwindSafe for World

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.