diff --git a/crates/re_query/src/range/results.rs b/crates/re_query/src/range/results.rs index cff3abcceabc..73254a2adc1f 100644 --- a/crates/re_query/src/range/results.rs +++ b/crates/re_query/src/range/results.rs @@ -226,10 +226,13 @@ pub struct RangeData<'a, T> { impl<'a, C: Component> RangeData<'a, C> { /// Useful to abstract over latest-at and ranged results. + /// + /// Use `reindexed` override the index of the data, if needed. #[inline] pub fn from_latest_at( resolver: &PromiseResolver, results: &'a LatestAtComponentResults, + reindexed: Option<(TimeInt, RowId)>, ) -> Self { let LatestAtComponentResults { index, @@ -238,9 +241,10 @@ impl<'a, C: Component> RangeData<'a, C> { } = results; let status = results.to_dense::(resolver).map(|_| ()); + let index = reindexed.unwrap_or(*index); Self { - indices: Some(Indices::Owned(vec![*index].into())), + indices: Some(Indices::Owned(vec![index].into())), data: cached_dense.get().map(|data| Data::Owned(Arc::clone(data))), time_range: TimeRange::new(index.0, index.0), front_status: status.clone(), diff --git a/crates/re_space_view_spatial/src/visualizers/results_ext.rs b/crates/re_space_view_spatial/src/visualizers/results_ext.rs index 1b03697315b6..63c77109527c 100644 --- a/crates/re_space_view_spatial/src/visualizers/results_ext.rs +++ b/crates/re_space_view_spatial/src/visualizers/results_ext.rs @@ -1,3 +1,4 @@ +use re_log_types::{RowId, TimeInt}; use re_query::{LatestAtResults, PromiseResolver, PromiseResult, RangeData, RangeResults, Results}; use re_types::Component; @@ -92,7 +93,7 @@ impl RangeResultsExt for LatestAtResults { resolver: &PromiseResolver, ) -> Option>> { let results = self.get(C::name())?; - let data = RangeData::from_latest_at(resolver, results); + let data = RangeData::from_latest_at(resolver, results, None); // TODO(#5607): what should happen if the promise is still pending? let (front_status, back_status) = data.status(); @@ -114,7 +115,12 @@ impl RangeResultsExt for LatestAtResults { resolver: &PromiseResolver, ) -> re_query::Result> { let results = self.get_or_empty(C::name()); - let data = RangeData::from_latest_at(resolver, results); + // With latest-at semantics, we just want to join the secondary components onto the primary + // ones, irrelevant of their indices. + // In particular, it is pretty common to have a secondary component be more recent than the + // associated primary component in latest-at contexts, e.g. colors in an otherwise fixed + // point cloud being changed each frame. + let data = RangeData::from_latest_at(resolver, results, Some((TimeInt::MIN, RowId::ZERO))); // TODO(#5607): what should happen if the promise is still pending? let (front_status, back_status) = data.status();