diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index 299199f21968..e0c908da9ddb 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -353,7 +353,9 @@ impl App { TimeControlCommand::TogglePlayPause => { time_ctrl.toggle_play_pause(times_per_timeline); } - TimeControlCommand::Restart => time_ctrl.set_time(0), + TimeControlCommand::Restart => { + time_ctrl.restart(times_per_timeline); + } TimeControlCommand::StepBack => { time_ctrl.step_time_back(times_per_timeline); } diff --git a/crates/re_viewer/src/misc/time_control.rs b/crates/re_viewer/src/misc/time_control.rs index 836f2a7bfd3a..e9839cefec45 100644 --- a/crates/re_viewer/src/misc/time_control.rs +++ b/crates/re_viewer/src/misc/time_control.rs @@ -293,6 +293,14 @@ impl TimeControl { } } + pub fn restart(&mut self, times_per_timeline: &TimesPerTimeline) { + if let Some(time_points) = times_per_timeline.get(&self.timeline) { + if let Some(state) = self.states.get_mut(&self.timeline) { + state.time = min(time_points).into(); + } + } + } + pub fn toggle_play_pause(&mut self, times_per_timeline: &TimesPerTimeline) { #[allow(clippy::collapsible_else_if)] if self.playing {