pub struct PhysicsWorld {
pub gravity: [f32; 3],
pub sleep_config: SleepConfig,
pub dreamspace: DreamSpace,
pub superposition: Vec<SuperpositionState>,
/* private fields */
}Expand description
CPU-deterministic physics simulation world.
Fields§
§gravity: [f32; 3]§sleep_config: SleepConfig§dreamspace: DreamSpaceDreamSpace incremental broadphase (alternative to SpatialHashGrid).
superposition: Vec<SuperpositionState>Per-body superposition state. Parallel to bodies Vec.
Implementations§
Source§impl PhysicsWorld
impl PhysicsWorld
pub fn new() -> Self
Sourcepub fn remove_body(&mut self, id: BodyId) -> bool
pub fn remove_body(&mut self, id: BodyId) -> bool
Remove a rigid body by ID. Returns true if found.
Sourcepub fn body_count(&self) -> usize
pub fn body_count(&self) -> usize
Number of active bodies.
Sourcepub fn set_broadphase_cell_size(&mut self, size: f32)
pub fn set_broadphase_cell_size(&mut self, size: f32)
Set broadphase cell size. Optimal: ~2x the largest body radius. Smaller cells = faster query at high body counts, more memory.
Sourcepub fn bodies_mut_slice(&mut self) -> &mut [RigidBody]
pub fn bodies_mut_slice(&mut self) -> &mut [RigidBody]
Mutable access to all bodies (for superposition state toggling).
Sourcepub fn step(&mut self, dt: f32)
pub fn step(&mut self, dt: f32)
Step the simulation forward by dt seconds. Sequence: apply gravity → detect contacts → resolve contacts → integrate → sleep.
Sourcepub fn step_dreamspace(&mut self, dt: f32)
pub fn step_dreamspace(&mut self, dt: f32)
Step using DreamSpace incremental broadphase. Same physics as step() but only re-queries cells that had boundary crossings. First call triggers a full rebuild; subsequent calls are incremental.
Sourcepub fn step_superposition(&mut self, dt: f32, observer: &SuperpositionObserver)
pub fn step_superposition(&mut self, dt: f32, observer: &SuperpositionObserver)
Step with DreamSuperposition — cell-level coherence collapse + decoherence rings.
Phase 0: Cell-level coherence collapse (O(C) cells, not O(N) bodies) Phase 1: Gravity (Active + Decohering-on-tick only) Phase 2: Broadphase (DreamSpace incremental, Active + Decohering only) Phase 3: Narrowphase (filtered pairs) Phase 4: Contact wake + resolve Phase 5: Integrate (Active + Decohering-on-tick) Phase 6: DreamSpace update
Sourcepub fn superposition_counts(&self) -> (u32, u32, u32, u32)
pub fn superposition_counts(&self) -> (u32, u32, u32, u32)
Count bodies in each superposition state: (active, decohering, superposed, dormant).