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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.