Skip to main content

NavGrid

Trait NavGrid 

Source
pub trait NavGrid {
    // Required methods
    fn size(&self) -> UVec2;
    fn cost(&self, cell: UVec2) -> Option<f32>;

    // Provided method
    fn walkable(&self, cell: UVec2) -> bool { ... }
}
Expand description

Read-only access to a bounded navigation grid.

Implement this for an existing tilemap, voxel slice or array so searches borrow its cells instead of copying them. Cell (x, y) exists for x < size().x and y < size().y.

Required Methods§

Source

fn size(&self) -> UVec2

Width and height in cells.

Source

fn cost(&self, cell: UVec2) -> Option<f32>

Cost of entering cell, or None when it is blocked.

Only called for cells inside size. Searches reject a cost that is not finite or is below PathOptions::min_cost (or not positive for distance fields and smoothing) with PathError::InvalidCost.

Provided Methods§

Source

fn walkable(&self, cell: UVec2) -> bool

Whether cell can be entered, for checks that need no cost: corner rules, line of sight and clearance, and which cells get a distance field entry. Overrides are only a faster path and must return exactly cost(cell).is_some(), the default.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<G: NavGrid + ?Sized> NavGrid for &G

Source§

fn size(&self) -> UVec2

Source§

fn cost(&self, cell: UVec2) -> Option<f32>

Source§

fn walkable(&self, cell: UVec2) -> bool

Implementors§