refactor(autorouter/invoker): Add default impls. to invoker's stepper traits

This commit is contained in:
Mikolaj Wielgus 2025-05-16 18:46:21 +02:00 committed by mikolaj
parent 53f937f14f
commit f9b1cc2cbf
6 changed files with 36 additions and 125 deletions

View File

@ -189,14 +189,4 @@ impl GetObstacles for AutorouteExecutionStepper {
}
}
impl GetNavmeshDebugTexts for AutorouteExecutionStepper {
fn navvertex_debug_text(&self, _navvertex: NavvertexIndex) -> Option<&str> {
// Add debug text here.
None
}
fn navedge_debug_text(&self, _navedge: (NavvertexIndex, NavvertexIndex)) -> Option<&str> {
// Add debug text here.
None
}
}
impl GetNavmeshDebugTexts for AutorouteExecutionStepper {}

View File

@ -130,12 +130,4 @@ impl GetObstacles for CompareDetoursExecutionStepper {
}
}
impl GetNavmeshDebugTexts for CompareDetoursExecutionStepper {
fn navvertex_debug_text(&self, _navvertex: NavvertexIndex) -> Option<&str> {
None
}
fn navedge_debug_text(&self, _navedge: (NavvertexIndex, NavvertexIndex)) -> Option<&str> {
None
}
}
impl GetNavmeshDebugTexts for CompareDetoursExecutionStepper {}

View File

@ -38,13 +38,17 @@ use super::{
/// most importantly the navmesh which is owned by the A* stepper.
#[enum_dispatch]
pub trait GetMaybeAstarStepper {
fn maybe_astar(&self) -> Option<&AstarStepper<Navmesh, f64>>;
fn maybe_astar(&self) -> Option<&AstarStepper<Navmesh, f64>> {
None
}
}
/// Trait for getting the navcord to display it on the debug overlay.
#[enum_dispatch]
pub trait GetMaybeNavcord {
fn maybe_navcord(&self) -> Option<&Navcord>;
fn maybe_navcord(&self) -> Option<&Navcord> {
None
}
}
/// Trait for getting ghosts to display on the debug overlay. Ghosts are the
@ -52,7 +56,9 @@ pub trait GetMaybeNavcord {
/// other shapes.
#[enum_dispatch]
pub trait GetGhosts {
fn ghosts(&self) -> &[PrimitiveShape];
fn ghosts(&self) -> &[PrimitiveShape] {
&[]
}
}
/// Trait for getting the obstacles that prevented Topola from creating
@ -61,15 +67,22 @@ pub trait GetGhosts {
/// debug overlay.
#[enum_dispatch]
pub trait GetObstacles {
fn obstacles(&self) -> &[PrimitiveIndex];
fn obstacles(&self) -> &[PrimitiveIndex] {
&[]
}
}
#[enum_dispatch]
/// Trait for getting text strings with debug information attached to navmesh
/// edges and vertices.
pub trait GetNavmeshDebugTexts {
fn navvertex_debug_text(&self, navvertex: NavvertexIndex) -> Option<&str>;
fn navedge_debug_text(&self, navedge: (NavvertexIndex, NavvertexIndex)) -> Option<&str>;
fn navvertex_debug_text(&self, navvertex: NavvertexIndex) -> Option<&str> {
None
}
fn navedge_debug_text(&self, navedge: (NavvertexIndex, NavvertexIndex)) -> Option<&str> {
None
}
}
/// Error types that can occur during the invocation of commands.

View File

@ -61,36 +61,8 @@ impl MeasureLengthExecutionStepper {
}
}
impl GetMaybeAstarStepper for MeasureLengthExecutionStepper {
fn maybe_astar(&self) -> Option<&AstarStepper<Navmesh, f64>> {
None
}
}
impl GetMaybeNavcord for MeasureLengthExecutionStepper {
fn maybe_navcord(&self) -> Option<&Navcord> {
None
}
}
impl GetGhosts for MeasureLengthExecutionStepper {
fn ghosts(&self) -> &[PrimitiveShape] {
&[]
}
}
impl GetObstacles for MeasureLengthExecutionStepper {
fn obstacles(&self) -> &[PrimitiveIndex] {
&[]
}
}
impl GetNavmeshDebugTexts for MeasureLengthExecutionStepper {
fn navvertex_debug_text(&self, _navvertex: NavvertexIndex) -> Option<&str> {
None
}
fn navedge_debug_text(&self, _navedge: (NavvertexIndex, NavvertexIndex)) -> Option<&str> {
None
}
}
impl GetMaybeAstarStepper for MeasureLengthExecutionStepper {}
impl GetMaybeNavcord for MeasureLengthExecutionStepper {}
impl GetGhosts for MeasureLengthExecutionStepper {}
impl GetObstacles for MeasureLengthExecutionStepper {}
impl GetNavmeshDebugTexts for MeasureLengthExecutionStepper {}

View File

@ -58,36 +58,8 @@ impl PlaceViaExecutionStepper {
}
}
impl GetMaybeAstarStepper for PlaceViaExecutionStepper {
fn maybe_astar(&self) -> Option<&AstarStepper<Navmesh, f64>> {
None
}
}
impl GetMaybeNavcord for PlaceViaExecutionStepper {
fn maybe_navcord(&self) -> Option<&Navcord> {
None
}
}
impl GetGhosts for PlaceViaExecutionStepper {
fn ghosts(&self) -> &[PrimitiveShape] {
&[]
}
}
impl GetObstacles for PlaceViaExecutionStepper {
fn obstacles(&self) -> &[PrimitiveIndex] {
&[]
}
}
impl GetNavmeshDebugTexts for PlaceViaExecutionStepper {
fn navvertex_debug_text(&self, _navvertex: NavvertexIndex) -> Option<&str> {
None
}
fn navedge_debug_text(&self, _navedge: (NavvertexIndex, NavvertexIndex)) -> Option<&str> {
None
}
}
impl GetMaybeAstarStepper for PlaceViaExecutionStepper {}
impl GetMaybeNavcord for PlaceViaExecutionStepper {}
impl GetGhosts for PlaceViaExecutionStepper {}
impl GetObstacles for PlaceViaExecutionStepper {}
impl GetNavmeshDebugTexts for PlaceViaExecutionStepper {}

View File

@ -57,36 +57,8 @@ impl RemoveBandsExecutionStepper {
}
}
impl GetMaybeAstarStepper for RemoveBandsExecutionStepper {
fn maybe_astar(&self) -> Option<&AstarStepper<Navmesh, f64>> {
None
}
}
impl GetMaybeNavcord for RemoveBandsExecutionStepper {
fn maybe_navcord(&self) -> Option<&Navcord> {
None
}
}
impl GetGhosts for RemoveBandsExecutionStepper {
fn ghosts(&self) -> &[PrimitiveShape] {
&[]
}
}
impl GetObstacles for RemoveBandsExecutionStepper {
fn obstacles(&self) -> &[PrimitiveIndex] {
&[]
}
}
impl GetNavmeshDebugTexts for RemoveBandsExecutionStepper {
fn navvertex_debug_text(&self, _navvertex: NavvertexIndex) -> Option<&str> {
None
}
fn navedge_debug_text(&self, _navedge: (NavvertexIndex, NavvertexIndex)) -> Option<&str> {
None
}
}
impl GetMaybeAstarStepper for RemoveBandsExecutionStepper {}
impl GetMaybeNavcord for RemoveBandsExecutionStepper {}
impl GetGhosts for RemoveBandsExecutionStepper {}
impl GetObstacles for RemoveBandsExecutionStepper {}
impl GetNavmeshDebugTexts for RemoveBandsExecutionStepper {}