mirror of https://codeberg.org/topola/topola.git
egui: add button to toggle showing navmesh
This commit is contained in:
parent
5161eecd49
commit
169ddf7d80
|
|
@ -16,6 +16,7 @@ use crate::{
|
|||
pub struct Top {
|
||||
pub is_placing_via: bool,
|
||||
pub show_ratsnest: bool,
|
||||
pub show_navmesh: bool,
|
||||
}
|
||||
|
||||
impl Top {
|
||||
|
|
@ -23,6 +24,7 @@ impl Top {
|
|||
Self {
|
||||
is_placing_via: false,
|
||||
show_ratsnest: false,
|
||||
show_navmesh: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -171,6 +173,7 @@ impl Top {
|
|||
ui.separator();
|
||||
|
||||
ui.toggle_value(&mut self.show_ratsnest, "Show Ratsnest");
|
||||
ui.toggle_value(&mut self.show_navmesh, "Show Navmesh");
|
||||
|
||||
ui.separator();
|
||||
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ impl Viewport {
|
|||
}
|
||||
}
|
||||
|
||||
if top.show_navmesh {
|
||||
if let Some(navmesh) = &shared_data.navmesh {
|
||||
for edge in navmesh.graph().edge_references() {
|
||||
let from = PrimitiveIndex::from(navmesh.graph().node_weight(edge.source()).unwrap().node)
|
||||
|
|
@ -205,6 +206,7 @@ impl Viewport {
|
|||
painter.paint_edge(from, to, stroke);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ghost in shared_data.ghosts.iter() {
|
||||
painter.paint_primitive(&ghost, egui::Color32::from_rgb(75, 75, 150));
|
||||
|
|
|
|||
|
|
@ -156,11 +156,6 @@ impl Navmesh {
|
|||
}
|
||||
|
||||
map.insert(trianvertex, navvertex);
|
||||
|
||||
/*// TODO: iterate over triangulation's edges instead of vertices.
|
||||
for edge in triangulation.edges(trianvertex) {
|
||||
graph.add_edge(edge.source(), edge.target(), &edge.weight());
|
||||
}*/
|
||||
}
|
||||
|
||||
for edge in triangulation.edge_references() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue