pub struct NavMesh<V: NavVec> {
pub vertices: Vec<V>,
pub polygons: Vec<Polygon<V>>,
/* private fields */
}Expand description
A navigation mesh: vertices plus convex polygon regions plus adjacency.
Queries never iterate a hash map, so the same mesh always answers the same
way. The map is only used while NavMesh::from_polygons builds adjacency.
Fields§
§vertices: Vec<V>Shared vertex buffer. Baked meshes deduplicate shared corners here.
polygons: Vec<Polygon<V>>Convex regions over vertices.
Implementations§
Sourcepub fn from_polygons(
vertices: Vec<V>,
polygons: Vec<Vec<u32>>,
) -> Result<Self, NavError>
pub fn from_polygons( vertices: Vec<V>, polygons: Vec<Vec<u32>>, ) -> Result<Self, NavError>
Build a mesh from vertices and per-polygon vertex index lists.
Returns NavError::DegeneratePolygon for a region with fewer than
three vertices and NavError::BadIndex for an out-of-range index.
Sourcepub fn polygon_count(&self) -> usize
pub fn polygon_count(&self) -> usize
Number of regions.
Sourcepub fn polygon_indices(&self, index: u32) -> Option<&[u32]>
pub fn polygon_indices(&self, index: u32) -> Option<&[u32]>
Vertex indices of one region.
Sourcepub fn neighbor(&self, polygon: u32, edge: u32) -> Option<Neighbor>
pub fn neighbor(&self, polygon: u32, edge: u32) -> Option<Neighbor>
Neighbour across directed edge edge of polygon, if the edge is shared.
Sourcepub fn portal(&self, polygon: u32, edge: u32) -> Option<[V; 2]>
pub fn portal(&self, polygon: u32, edge: u32) -> Option<[V; 2]>
Endpoints of directed edge edge of polygon.
Sourcepub fn locate(&self, point: V) -> Option<u32>
pub fn locate(&self, point: V) -> Option<u32>
Region containing point, if any. Ties (they cannot occur in a normal
tiling) resolve to the lowest region index.
Sourcepub fn closest_polygon(&self, point: V) -> Option<u32>
pub fn closest_polygon(&self, point: V) -> Option<u32>
Region nearest to point when it is outside the mesh.
Sourcepub fn closest_point_on_polygon(&self, polygon: u32, point: V) -> V
pub fn closest_point_on_polygon(&self, polygon: u32, point: V) -> V
Closest point on a region to point.
Inside the region the point is lifted onto the (possibly tilted) polygon surface by barycentric interpolation; outside it is projected onto the closest boundary edge.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.