Skip to content

Commit b249c43

Browse files
committed
clean up
1 parent e6ca9f6 commit b249c43

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

crates/viewer/re_time_panel/src/time_panel.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ impl Default for TimePanel {
167167
}
168168
}
169169

170+
/// This trait is used for the time panel to interact with either a
171+
/// `TimeControl` or a `BlueprintTimeControl` to avoid code duplication.
170172
pub trait TimeControlExt: Clone + PartialEq {
171173
fn get(&self) -> &TimeControl;
172174
fn get_mut(&mut self) -> &mut TimeControl;

crates/viewer/re_view_spatial/tests/video.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![expect(clippy::unwrap_used)] // It's a test!
22

3-
use std::cell::Cell;
4-
53
use re_chunk_store::RowId;
64
use re_log_types::{NonMinI64, TimePoint};
75
use re_test_context::{TestContext, external::egui_kittest::SnapshotOptions};
@@ -273,10 +271,6 @@ fn test_video(video_type: VideoType, codec: VideoCodec) {
273271
let step_dt_seconds = 1.0 / 4.0; // This is also the current egui_kittest default, but let's be explicit since we use `try_run_realtime`.
274272
let max_total_time_seconds = 60.0;
275273

276-
// Using a single harness for all frames - we want to make sure that we use the same decoder,
277-
// not tearing down the video player!
278-
let desired_seek_ns = Cell::new(0);
279-
280274
let mut harness = test_context
281275
.setup_kittest_for_rendering()
282276
.with_step_dt(step_dt_seconds)
@@ -285,17 +279,16 @@ fn test_video(video_type: VideoType, codec: VideoCodec) {
285279
.build_ui(|ui| {
286280
test_context.run_with_single_view(ui, view_id);
287281

288-
test_context.with_blueprint_ctx(|ctx| {
289-
ctx.set_time(NonMinI64::new(desired_seek_ns.get()).unwrap());
290-
});
291-
292282
std::thread::sleep(std::time::Duration::from_millis(20));
293283
});
294284

295285
for seek_location in VideoTestSeekLocation::ALL {
296-
desired_seek_ns.set(seek_location.get_time_ns(&frame_timestamps_nanos));
297-
298-
// Since we can't access `test_context` after creating `harness`, we have to do the seeking in here.
286+
// Using a single harness for all frames - we want to make sure that we use the same decoder,
287+
// not tearing down the video player!
288+
let desired_seek_ns = seek_location.get_time_ns(&frame_timestamps_nanos);
289+
test_context.with_blueprint_ctx(|ctx| {
290+
ctx.set_time(NonMinI64::new(desired_seek_ns).unwrap());
291+
});
299292

300293
// Video decoding happens in a different thread, so it's important that we give it time
301294
// and don't busy loop.

crates/viewer/re_viewer_context/src/time_control.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ impl TimeControl {
363363
)
364364
}
365365

366+
/// Sets the current time.
367+
///
368+
/// If `blueprint_ctx` is some, this will also update the time stored in
369+
/// the blueprint if `time_int` has changed.
366370
fn update_time(&mut self, blueprint_ctx: Option<&impl BlueprintContext>, time: TimeReal) {
367371
let time_int = time.floor();
368372
if self.time_int() != Some(time_int)
@@ -374,6 +378,10 @@ impl TimeControl {
374378
self.set_time(time);
375379
}
376380

381+
/// Read from the time panel blueprint and update the state from that.
382+
///
383+
/// If `times_per_timeline` is some this will also make sure we are on
384+
/// a valid timeline.
377385
fn update_from_blueprint(
378386
&mut self,
379387
blueprint_ctx: &impl BlueprintContext,
@@ -404,6 +412,10 @@ impl TimeControl {
404412
}
405413
}
406414

415+
/// See [`Self::update`].
416+
///
417+
/// If `blueprint_ctx` is some, this will read and write to the
418+
/// time panel blueprint.
407419
#[must_use]
408420
fn update_inner(
409421
&mut self,

0 commit comments

Comments
 (0)