diff --git a/crates/viewer/re_space_view_graph/src/ui/state.rs b/crates/viewer/re_space_view_graph/src/ui/state.rs index ef597b554162..0b317d1c865c 100644 --- a/crates/viewer/re_space_view_graph/src/ui/state.rs +++ b/crates/viewer/re_space_view_graph/src/ui/state.rs @@ -1,5 +1,5 @@ use egui::Rect; -use re_chunk::{TimeInt, Timeline}; +use re_chunk::{EntityPath, TimeInt, Timeline}; use re_format::format_f32; use re_types::blueprint::components::VisualBounds2D; use re_ui::UiExt; @@ -63,14 +63,23 @@ impl SpaceViewState for GraphSpaceViewState { /// Used to determine if a layout is up-to-date or outdated. #[derive(Debug, PartialEq, Eq)] -pub struct Timestamp { +pub struct Discriminator { timeline: Timeline, time: TimeInt, + entities: ahash::HashSet, } -impl Timestamp { - pub fn new(timeline: Timeline, time: TimeInt) -> Self { - Self { timeline, time } +impl Discriminator { + pub fn new( + timeline: Timeline, + time: TimeInt, + entities: impl IntoIterator, + ) -> Self { + Self { + timeline, + time, + entities: entities.into_iter().collect(), + } } } @@ -82,12 +91,12 @@ pub enum LayoutState { #[default] None, InProgress { - timestamp: Timestamp, + timestamp: Discriminator, layout: Layout, provider: ForceLayout, }, Finished { - timestamp: Timestamp, + timestamp: Discriminator, layout: Layout, _provider: ForceLayout, }, @@ -118,7 +127,7 @@ impl LayoutState { /// A simple state machine that keeps track of the different stages and if the layout needs to be recomputed. fn update<'a>( self, - requested: Timestamp, + requested: Discriminator, graphs: impl Iterator> + Clone, ) -> Self { match self { @@ -172,9 +181,10 @@ impl LayoutState { &'a mut self, timeline: Timeline, time: TimeInt, + entities: impl IntoIterator, graphs: impl Iterator> + Clone, ) -> &'a mut Layout { - *self = std::mem::take(self).update(Timestamp::new(timeline, time), graphs); + *self = std::mem::take(self).update(Discriminator::new(timeline, time, entities), graphs); match self { Self::Finished { layout, .. } | Self::InProgress { layout, .. } => layout, diff --git a/crates/viewer/re_space_view_graph/src/view.rs b/crates/viewer/re_space_view_graph/src/view.rs index 2177d5458bb5..dcf220446eb2 100644 --- a/crates/viewer/re_space_view_graph/src/view.rs +++ b/crates/viewer/re_space_view_graph/src/view.rs @@ -163,6 +163,7 @@ Display a graph of nodes and edges. let layout = state.layout_state.get( query.timeline, query.latest_at, + graphs.iter().map(|g| (g.0).clone()), graphs.iter().map(|(_, graph)| graph), ); let needs_remeasure = layout.has_zero_size();