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