Struct NavigationGrid
pub struct NavigationGrid<const W: usize, const H: usize> {
pub cells: [u8; 16384],
pub width: usize,
pub height: usize,
}Expand description
Bounded deterministic 2D navigation grid.
Fields§
§cells: [u8; 16384]Passability mask: 0 = walkable, 1 = static obstacle, 2 = dynamic obstacle / closed gate.
width: usize§height: usizeImplementations§
pub fn new() -> NavigationGrid<W, H>
pub fn new() -> NavigationGrid<W, H>
Creates a new NavigationGrid with all cells initialized to walkable (0).
pub fn index_of(&self, x: i32, y: i32) -> Option<usize>
pub fn index_of(&self, x: i32, y: i32) -> Option<usize>
Computes the linear array index for grid coordinates (x, y).
pub fn is_walkable(&self, x: i32, y: i32) -> bool
pub fn is_walkable(&self, x: i32, y: i32) -> bool
Returns true if (x, y) is within bounds and walkable (passability mask == 0).
pub fn set_obstacle(&mut self, x: i32, y: i32, obstacle_code: u8) -> bool
pub fn set_obstacle(&mut self, x: i32, y: i32, obstacle_code: u8) -> bool
Sets an obstacle code at (x, y). Returns true if coordinate was valid.
pub fn clear_obstacle(&mut self, x: i32, y: i32) -> bool
pub fn clear_obstacle(&mut self, x: i32, y: i32) -> bool
Clears an obstacle at (x, y) back to walkable.
pub fn find_path(
&self,
start: (i32, i32),
target: (i32, i32),
out_path: &mut [(i32, i32)],
) -> usize
pub fn find_path( &self, start: (i32, i32), target: (i32, i32), out_path: &mut [(i32, i32)], ) -> usize
Deterministic Breadth-First-Search pathfinder with bounded stack scratch.
Writes coordinates (x, y) into out_path from start to target.
Returns the number of waypoints written.
pub fn find_path_astar(
&self,
start: (i32, i32),
target: (i32, i32),
out_path: &mut [(i32, i32)],
) -> PathResult
pub fn find_path_astar( &self, start: (i32, i32), target: (i32, i32), out_path: &mut [(i32, i32)], ) -> PathResult
Deterministic A* pathfinder with Octile distance heuristic and bounded stack scratch.
Writes coordinates (x, y) into out_path from start to target.
Returns a typed PathResult.
pub fn compute_group_formation_destinations(
&self,
target_x: i32,
target_y: i32,
agent_count: usize,
out_destinations: &mut [(i32, i32)],
) -> usize
pub fn compute_group_formation_destinations( &self, target_x: i32, target_y: i32, agent_count: usize, out_destinations: &mut [(i32, i32)], ) -> usize
Compute deterministic grid offsets for a group of agent_count agents ordered
to move towards (target_x, target_y).
Writes offsets into out_destinations around (target_x, target_y) such that
agents form a compact grid formation without overlap.
Trait Implementations§
§fn clone(&self) -> NavigationGrid<W, H>
fn clone(&self) -> NavigationGrid<W, H>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§fn default() -> NavigationGrid<W, H>
fn default() -> NavigationGrid<W, H>
Auto Trait Implementations§
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more