Skip to main content

DreamSpace

Struct DreamSpace 

Source
pub struct DreamSpace { /* private fields */ }
Expand description

DreamSpace — incremental spatial index with dirty-cell pair generation.

Implementations§

Source§

impl DreamSpace

Source

pub fn new(cell_size: f32) -> Self

Source

pub fn rebuild(&mut self, bodies: &[RigidBody])

Initial population — called once, or when body count changes.

Source

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.

Source

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.

Source

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).

Source

pub fn dirty_cell_count(&self) -> usize

Source

pub fn total_cell_count(&self) -> usize

Source

pub fn is_initialized(&self) -> bool

Source

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).

Source

pub fn bodies_in_cell(&self, cell: &(i32, i32, i32)) -> &[usize]

Get all body indices in a given cell.

Auto Trait Implementations§

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.