Skip to main content

SpatialPartition

Trait SpatialPartition 

Source
pub trait SpatialPartition {
    type Cell: Hash + Eq;

    // Required method
    fn cells(&self) -> impl Iterator<Item = Self::Cell>;
}
Expand description

Maps a collider to spatial cells for broad-phase acceleration.

Collision managers can use this to build a spatial index and only check pairs that share at least one cell, reducing O(n²) to O(n×k) where k is the average number of colliders per cell.

Required Associated Types§

Source

type Cell: Hash + Eq

The cell type used for spatial indexing.

Required Methods§

Source

fn cells(&self) -> impl Iterator<Item = Self::Cell>

Returns the cells this collider occupies.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§