mirror of https://codeberg.org/topola/topola.git
docs: navigation mesh documented
This commit is contained in:
parent
75d41f983a
commit
c1271e570e
|
|
@ -28,6 +28,7 @@ use super::{
|
||||||
|
|
||||||
#[enum_dispatch]
|
#[enum_dispatch]
|
||||||
pub trait GetMaybeNavmesh {
|
pub trait GetMaybeNavmesh {
|
||||||
|
/// Returns navigation mesh if possible
|
||||||
fn maybe_navmesh(&self) -> Option<&Navmesh>;
|
fn maybe_navmesh(&self) -> Option<&Navmesh>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,10 @@ pub enum NavmeshError {
|
||||||
Insertion(#[from] InsertionError),
|
Insertion(#[from] InsertionError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Contains Navigation Mesh properties
|
||||||
|
///
|
||||||
|
/// Navigation Mesh is a mesh of possible routes between
|
||||||
|
/// two nodes
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Navmesh {
|
pub struct Navmesh {
|
||||||
graph: UnGraph<NavvertexWeight, (), usize>,
|
graph: UnGraph<NavvertexWeight, (), usize>,
|
||||||
|
|
@ -127,6 +131,10 @@ pub struct Navmesh {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Navmesh {
|
impl Navmesh {
|
||||||
|
/// Create new Navigation mesh
|
||||||
|
///
|
||||||
|
/// Method to create new Navigation Mesh between
|
||||||
|
/// origin and destination nodes
|
||||||
pub fn new(
|
pub fn new(
|
||||||
layout: &Layout<impl AccessRules>,
|
layout: &Layout<impl AccessRules>,
|
||||||
origin: FixedDotIndex,
|
origin: FixedDotIndex,
|
||||||
|
|
@ -291,22 +299,27 @@ impl Navmesh {
|
||||||
.push((navvertex1, navvertex2));
|
.push((navvertex1, navvertex2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns Graph with undirected edges of Navigation Vertex
|
||||||
pub fn graph(&self) -> &UnGraph<NavvertexWeight, (), usize> {
|
pub fn graph(&self) -> &UnGraph<NavvertexWeight, (), usize> {
|
||||||
&self.graph
|
&self.graph
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns origin node index
|
||||||
pub fn origin(&self) -> FixedDotIndex {
|
pub fn origin(&self) -> FixedDotIndex {
|
||||||
self.origin
|
self.origin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns Navigation Vertex of origin node
|
||||||
pub fn origin_navvertex(&self) -> NavvertexIndex {
|
pub fn origin_navvertex(&self) -> NavvertexIndex {
|
||||||
self.origin_navvertex
|
self.origin_navvertex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns destination node index
|
||||||
pub fn destination(&self) -> FixedDotIndex {
|
pub fn destination(&self) -> FixedDotIndex {
|
||||||
self.destination
|
self.destination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns Navigation Vertex of destination node
|
||||||
pub fn destination_navvertex(&self) -> NavvertexIndex {
|
pub fn destination_navvertex(&self) -> NavvertexIndex {
|
||||||
self.destination_navvertex
|
self.destination_navvertex
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue