pub struct GridPathfinder {
pub width: usize,
pub height: usize,
pub cell_size: f32,
pub origin: Vec2,
pub passable: Vec<bool>,
pub cost_map: Vec<f32>,
}Fields§
§width: usize§height: usize§cell_size: f32§origin: Vec2§passable: Vec<bool>§cost_map: Vec<f32>Implementations§
Source§impl GridPathfinder
impl GridPathfinder
pub fn new(width: usize, height: usize, cell_size: f32, origin: Vec2) -> Self
pub fn world_to_cell(&self, pos: Vec2) -> (i32, i32)
pub fn cell_to_world(&self, x: i32, y: i32) -> Vec2
pub fn is_passable(&self, x: i32, y: i32) -> bool
pub fn set_obstacle(&mut self, x: i32, y: i32, obstacle: bool)
Sourcepub fn find_path(&self, from: Vec2, to: Vec2) -> Option<Vec<Vec2>>
pub fn find_path(&self, from: Vec2, to: Vec2) -> Option<Vec<Vec2>>
A* search; returns world-space waypoints
pub fn smooth_path(path: &[Vec2], obstacles: &[Aabb]) -> Vec<Vec2>
Trait Implementations§
Source§impl Clone for GridPathfinder
impl Clone for GridPathfinder
Auto Trait Implementations§
impl Freeze for GridPathfinder
impl RefUnwindSafe for GridPathfinder
impl Send for GridPathfinder
impl Sync for GridPathfinder
impl Unpin for GridPathfinder
impl UnsafeUnpin for GridPathfinder
impl UnwindSafe for GridPathfinder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.