From 55ed4bf4cc697e7ec597d29eba3516dd7d394b1c Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 30 Oct 2025 05:18:05 +0100 Subject: [PATCH] feat(topola-egui): Replace "update timestep" with "step rate" The term "timestep" is usually used to refer to a time step on some internal simulation time scale that is separate from the real time. There is however no time scale other than real time in Topola. --- crates/topola-egui/src/menu_bar.rs | 13 ++++++++----- crates/topola-egui/src/viewport.rs | 2 +- crates/topola-egui/src/workspace.rs | 12 +++++------- locales/en-US/main.ftl | 13 +++++-------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/crates/topola-egui/src/menu_bar.rs b/crates/topola-egui/src/menu_bar.rs index 5021cae..dbe06d0 100644 --- a/crates/topola-egui/src/menu_bar.rs +++ b/crates/topola-egui/src/menu_bar.rs @@ -41,7 +41,7 @@ pub struct MenuBar { pub show_primitive_indices: bool, pub show_appearance_panel: bool, pub fix_step_rate: bool, - pub update_timestep: f32, + pub step_rate: f32, } impl MenuBar { @@ -76,7 +76,7 @@ impl MenuBar { show_primitive_indices: false, show_appearance_panel: true, fix_step_rate: false, - update_timestep: 0.25, + step_rate: 1.0, } } @@ -170,10 +170,13 @@ impl MenuBar { actions.debug.render_menu(ctx, ui, self); ui.add_enabled_ui(self.fix_step_rate, |ui| { - ui.label(tr.text("tr-menu-debug-update-timestep")); + ui.label(tr.text("tr-menu-debug-step-rate")); ui.add( - egui::widgets::Slider::new(&mut self.update_timestep, 0.01..=3.0) - .suffix(" s"), + egui::widgets::Slider::new(&mut self.step_rate, 100.0..=0.1) + .suffix(format!( + " {}", + tr.text("tr-menu-debug-step-rate-unit") + )), ); }); }); diff --git a/crates/topola-egui/src/viewport.rs b/crates/topola-egui/src/viewport.rs index f941bd7..2df12b6 100644 --- a/crates/topola-egui/src/viewport.rs +++ b/crates/topola-egui/src/viewport.rs @@ -69,7 +69,7 @@ impl Viewport { workspace.advance_state_by_dt( tr, error_dialog, - menu_bar.fix_step_rate.then_some(menu_bar.update_timestep), + menu_bar.fix_step_rate.then_some(menu_bar.step_rate), &interactive_input, ); diff --git a/crates/topola-egui/src/workspace.rs b/crates/topola-egui/src/workspace.rs index 7d20621..b0e2d81 100644 --- a/crates/topola-egui/src/workspace.rs +++ b/crates/topola-egui/src/workspace.rs @@ -76,20 +76,18 @@ impl Workspace { &mut self, tr: &Translator, error_dialog: &mut ErrorDialog, - maybe_update_timestep: Option, + maybe_step_rate: Option, interactive_input: &InteractiveInput, ) -> bool { let instant = Instant::now(); - if maybe_update_timestep.is_some() { + if maybe_step_rate.is_some() { self.update_counter += interactive_input.dt; } - while maybe_update_timestep - .is_none_or(|update_timestep| self.update_counter >= update_timestep) - { - if let Some(update_timestep) = maybe_update_timestep { - self.update_counter -= update_timestep; + while maybe_step_rate.is_none_or(|step_rate| self.update_counter >= 1.0 / step_rate) { + if let Some(step_rate) = maybe_step_rate { + self.update_counter -= 1.0 / step_rate; } if let ControlFlow::Break(()) = self.update_state(tr, error_dialog, interactive_input) { diff --git a/locales/en-US/main.ftl b/locales/en-US/main.ftl index c324455..9f04228 100644 --- a/locales/en-US/main.ftl +++ b/locales/en-US/main.ftl @@ -47,7 +47,8 @@ tr-menu-debug-show-topo-navmesh = Show Topological Navmesh tr-menu-debug-show-bboxes = Show BBoxes tr-menu-debug-show-primitive-indices = Show Primitive Indices tr-menu-debug-fix-step-rate = Fix Step Rate -tr-menu-debug-update-timestep = Update Timestep +tr-menu-debug-step-rate = Step Rate +tr-menu-debug-step-rate-unit = steps/s tr-menu-help = Help tr-menu-help-online-documentation = Online Documentation @@ -61,9 +62,9 @@ tr-menu-route-options-presort-by-pairwise-detours = Pairwise Detours tr-menu-route-options-permutate = Permutate -## Continuously applied, so use frequentative or imperfective aspect if -## possible, e.g. in Polish it should be "przeciskaj pod taśmami" (imperfective) -## instead of "przeciśnij pod taśmami". +## This refers to behavior that is continuously applied, so use frequentative or +## imperfective aspect if possible, e.g. in Polish it should be "przeciskaj pod +## taśmami" (imperfective) instead of "przeciśnij pod taśmami". tr-menu-route-options-squeeze-through-under-bends = Squeeze through under Bends tr-menu-route-options-wrap-around-bands = Wrap around Bands @@ -71,10 +72,6 @@ tr-menu-route-options-wrap-around-bands = Wrap around Bands ## tr-menu-inspect = Inspect - -# Unused. -tr-menu-inspect-compare-detours = Compare Detours - tr-menu-inspect-measure-length = Measure Length tr-menu-preferences = Preferences