pub struct DijkstraMap {
pub width: usize,
pub height: usize,
pub distances: Vec<f32>,
pub flow: Vec<Option<(usize, usize)>>,
}Expand description
A distance field computed simultaneously from multiple source cells. Useful for “all enemies chase the player” scenarios — compute once, use many.
Fields§
§width: usize§height: usize§distances: Vec<f32>§flow: Vec<Option<(usize, usize)>>Implementations§
Source§impl DijkstraMap
impl DijkstraMap
Sourcepub fn new(width: usize, height: usize) -> Self
pub fn new(width: usize, height: usize) -> Self
Create an empty map of the same dimensions as grid.
Sourcepub fn build(&mut self, grid: &PathGrid, goals: &[Vec2])
pub fn build(&mut self, grid: &PathGrid, goals: &[Vec2])
Build the distance field from a set of goal positions (world coords).
Sourcepub fn build_from_cells(&mut self, grid: &PathGrid, goals: &[(usize, usize)])
pub fn build_from_cells(&mut self, grid: &PathGrid, goals: &[(usize, usize)])
Build from grid coordinates directly.
Sourcepub fn distance_at(&self, grid: &PathGrid, pos: Vec2) -> f32
pub fn distance_at(&self, grid: &PathGrid, pos: Vec2) -> f32
Get the distance at a world position.
Trait Implementations§
Source§impl Clone for DijkstraMap
impl Clone for DijkstraMap
Source§fn clone(&self) -> DijkstraMap
fn clone(&self) -> DijkstraMap
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DijkstraMap
impl RefUnwindSafe for DijkstraMap
impl Send for DijkstraMap
impl Sync for DijkstraMap
impl Unpin for DijkstraMap
impl UnsafeUnpin for DijkstraMap
impl UnwindSafe for DijkstraMap
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