Struct NavMesh

Source
pub struct NavMesh { /* private fields */ }

Implementations§

Source§

impl NavMesh

Source

pub fn new( triangles: Vec<NavTriangle>, links: Vec<TraversalLink>, ) -> Result<NavMesh, NavigationError>

Construction allocates; searches reuse their own scratch space. Retains permissive legacy adjacency; use Self::new_checked for authoring.

Source

pub fn validate( triangles: &[NavTriangle], links: &[TraversalLink], ) -> Result<(), NavMeshDiagnostic>

Inspect borrowed authoring data without allocating a mesh identity or changing a live mesh. Scratch storage is at most three neighbor slots per face; topology checking is O(triangles²), bounded to 2048 faces/16384 links.

Checks finite, bounded, nondegenerate faces, duplicates, manifold shared edges and consistent relative winding. Walk links require an exact shared edge and endpoints within 0.001 units of its segment. Disabled links are checked too; non-walk links may bridge gaps. Self links are rejected. Missing reverse links are allowed: authored links remain directional. This does not detect geometric overlaps, T-junctions, clearance or slope.

use ferravex_math::Vec3;
use ferravex_play::navigation::{NavMesh, NavMeshDiagnostic, NavTriangle};
let faces = [NavTriangle([Vec3::ZERO, Vec3::X, Vec3::X])];
assert_eq!(NavMesh::validate(&faces, &[]),
    Err(NavMeshDiagnostic::DegenerateTriangle { triangle: 0 }));
Source

pub fn new_checked( triangles: Vec<NavTriangle>, links: Vec<TraversalLink>, ) -> Result<NavMesh, NavMeshDiagnostic>

Construct only after all Self::validate checks pass. Errors carry input indices and implement std::fmt::Display for editor messages.

use ferravex_math::Vec3;
use ferravex_play::navigation::{NavMesh, NavTriangle};
let mesh = NavMesh::new_checked(
    vec![NavTriangle([Vec3::ZERO, Vec3::X, Vec3::Z])], vec![])?;
assert_eq!(mesh.locate(Vec3::ZERO), Some(0));
Source

pub fn replace_checked( &mut self, triangles: Vec<NavTriangle>, links: Vec<TraversalLink>, ) -> Result<(), NavMeshDiagnostic>

Replace an authored mesh transactionally. On error, geometry, block/link state, identity and existing searches are untouched. On success, faces start unblocked, link enabled flags come from the input, and every old search/result is invalidated by a fresh identity (even for identical data).

use ferravex_math::Vec3;
use ferravex_play::navigation::{NavMesh, NavTriangle};
let mut mesh = NavMesh::new_checked(
    vec![NavTriangle([Vec3::ZERO, Vec3::X, Vec3::Z])], vec![])?;
assert!(mesh.replace_checked(vec![], vec![]).is_err());
assert_eq!(mesh.locate(Vec3::ZERO), Some(0));
Source

pub fn welded(triangles: Vec<NavTriangle>) -> Result<NavMesh, NavigationError>

Weld exact shared vertex edges; O(triangles²) setup, bounded to 2048 faces. Use Self::welded_checked to diagnose malformed adjacency before welding.

Source

pub fn welded_checked( triangles: Vec<NavTriangle>, ) -> Result<NavMesh, NavMeshDiagnostic>

Validate geometry and topology before generating bidirectional walk portals, then check generated endpoints before publishing the mesh. Uses the same midpoint/cost/order as Self::welded on valid input.

use ferravex_math::Vec3;
use ferravex_play::navigation::{NavMesh, NavTriangle};
let mesh = NavMesh::welded_checked(vec![
    NavTriangle([Vec3::ZERO, Vec3::X, Vec3::Z]),
    NavTriangle([Vec3::X, Vec3::X + Vec3::Z, Vec3::Z]),
])?;
assert!(mesh.search(Vec3::ZERO, Vec3::X + Vec3::Z).is_ok());
Source

pub fn locate(&self, p: Vec3) -> Option<usize>

Source

pub fn set_blocked( &mut self, index: usize, blocked: bool, ) -> Result<(), NavigationError>

Source

pub fn search( &self, start: Vec3, end: Vec3, ) -> Result<NavSearch, NavigationError>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.