pub struct Navmesh { /* private fields */ }Expand description
Graph of convex cells and portal segments for connectivity and walkability.
Construction does not validate. Treat a mesh as authoritative only after
Self::validate (or after materialization from a valid DynamicNavmeshState).
Solvers and prepared builders clone this snapshot; they do not mutate it in place.
Implementations§
Sourcepub fn new(cells: Vec<NavmeshCell>, portals: Vec<NavmeshPortal>) -> Navmesh
pub fn new(cells: Vec<NavmeshCell>, portals: Vec<NavmeshPortal>) -> Navmesh
Creates an unvalidated mesh; call Self::validate before search or preprocess.
Sourcepub fn cells(&self) -> &[NavmeshCell]
pub fn cells(&self) -> &[NavmeshCell]
Convex cells that define walkable free space.
Sourcepub fn portals(&self) -> &[NavmeshPortal]
pub fn portals(&self) -> &[NavmeshPortal]
Shared boundary portals linking adjacent cells.
Sourcepub fn validate(&self) -> Result<(), NavmeshValidationError>
pub fn validate(&self) -> Result<(), NavmeshValidationError>
Validates every cell and every portal’s indices, non-degeneracy, and boundary endpoints.
§Errors
Returns NavmeshValidationError when a cell is invalid, cell ids are
duplicated, or a portal violates its endpoint contract.
Sourcepub fn locate_point(&self, point: Point2) -> Option<usize>
pub fn locate_point(&self, point: Point2) -> Option<usize>
Index of the first cell that contains point under inclusive membership, if any.
When a point lies on a shared boundary, the lowest-index containing cell wins.
Prefer Self::locate_cells when multi-membership matters (connectivity BFS).
Sourcepub fn locate_cells(&self, point: Point2) -> Vec<usize>
pub fn locate_cells(&self, point: Point2) -> Vec<usize>
All cell indices whose polygons contain point (inclusive boundary).
Order follows cell list order. Overlapping or boundary-sharing cells all appear.
Sourcepub fn neighbors(&self, cell_index: usize) -> Vec<usize>
pub fn neighbors(&self, cell_index: usize) -> Vec<usize>
Cell indices reachable in one portal hop from cell_index (unsorted, portal order).
Out-of-range indices yield an empty list. Duplicate portals to the same neighbor produce duplicate entries.
Sourcepub fn portals_from(&self, cell_index: usize) -> Vec<&NavmeshPortal>
pub fn portals_from(&self, cell_index: usize) -> Vec<&NavmeshPortal>
Portals incident to cell_index, in mesh portal order.
Sourcepub fn query(&self, query: NavmeshQuery) -> NavmeshQueryResult
pub fn query(&self, query: NavmeshQuery) -> NavmeshQueryResult
Cell-graph connectivity between query endpoints (no geometric path).
Locates every cell covering start and goal. If either endpoint lies outside all
cells, returns NavmeshQueryResult::InvalidStart or
NavmeshQueryResult::InvalidGoal. Otherwise BFS over portals from the full start
cell set; when any goal cell is reachable, returns
NavmeshQueryResult::Connected with the source start cell and hit goal cell.
Multi-cell endpoints use the first located cell only for the reported
NoPath indices when disconnected.
Sourcepub fn is_walkable(&self, point: Point2) -> bool
pub fn is_walkable(&self, point: Point2) -> bool
Whether point lies in at least one cell (inclusive boundary).
Sourcepub fn segment_is_walkable(&self, start: Point2, end: Point2) -> bool
pub fn segment_is_walkable(&self, start: Point2, end: Point2) -> bool
Whether the open segment from start to end stays on walkable cells.
Endpoints must be walkable. The check samples cell-edge intersections along the segment and requires each open sub-interval to lie inside some cell; when adjacent intervals occupy disjoint cell sets, a portal must cover the transition point. Used by funnel string-pull and path validation—not a free-space raycast.
Sourcepub fn path_is_walkable(&self, path: &[Point2]) -> bool
pub fn path_is_walkable(&self, path: &[Point2]) -> bool
Whether every consecutive segment of path is walkable and vertices admit portal transitions.
Empty paths are not walkable. A single point is walkable iff it lies in some cell. At interior vertices, incoming and outgoing probes must share a cell or cross a portal.
Trait Implementations§
Auto Trait Implementations§
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
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> 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