pub struct SpatialHash { /* private fields */ }Expand description
A flat 2D spatial hash grid for O(1) proximity queries against road nodes and edges.
Implementations§
Source§impl SpatialHash
impl SpatialHash
Sourcepub fn new(world_width: f32, world_depth: f32, cell_size: f32) -> Self
pub fn new(world_width: f32, world_depth: f32, cell_size: f32) -> Self
Creates a new spatial hash covering a world_width × world_depth
area with cells of the given size. If the resulting grid would exceed
MAX_CELLS, cell_size is automatically increased to fit.
Sourcepub fn insert_node(&mut self, id: NodeId, pos: Vec2)
pub fn insert_node(&mut self, id: NodeId, pos: Vec2)
Registers a node in the cell containing pos.
Sourcepub fn remove_edge(&mut self, id: EdgeId, start: Vec2, end: Vec2)
pub fn remove_edge(&mut self, id: EdgeId, start: Vec2, end: Vec2)
Removes an edge from every cell it was registered in.
Sourcepub fn insert_edge(&mut self, id: EdgeId, start: Vec2, end: Vec2)
pub fn insert_edge(&mut self, id: EdgeId, start: Vec2, end: Vec2)
Registers an edge in every cell its axis-aligned bounding box overlaps.
Auto Trait Implementations§
impl Freeze for SpatialHash
impl RefUnwindSafe for SpatialHash
impl Send for SpatialHash
impl Sync for SpatialHash
impl Unpin for SpatialHash
impl UnsafeUnpin for SpatialHash
impl UnwindSafe for SpatialHash
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more