[−][src]Struct oxygengine_navigation::resource::NavMesh
Nav mesh object used to find shortest path between two points.
Implementations
impl NavMesh
[src]
pub fn new(
vertices: Vec<NavVec3>,
triangles: Vec<NavTriangle>
) -> Result<NavMesh, Error>
[src]
vertices: Vec<NavVec3>,
triangles: Vec<NavTriangle>
) -> Result<NavMesh, Error>
Create new nav mesh object from vertices and triangles.
Arguments
vertices
- list of vertices points.triangles
- list of vertices indices that produces triangles.
Returns
Ok
with nav mesh object or Err
with Error::TriangleVerticeIndexOutOfBounds
if input
data is invalid.
Example
use navmesh::*; let vertices = vec![ (0.0, 0.0, 0.0).into(), // 0 (1.0, 0.0, 0.0).into(), // 1 (2.0, 0.0, 1.0).into(), // 2 (0.0, 1.0, 0.0).into(), // 3 (1.0, 1.0, 0.0).into(), // 4 (2.0, 1.0, 1.0).into(), // 5 ]; let triangles = vec![ (0, 1, 4).into(), // 0 (4, 3, 0).into(), // 1 (1, 2, 5).into(), // 2 (5, 4, 1).into(), // 3 ]; let mesh = NavMesh::new(vertices, triangles).unwrap();
pub fn thicken(&self, value: f32) -> Result<NavMesh, Error>
[src]
pub fn scale(
&self,
value: NavVec3,
origin: Option<NavVec3>
) -> Result<NavMesh, Error>
[src]
&self,
value: NavVec3,
origin: Option<NavVec3>
) -> Result<NavMesh, Error>
pub fn id(&self) -> ID<NavMesh>
[src]
Nav mesh identifier.
pub fn origin(&self) -> NavVec3
[src]
Nav mesh origin point.
pub fn vertices(&self) -> &[NavVec3]
[src]
Reference to list of nav mesh vertices points.
pub fn triangles(&self) -> &[NavTriangle]
[src]
Reference to list of nav mesh triangles.
pub fn areas(&self) -> &[NavArea]
[src]
Reference to list of nav mesh area descriptors.
pub fn set_area_cost(&mut self, index: usize, cost: f32) -> f32
[src]
Set area cost by triangle index.
Arguments
index
- triangle index.cost
- cost factor.
Returns
Old area cost value.
pub fn closest_point(&self, point: NavVec3, query: NavQuery) -> Option<NavVec3>
[src]
Find closest point on nav mesh.
Arguments
point
- query point.query
- query quality.
Returns
Some
with point on nav mesh if found or None
otherwise.
pub fn find_path(
&self,
from: NavVec3,
to: NavVec3,
query: NavQuery,
mode: NavPathMode
) -> Option<Vec<NavVec3>>
[src]
&self,
from: NavVec3,
to: NavVec3,
query: NavQuery,
mode: NavPathMode
) -> Option<Vec<NavVec3>>
Find shortest path on nav mesh between two points.
Arguments
from
- query point from.to
- query point to.query
- query quality.mode
- path finding quality.
Returns
Some
with path points on nav mesh if found or None
otherwise.
Example
use navmesh::*; let vertices = vec![ (0.0, 0.0, 0.0).into(), // 0 (1.0, 0.0, 0.0).into(), // 1 (2.0, 0.0, 1.0).into(), // 2 (0.0, 1.0, 0.0).into(), // 3 (1.0, 1.0, 0.0).into(), // 4 (2.0, 1.0, 1.0).into(), // 5 ]; let triangles = vec![ (0, 1, 4).into(), // 0 (4, 3, 0).into(), // 1 (1, 2, 5).into(), // 2 (5, 4, 1).into(), // 3 ]; let mesh = NavMesh::new(vertices, triangles).unwrap(); let path = mesh .find_path( (0.0, 1.0, 0.0).into(), (1.5, 0.25, 0.5).into(), NavQuery::Accuracy, NavPathMode::MidPoints, ) .unwrap(); assert_eq!( path.into_iter() .map(|v| ( (v.x * 10.0) as i32, (v.y * 10.0) as i32, (v.z * 10.0) as i32, )) .collect::<Vec<_>>(), vec![(0, 10, 0), (10, 5, 0), (15, 2, 5),] );
pub fn find_path_custom<F>(
&self,
from: NavVec3,
to: NavVec3,
query: NavQuery,
mode: NavPathMode,
filter: F
) -> Option<Vec<NavVec3>> where
F: FnMut(f32, usize, usize) -> bool,
[src]
&self,
from: NavVec3,
to: NavVec3,
query: NavQuery,
mode: NavPathMode,
filter: F
) -> Option<Vec<NavVec3>> where
F: FnMut(f32, usize, usize) -> bool,
Find shortest path on nav mesh between two points, providing custom filtering function.
Arguments
from
- query point from.to
- query point to.query
- query quality.mode
- path finding quality.filter
- closure that gives you a connection distance squared, first triangle index and second triangle index.
Returns
Some
with path points on nav mesh if found or None
otherwise.
Example
use navmesh::*; let vertices = vec![ (0.0, 0.0, 0.0).into(), // 0 (1.0, 0.0, 0.0).into(), // 1 (2.0, 0.0, 1.0).into(), // 2 (0.0, 1.0, 0.0).into(), // 3 (1.0, 1.0, 0.0).into(), // 4 (2.0, 1.0, 1.0).into(), // 5 ]; let triangles = vec![ (0, 1, 4).into(), // 0 (4, 3, 0).into(), // 1 (1, 2, 5).into(), // 2 (5, 4, 1).into(), // 3 ]; let mesh = NavMesh::new(vertices, triangles).unwrap(); let path = mesh .find_path_custom( (0.0, 1.0, 0.0).into(), (1.5, 0.25, 0.5).into(), NavQuery::Accuracy, NavPathMode::MidPoints, |_dist_sqr, _first_idx, _second_idx| true, ) .unwrap(); assert_eq!( path.into_iter() .map(|v| ( (v.x * 10.0) as i32, (v.y * 10.0) as i32, (v.z * 10.0) as i32, )) .collect::<Vec<_>>(), vec![(0, 10, 0), (10, 5, 0), (15, 2, 5),] );
pub fn find_path_triangles(
&self,
from: usize,
to: usize
) -> Option<(Vec<usize>, f32)>
[src]
&self,
from: usize,
to: usize
) -> Option<(Vec<usize>, f32)>
Find shortest path on nav mesh between two points.
Arguments
from
- query point from.to
- query point to.query
- query quality.mode
- path finding quality.
Returns
Some
with path points on nav mesh and path length if found or None
otherwise.
Example
use navmesh::*; let vertices = vec![ (0.0, 0.0, 0.0).into(), // 0 (1.0, 0.0, 0.0).into(), // 1 (2.0, 0.0, 1.0).into(), // 2 (0.0, 1.0, 0.0).into(), // 3 (1.0, 1.0, 0.0).into(), // 4 (2.0, 1.0, 1.0).into(), // 5 ]; let triangles = vec![ (0, 1, 4).into(), // 0 (4, 3, 0).into(), // 1 (1, 2, 5).into(), // 2 (5, 4, 1).into(), // 3 ]; let mesh = NavMesh::new(vertices, triangles).unwrap(); let path = mesh.find_path_triangles(1, 2).unwrap().0; assert_eq!(path, vec![1, 0, 3, 2]);
pub fn find_path_triangles_custom<F>(
&self,
from: usize,
to: usize,
filter: F
) -> Option<(Vec<usize>, f32)> where
F: FnMut(f32, usize, usize) -> bool,
[src]
&self,
from: usize,
to: usize,
filter: F
) -> Option<(Vec<usize>, f32)> where
F: FnMut(f32, usize, usize) -> bool,
Find shortest path on nav mesh between two points, providing custom filtering function.
Arguments
from
- query point from.to
- query point to.query
- query quality.mode
- path finding quality.filter
- closure that gives you a connection distance squared, first triangle index and second triangle index.
Returns
Some
with path points on nav mesh and path length if found or None
otherwise.
Example
use navmesh::*; let vertices = vec![ (0.0, 0.0, 0.0).into(), // 0 (1.0, 0.0, 0.0).into(), // 1 (2.0, 0.0, 1.0).into(), // 2 (0.0, 1.0, 0.0).into(), // 3 (1.0, 1.0, 0.0).into(), // 4 (2.0, 1.0, 1.0).into(), // 5 ]; let triangles = vec![ (0, 1, 4).into(), // 0 (4, 3, 0).into(), // 1 (1, 2, 5).into(), // 2 (5, 4, 1).into(), // 3 ]; let mesh = NavMesh::new(vertices, triangles).unwrap(); let path = mesh.find_path_triangles_custom( 1, 2, |_dist_sqr, _first_idx, _second_idx| true ).unwrap().0; assert_eq!(path, vec![1, 0, 3, 2]);
pub fn find_closest_triangle(
&self,
point: NavVec3,
query: NavQuery
) -> Option<usize>
[src]
&self,
point: NavVec3,
query: NavQuery
) -> Option<usize>
Find closest triangle on nav mesh closest to given point.
Arguments
point
- query point.query
- query quality.
Returns
Some
with nav mesh triangle index if found or None
otherwise.
pub fn path_target_point(
path: &[NavVec3],
point: NavVec3,
offset: f32
) -> Option<(NavVec3, f32)>
[src]
path: &[NavVec3],
point: NavVec3,
offset: f32
) -> Option<(NavVec3, f32)>
Find target point on nav mesh path.
Arguments
path
- path points.point
- source point.offset
- target point offset from the source on path.
Returns
Some
with point and distance from path start point if found or None
otherwise.
pub fn project_on_path(path: &[NavVec3], point: NavVec3, offset: f32) -> f32
[src]
Project point on nav mesh path.
Arguments
path
- path points.point
- source point.offset
- target point offset from the source on path.
Returns
Distance from path start point.
pub fn point_on_path(path: &[NavVec3], s: f32) -> Option<NavVec3>
[src]
Find point on nav mesh path at given distance.
Arguments
path
- path points.s
- Distance from path start point.
Returns
Some
with point on path ot None
otherwise.
pub fn path_length(path: &[NavVec3]) -> f32
[src]
Trait Implementations
impl Clone for NavMesh
[src]
impl Debug for NavMesh
[src]
impl Default for NavMesh
[src]
impl<'de> Deserialize<'de> for NavMesh
[src]
fn deserialize<__D>(
__deserializer: __D
) -> Result<NavMesh, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<NavMesh, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl Serialize for NavMesh
[src]
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Auto Trait Implementations
impl RefUnwindSafe for NavMesh
impl Send for NavMesh
impl Sync for NavMesh
impl Unpin for NavMesh
impl UnwindSafe for NavMesh
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
fn get_type_id(&self) -> TypeId
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> Event for T where
T: Send + Sync + 'static,
T: Send + Sync + 'static,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Resource for T where
T: Any,
T: Any,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> TryDefault for T where
T: Default,
T: Default,
fn try_default() -> Result<T, String>
fn unwrap_default() -> Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,