pub struct DreamSpace { /* private fields */ }Expand description
DreamSpace — incremental spatial index with dirty-cell pair generation.
Implementations§
Source§impl DreamSpace
impl DreamSpace
pub fn new(cell_size: f32) -> Self
Sourcepub fn rebuild(&mut self, bodies: &[RigidBody])
pub fn rebuild(&mut self, bodies: &[RigidBody])
Initial population — called once, or when body count changes.
Sourcepub fn update(&mut self, bodies: &[RigidBody])
pub fn update(&mut self, bodies: &[RigidBody])
Incremental update — called each step AFTER position integration. Scans all bodies, detects cell boundary crossings, updates cell map. Only crossing bodies cause writes. Sleeping/static bodies = zero cost.
Sourcepub fn query_dirty_pairs(&self, bodies: &[RigidBody]) -> Vec<(usize, usize)>
pub fn query_dirty_pairs(&self, bodies: &[RigidBody]) -> Vec<(usize, usize)>
Generate collision pairs from dirty cells + their 27 neighbors. Only bodies near dirty regions are checked — sleeping clusters are skipped.
Sourcepub fn query_all_pairs(&self, bodies: &[RigidBody]) -> Vec<(usize, usize)>
pub fn query_all_pairs(&self, bodies: &[RigidBody]) -> Vec<(usize, usize)>
Full rebuild query — used on first frame or after large changes. Generates all pairs (equivalent to old query_pairs but with HashMap O(1) lookup).
pub fn dirty_cell_count(&self) -> usize
pub fn total_cell_count(&self) -> usize
pub fn is_initialized(&self) -> bool
Sourcepub fn classify_cells(
&self,
observer: &SuperpositionObserver,
) -> (Vec<(i32, i32, i32)>, Vec<(i32, i32, i32)>, Vec<(i32, i32, i32)>)
pub fn classify_cells( &self, observer: &SuperpositionObserver, ) -> (Vec<(i32, i32, i32)>, Vec<(i32, i32, i32)>, Vec<(i32, i32, i32)>)
Coherence collapse: classify all occupied cells by observer distance. Returns (active_cells, decohering_cells, superposed_cells) as lists of cell keys. Bodies in a cell share the cell’s superposition state — “coherent superposition.” This replaces per-body distance checks with per-cell checks: O(C) instead of O(N).