diff --git a/crates/store/re_chunk/src/chunk.rs b/crates/store/re_chunk/src/chunk.rs index 9d25ac0c38c4..350ff0d98afd 100644 --- a/crates/store/re_chunk/src/chunk.rs +++ b/crates/store/re_chunk/src/chunk.rs @@ -103,10 +103,8 @@ impl ChunkComponents { } /// Whether any of the components in this chunk has the given name. - pub fn contains_component_name(&self, component_name: ComponentName) -> bool { - self.0 - .keys() - .any(|desc| desc.component_name == component_name) + pub fn contains_component(&self, component_descr: &ComponentDescriptor) -> bool { + self.0.contains_key(component_descr) } /// Whether any of the components in this chunk is tagged with the given archetype name. diff --git a/crates/store/re_chunk_store/src/query.rs b/crates/store/re_chunk_store/src/query.rs index 5cde7a3cc7d3..8e893f3447e5 100644 --- a/crates/store/re_chunk_store/src/query.rs +++ b/crates/store/re_chunk_store/src/query.rs @@ -10,8 +10,7 @@ use re_chunk::{Chunk, LatestAtQuery, RangeQuery, TimelineName}; use re_log_types::ResolvedTimeRange; use re_log_types::{EntityPath, TimeInt, Timeline}; use re_types_core::{ - ComponentDescriptor, ComponentDescriptorSet, ComponentName, ComponentNameSet, - UnorderedComponentDescriptorSet, + ComponentDescriptor, ComponentDescriptorSet, ComponentName, UnorderedComponentDescriptorSet, }; use crate::{store::ChunkIdSetPerTime, ChunkStore}; @@ -146,56 +145,6 @@ impl ChunkStore { } } - /// Retrieve all the [`ComponentName`]s that have been written to for a given [`EntityPath`] on - /// the specified [`Timeline`]. - /// - /// Static components are always included in the results. - /// - /// Returns `None` if the entity doesn't exist at all on this `timeline`. - // TODO(#6889): Remove in favor of `all_components_on_timeline_sorted`. - pub fn all_components_on_timeline_sorted_by_name( - &self, - timeline: &TimelineName, - entity_path: &EntityPath, - ) -> Option { - re_tracing::profile_function!(); - - let static_components: Option = self - .static_chunk_ids_per_entity - .get(entity_path) - .map(|static_chunks_per_component| { - static_chunks_per_component - .keys() - .map(|descr| descr.component_name) - .collect::() - }) - .filter(|names| !names.is_empty()); - - let temporal_components: Option = self - .temporal_chunk_ids_per_entity_per_component - .get(entity_path) - .map(|temporal_chunk_ids_per_timeline| { - temporal_chunk_ids_per_timeline - .get(timeline) - .map(|temporal_chunk_ids_per_component| { - temporal_chunk_ids_per_component - .keys() - .map(|descr| descr.component_name) - .collect::() - }) - .unwrap_or_default() - }) - .filter(|names| !names.is_empty()); - - match (static_components, temporal_components) { - (None, None) => None, - (None, Some(comps)) | (Some(comps), None) => Some(comps), - (Some(static_comps), Some(temporal_comps)) => { - Some(static_comps.into_iter().chain(temporal_comps).collect()) - } - } - } - /// Retrieve all the [`ComponentName`]s that have been written to for a given [`EntityPath`] on /// the specified [`Timeline`]. /// @@ -292,29 +241,24 @@ impl ChunkStore { pub fn all_components_for_entity_sorted( &self, entity_path: &EntityPath, - ) -> Option { + ) -> Option { re_tracing::profile_function!(); - let static_components: Option = self + let static_components: Option = self .static_chunk_ids_per_entity .get(entity_path) .map(|static_chunks_per_component| { - static_chunks_per_component - .keys() - .map(|descr| descr.component_name) - .collect() + static_chunks_per_component.keys().cloned().collect() }); - let temporal_components: Option = self + let temporal_components: Option = self .temporal_chunk_ids_per_entity_per_component .get(entity_path) .map(|temporal_chunk_ids_per_timeline| { temporal_chunk_ids_per_timeline .iter() .flat_map(|(_, temporal_chunk_ids_per_component)| { - temporal_chunk_ids_per_component - .keys() - .map(|descr| descr.component_name) + temporal_chunk_ids_per_component.keys().cloned() }) .collect() }); diff --git a/crates/store/re_chunk_store/tests/reads.rs b/crates/store/re_chunk_store/tests/reads.rs index a064d5e5477a..e52d8a2a89c9 100644 --- a/crates/store/re_chunk_store/tests/reads.rs +++ b/crates/store/re_chunk_store/tests/reads.rs @@ -14,7 +14,7 @@ use re_log_types::{ }; use re_types::{ testing::{build_some_large_structs, LargeStruct}, - ComponentDescriptor, ComponentNameSet, + ComponentDescriptor, ComponentDescriptorSet, }; use re_types_core::Component as _; @@ -58,12 +58,10 @@ fn all_components() -> anyhow::Result<()> { |store: &ChunkStore, entity_path: &EntityPath, expected: Option<&[ComponentDescriptor]>| { let timeline = TimelineName::new("frame_nr"); - let component_names = - store.all_components_on_timeline_sorted_by_name(&timeline, entity_path); + let component_names = store.all_components_on_timeline_sorted(&timeline, entity_path); let expected_component_names = expected.map(|expected| { - let expected: ComponentNameSet = - expected.iter().map(|desc| desc.component_name).collect(); + let expected: ComponentDescriptorSet = expected.iter().cloned().collect(); expected }); diff --git a/crates/store/re_query/src/latest_at.rs b/crates/store/re_query/src/latest_at.rs index 006ab9c6c696..b0c777b67f61 100644 --- a/crates/store/re_query/src/latest_at.rs +++ b/crates/store/re_query/src/latest_at.rs @@ -436,9 +436,8 @@ impl LatestAtResults { &self, log_level: re_log::Level, instance_index: usize, + component_descr: &ComponentDescriptor, ) -> Option { - let component_descr = self.find_component_descriptor(C::name())?; - self.components.get(component_descr).and_then(|unit| { self.ok_or_log_err( log_level, @@ -452,8 +451,17 @@ impl LatestAtResults { /// /// Logs an error if the data cannot be deserialized, or if the instance index is out of bounds. #[inline] - pub fn component_instance(&self, instance_index: usize) -> Option { - self.component_instance_with_log_level(re_log::Level::Error, instance_index) + pub fn component_instance( + &self, + instance_index: usize, + component_descr: &ComponentDescriptor, + ) -> Option { + debug_assert_eq!(component_descr.component_name, C::name()); + self.component_instance_with_log_level( + re_log::Level::Error, + instance_index, + component_descr, + ) } /// Returns the deserialized data for the specified component at the given instance index. diff --git a/crates/store/re_types_core/src/lib.rs b/crates/store/re_types_core/src/lib.rs index 9fc783c2b6da..bbb6256cd272 100644 --- a/crates/store/re_types_core/src/lib.rs +++ b/crates/store/re_types_core/src/lib.rs @@ -44,7 +44,7 @@ pub use self::{ component_descriptor::ComponentDescriptor, id::{ChunkId, RowId}, loggable::{ - Component, ComponentDescriptorSet, ComponentName, ComponentNameSet, DatatypeName, Loggable, + Component, ComponentDescriptorSet, ComponentName, DatatypeName, Loggable, UnorderedComponentDescriptorSet, }, loggable_batch::{ diff --git a/crates/store/re_types_core/src/loggable.rs b/crates/store/re_types_core/src/loggable.rs index 762605c4546d..a382e36b4b6e 100644 --- a/crates/store/re_types_core/src/loggable.rs +++ b/crates/store/re_types_core/src/loggable.rs @@ -123,8 +123,6 @@ pub trait Component: Loggable { pub type UnorderedComponentDescriptorSet = IntSet; -pub type ComponentNameSet = std::collections::BTreeSet; - pub type ComponentDescriptorSet = std::collections::BTreeSet; re_string_interner::declare_new_type!( diff --git a/crates/viewer/re_view/src/annotation_scene_context.rs b/crates/viewer/re_view/src/annotation_scene_context.rs index 3ea7528ca943..860ceed3bac9 100644 --- a/crates/viewer/re_view/src/annotation_scene_context.rs +++ b/crates/viewer/re_view/src/annotation_scene_context.rs @@ -1,4 +1,4 @@ -use re_types::{archetypes::AnnotationContext, Archetype as _, ComponentNameSet}; +use re_types::{archetypes::AnnotationContext, Archetype as _, ComponentDescriptorSet}; use re_viewer_context::{ AnnotationMap, IdentifiedViewSystem, ViewContextSystem, ViewSystemIdentifier, }; @@ -13,13 +13,11 @@ impl IdentifiedViewSystem for AnnotationSceneContext { } impl ViewContextSystem for AnnotationSceneContext { - fn compatible_component_sets(&self) -> Vec { - vec![ - AnnotationContext::required_components() - .iter() - .map(|descr| descr.component_name) - .collect(), // - ] + fn compatible_component_sets(&self) -> Vec { + vec![AnnotationContext::required_components() + .iter() + .cloned() + .collect()] } fn execute( diff --git a/crates/viewer/re_view/src/results_ext.rs b/crates/viewer/re_view/src/results_ext.rs index 3efe968b6afb..f9b8eebad93f 100644 --- a/crates/viewer/re_view/src/results_ext.rs +++ b/crates/viewer/re_view/src/results_ext.rs @@ -41,7 +41,11 @@ pub struct HybridRangeResults<'a> { impl HybridLatestAtResults<'_> { /// Returns the [`UnitChunkShared`] for the specified [`re_types_core::Component`]. #[inline] - pub fn get(&self, component_name: impl Into) -> Option<&UnitChunkShared> { + // TODO(#6889): This method seems to be unused? + pub fn get_by_name( + &self, + component_name: impl Into, + ) -> Option<&UnitChunkShared> { let component_name = component_name.into(); self.overrides .get_by_name(&component_name) @@ -49,6 +53,7 @@ impl HybridLatestAtResults<'_> { .or_else(|| self.defaults.get_by_name(&component_name)) } + // TODO(#6889): Right now, fallbacks are on a per-component basis, so it's fine to pass the component name here. pub fn fallback_raw(&self, component_name: ComponentName) -> arrow::array::ArrayRef { let query_context = QueryContext { viewer_ctx: self.ctx.viewer_ctx, @@ -68,41 +73,66 @@ impl HybridLatestAtResults<'_> { /// Utility for retrieving the first instance of a component, ignoring defaults. #[inline] - pub fn get_required_mono(&self) -> Option { - self.get_required_instance(0) + pub fn get_required_mono( + &self, + component_descr: &ComponentDescriptor, + ) -> Option { + self.get_required_instance(0, component_descr) } /// Utility for retrieving the first instance of a component. #[inline] - pub fn get_mono(&self) -> Option { - self.get_instance(0) + pub fn get_mono( + &self, + component_descr: &ComponentDescriptor, + ) -> Option { + self.get_instance(0, component_descr) } /// Utility for retrieving the first instance of a component. #[inline] - pub fn get_mono_with_fallback(&self) -> C { - self.get_instance_with_fallback(0) + pub fn get_mono_with_fallback( + &self, + component_descr: &ComponentDescriptor, + ) -> C { + debug_assert_eq!(component_descr.component_name, C::name()); + + self.get_instance_with_fallback(0, component_descr) } /// Utility for retrieving a single instance of a component, not checking for defaults. /// /// If overrides or defaults are present, they will only be used respectively if they have a component at the specified index. #[inline] - pub fn get_required_instance(&self, index: usize) -> Option { - self.overrides.component_instance::(index).or_else(|| + pub fn get_required_instance( + &self, + index: usize, + component_descr: &ComponentDescriptor, + ) -> Option { + self.overrides + .component_instance::(index, component_descr) + .or_else(|| // No override -> try recording store instead - self.results.component_instance::(index)) + self.results.component_instance::(index, component_descr)) } /// Utility for retrieving a single instance of a component. /// /// If overrides or defaults are present, they will only be used respectively if they have a component at the specified index. #[inline] - pub fn get_instance(&self, index: usize) -> Option { - self.get_required_instance(index).or_else(|| { - // No override & no store -> try default instead - self.defaults.component_instance::(index) - }) + pub fn get_instance( + &self, + index: usize, + component_descr: &ComponentDescriptor, + ) -> Option { + debug_assert_eq!(component_descr.component_name, C::name()); + + self.get_required_instance(index, component_descr) + .or_else(|| { + // No override & no store -> try default instead + self.defaults + .component_instance::(index, component_descr) + }) } /// Utility for retrieving a single instance of a component. @@ -112,11 +142,15 @@ impl HybridLatestAtResults<'_> { pub fn get_instance_with_fallback( &self, index: usize, + component_descr: &ComponentDescriptor, ) -> C { - self.get_instance(index) + debug_assert_eq!(component_descr.component_name, C::name()); + + let component_name = component_descr.component_name; + self.get_instance(index, component_descr) .or_else(|| { // No override, no store, no default -> try fallback instead - let raw_fallback = self.fallback_raw(C::name()); + let raw_fallback = self.fallback_raw(component_name); C::from_arrow(raw_fallback.as_ref()) .ok() .and_then(|r| r.first().cloned()) diff --git a/crates/viewer/re_view_bar_chart/src/visualizer_system.rs b/crates/viewer/re_view_bar_chart/src/visualizer_system.rs index c938393d027a..a6f78b4df3b9 100644 --- a/crates/viewer/re_view_bar_chart/src/visualizer_system.rs +++ b/crates/viewer/re_view_bar_chart/src/visualizer_system.rs @@ -59,12 +59,14 @@ impl VisualizerSystem for BarChartVisualizerSystem { let results = data_result .latest_at_with_blueprint_resolved_data::(ctx, &timeline_query); - let Some(tensor) = results.get_required_mono::() else { + let Some(tensor) = + results.get_required_mono::(&BarChart::descriptor_values()) + else { continue; }; if tensor.is_vector() { - let color = results.get_mono_with_fallback(); + let color = results.get_mono_with_fallback(&BarChart::descriptor_color()); self.charts .insert(data_result.entity_path.clone(), (tensor.0.clone(), color)); } diff --git a/crates/viewer/re_view_dataframe/src/view_query/ui.rs b/crates/viewer/re_view_dataframe/src/view_query/ui.rs index 153c7ea9e811..a0bb7a783a05 100644 --- a/crates/viewer/re_view_dataframe/src/view_query/ui.rs +++ b/crates/viewer/re_view_dataframe/src/view_query/ui.rs @@ -7,11 +7,15 @@ use re_log_types::{ }; use re_sorbet::ColumnSelector; use re_types::blueprint::components; -use re_types_core::{ComponentName, ComponentNameSet}; +use re_types_core::ComponentName; use re_ui::{list_item, TimeDragValue, UiExt as _}; use re_viewer_context::{ViewId, ViewSystemExecutionError, ViewerContext}; use std::collections::{BTreeSet, HashSet}; +// TODO(#6889): This should be a `ComponentDescriptorSet`, but we first need to figure out +// how to handle descriptors for dataframe view queries in general. +type ComponentNameSet = std::collections::BTreeSet; + // UI implementation impl Query { pub(super) fn timeline_ui( @@ -226,7 +230,7 @@ impl Query { let all_components = ctx .recording_engine() .store() - .all_components_on_timeline_sorted_by_name(timeline, &filter_entity) + .all_components_on_timeline_sorted(timeline, &filter_entity) .unwrap_or_default(); // The list of suggested components is built as follows: @@ -237,7 +241,8 @@ impl Query { all_components .iter() .filter_map(|c| { - c.indicator_component_archetype_short_name() + c.component_name + .indicator_component_archetype_short_name() .and_then(|archetype_short_name| { ctx.reflection() .archetype_reflection_from_short_name(&archetype_short_name) @@ -248,13 +253,24 @@ impl Query { .required_fields() .map(|field| field.component_name) }) - .filter(|c| all_components.contains(c)) + .filter(|c| { + all_components + .iter() + // TODO(#6889): Should we filter by the component descriptor instead? + .any(|descr| &descr.component_name == c) + }) .collect::() }; // If the currently saved component, we auto-switch it to a reasonable one. let mut filter_component = filter_component - .and_then(|component| all_components.contains(&component).then_some(component)) + .and_then(|component| { + all_components + .iter() + // TODO(#6889): Should we filter by the component descriptor instead? + .any(|descr| descr.component_name == component) + .then_some(component) + }) .or_else(|| suggested_components().first().copied()) .unwrap_or_else(|| ComponentName::from("-")); @@ -283,9 +299,13 @@ impl Query { egui::ComboBox::new("pov_component", "") .selected_text(filter_component.short_name()) .show_ui(ui, |ui| { - for component in all_components { - let label = component.short_name(); - ui.selectable_value(&mut filter_component, component, label); + for descr in all_components { + let label = descr.short_name(); + ui.selectable_value( + &mut filter_component, + descr.component_name, + label, + ); } }); }), diff --git a/crates/viewer/re_view_graph/src/visualizers/edges.rs b/crates/viewer/re_view_graph/src/visualizers/edges.rs index 47502d4e8c31..90473b30cb75 100644 --- a/crates/viewer/re_view_graph/src/visualizers/edges.rs +++ b/crates/viewer/re_view_graph/src/visualizers/edges.rs @@ -70,7 +70,9 @@ impl VisualizerSystem for EdgesVisualizer { let all_edges = results.iter_as(query.timeline, GraphEdges::descriptor_edges()); // TODO(#6889): This still uses an untagged query. - let graph_type = results.get_mono_with_fallback::(); + let graph_type = results.get_mono_with_fallback::( + &GraphEdges::descriptor_graph_type(), + ); let sources = all_edges .slice_from_struct_field::(SOURCE) diff --git a/crates/viewer/re_view_graph/src/visualizers/nodes.rs b/crates/viewer/re_view_graph/src/visualizers/nodes.rs index 47c4afecc841..e41b93c56f5b 100644 --- a/crates/viewer/re_view_graph/src/visualizers/nodes.rs +++ b/crates/viewer/re_view_graph/src/visualizers/nodes.rs @@ -85,7 +85,7 @@ impl VisualizerSystem for NodeVisualizer { let all_labels = results.iter_as(query.timeline, GraphNodes::descriptor_labels()); let all_radii = results.iter_as(query.timeline, GraphNodes::descriptor_radii()); let show_label = results - .get_mono::() + .get_mono::(&GraphNodes::descriptor_show_labels()) .is_none_or(bool::from); let data = range_zip_1x4( diff --git a/crates/viewer/re_view_spatial/src/contexts/depth_offsets.rs b/crates/viewer/re_view_spatial/src/contexts/depth_offsets.rs index 32be813fa548..51473934728d 100644 --- a/crates/viewer/re_view_spatial/src/contexts/depth_offsets.rs +++ b/crates/viewer/re_view_spatial/src/contexts/depth_offsets.rs @@ -3,7 +3,7 @@ use std::collections::{BTreeMap, BTreeSet}; use ahash::HashMap; use re_log_types::EntityPathHash; -use re_types::{components::DrawOrder, Component as _, ComponentNameSet}; +use re_types::{archetypes, components::DrawOrder, ComponentDescriptorSet}; use re_view::latest_at_with_blueprint_resolved_data; use re_viewer_context::{IdentifiedViewSystem, ViewContextSystem, ViewSystemIdentifier}; @@ -23,8 +23,19 @@ impl IdentifiedViewSystem for EntityDepthOffsets { } impl ViewContextSystem for EntityDepthOffsets { - fn compatible_component_sets(&self) -> Vec { - vec![std::iter::once(DrawOrder::name()).collect()] + fn compatible_component_sets(&self) -> Vec { + vec![[ + archetypes::Arrows2D::descriptor_indicator(), + archetypes::Boxes2D::descriptor_indicator(), + archetypes::DepthImage::descriptor_indicator(), + archetypes::EncodedImage::descriptor_indicator(), + archetypes::Image::descriptor_indicator(), + archetypes::LineStrips2D::descriptor_indicator(), + archetypes::Points2D::descriptor_indicator(), + archetypes::SegmentationImage::descriptor_indicator(), + ] + .into_iter() + .collect()] } fn execute( @@ -94,7 +105,7 @@ fn collect_draw_order_per_visualizer( [draw_order_descriptor], query_shadowed_components, ) - .get_mono_with_fallback::(); + .get_mono_with_fallback::(draw_order_descriptor); entities_per_draw_order .entry(draw_order) diff --git a/crates/viewer/re_view_spatial/src/contexts/transform_tree_context.rs b/crates/viewer/re_view_spatial/src/contexts/transform_tree_context.rs index debcd4bb7e3b..6cf8dbbdb625 100644 --- a/crates/viewer/re_view_spatial/src/contexts/transform_tree_context.rs +++ b/crates/viewer/re_view_spatial/src/contexts/transform_tree_context.rs @@ -5,8 +5,8 @@ use re_entity_db::{EntityPath, EntityTree}; use re_log_types::EntityPathHash; use re_types::{ archetypes::{self, InstancePoses3D, Transform3D}, - components::{ImagePlaneDistance, PinholeProjection}, - Archetype as _, Component as _, ComponentNameSet, + components::ImagePlaneDistance, + Archetype as _, Component as _, ComponentDescriptorSet, }; use re_view::DataResultQuery as _; use re_viewer_context::{DataResultTree, IdentifiedViewSystem, ViewContext, ViewContextSystem}; @@ -149,17 +149,11 @@ impl Default for TransformTreeContext { } impl ViewContextSystem for TransformTreeContext { - fn compatible_component_sets(&self) -> Vec { + fn compatible_component_sets(&self) -> Vec { vec![ - Transform3D::all_components() - .iter() - .map(|descr| descr.component_name) - .collect(), - InstancePoses3D::all_components() - .iter() - .map(|descr| descr.component_name) - .collect(), - std::iter::once(PinholeProjection::name()).collect(), + Transform3D::all_components().iter().cloned().collect(), + InstancePoses3D::all_components().iter().cloned().collect(), + std::iter::once(archetypes::Pinhole::descriptor_image_from_camera()).collect(), ] } @@ -374,7 +368,9 @@ fn lookup_image_plane_distance( query, &archetypes::Pinhole::descriptor_image_plane_distance(), ) - .get_mono_with_fallback::() + .get_mono_with_fallback::( + &archetypes::Pinhole::descriptor_image_plane_distance(), + ) }) .unwrap_or_default() .into() diff --git a/crates/viewer/re_view_spatial/src/mesh_cache.rs b/crates/viewer/re_view_spatial/src/mesh_cache.rs index 4fe8aea0b07d..8494b3ab3e01 100644 --- a/crates/viewer/re_view_spatial/src/mesh_cache.rs +++ b/crates/viewer/re_view_spatial/src/mesh_cache.rs @@ -7,7 +7,10 @@ use re_chunk_store::{ChunkStoreEvent, RowId}; use re_entity_db::VersionedInstancePathHash; use re_log_types::hash::Hash64; use re_renderer::RenderContext; -use re_types::{components::MediaType, Component as _}; +use re_types::{ + archetypes::{Asset3D, Mesh3D}, + components::MediaType, +}; use re_viewer_context::Cache; use crate::mesh_loader::{LoadedMesh, NativeAsset3D, NativeMesh3D}; @@ -93,12 +96,12 @@ impl Cache for MeshCache { let contains_asset_blob = event .chunk .components() - .contains_component_name(re_types::components::Blob::name()); + .contains_component(&Asset3D::descriptor_blob()); let contains_vertex_positions = event .chunk .components() - .contains_component_name(re_types::components::Position3D::name()); + .contains_component(&Mesh3D::descriptor_vertex_positions()); contains_asset_blob || contains_vertex_positions }; diff --git a/crates/viewer/re_view_spatial/src/visualizers/cameras.rs b/crates/viewer/re_view_spatial/src/visualizers/cameras.rs index cc1c2c2844b1..139f45929a77 100644 --- a/crates/viewer/re_view_spatial/src/visualizers/cameras.rs +++ b/crates/viewer/re_view_spatial/src/visualizers/cameras.rs @@ -249,20 +249,24 @@ impl VisualizerSystem for CamerasVisualizer { query_shadowed_components, ); - let Some(pinhole_projection) = - query_results.get_required_mono::() + let Some(pinhole_projection) = query_results + .get_required_mono::( + &Pinhole::descriptor_image_from_camera(), + ) else { continue; }; let resolution = query_results - .get_mono::() + .get_mono::(&Pinhole::descriptor_resolution()) .unwrap_or_else(|| self.fallback_for(&query_ctx)); let camera_xyz = query_results - .get_mono::() + .get_mono::(&Pinhole::descriptor_camera_xyz()) .unwrap_or_else(|| self.fallback_for(&query_ctx)); let image_plane_distance = query_results - .get_mono::() + .get_mono::( + &Pinhole::descriptor_image_plane_distance(), + ) .unwrap_or_else(|| self.fallback_for(&query_ctx)); let component_data = CameraComponentDataWithFallbacks { diff --git a/crates/viewer/re_view_spatial/src/visualizers/transform3d_arrows.rs b/crates/viewer/re_view_spatial/src/visualizers/transform3d_arrows.rs index f53f2c91408a..55756cac6088 100644 --- a/crates/viewer/re_view_spatial/src/visualizers/transform3d_arrows.rs +++ b/crates/viewer/re_view_spatial/src/visualizers/transform3d_arrows.rs @@ -128,7 +128,9 @@ impl VisualizerSystem for Transform3DArrowsVisualizer { false, ); - let axis_length: f32 = results.get_mono_with_fallback::().into(); + let axis_length: f32 = results + .get_mono_with_fallback::(&Transform3D::descriptor_axis_length()) + .into(); if axis_length == 0.0 { // Don't draw axis and don't add to the bounding box! @@ -236,7 +238,9 @@ impl TypedComponentFallbackProvider for Transform3DArrowsVisualizer let results = data_result .latest_at_with_blueprint_resolved_data::(view_ctx, ctx.query); - Some(results.get_mono_with_fallback::()) + Some(results.get_mono_with_fallback::( + &Pinhole::descriptor_image_plane_distance(), + )) } else { None } diff --git a/crates/viewer/re_view_spatial/src/visualizers/videos.rs b/crates/viewer/re_view_spatial/src/visualizers/videos.rs index f0eb9757ca3e..a1ffdf82ec5f 100644 --- a/crates/viewer/re_view_spatial/src/visualizers/videos.rs +++ b/crates/viewer/re_view_spatial/src/visualizers/videos.rs @@ -394,8 +394,9 @@ fn latest_at_query_video_from_datastore( ); let blob_row_id = results.component_row_id(&AssetVideo::descriptor_blob())?; - let blob = results.component_instance::(0)?; - let media_type = results.component_instance::(0); + let blob = results.component_instance::(0, &AssetVideo::descriptor_blob())?; + let media_type = + results.component_instance::(0, &AssetVideo::descriptor_media_type()); let video = ctx.store_context.caches.entry(|c: &mut VideoCache| { let debug_name = entity_path.to_string(); diff --git a/crates/viewer/re_view_text_document/src/visualizer_system.rs b/crates/viewer/re_view_text_document/src/visualizer_system.rs index 5aeeba10a3b1..e5e7bcd4fdd6 100644 --- a/crates/viewer/re_view_text_document/src/visualizer_system.rs +++ b/crates/viewer/re_view_text_document/src/visualizer_system.rs @@ -46,12 +46,14 @@ impl VisualizerSystem for TextDocumentSystem { let results = data_result .latest_at_with_blueprint_resolved_data::(ctx, &timeline_query); - let Some(text) = results.get_required_mono::() else { + let Some(text) = + results.get_required_mono::(&TextDocument::descriptor_text()) + else { continue; }; self.text_entries.push(TextDocumentEntry { body: text.clone(), - media_type: results.get_mono_with_fallback(), + media_type: results.get_mono_with_fallback(&TextDocument::descriptor_media_type()), }); } diff --git a/crates/viewer/re_view_time_series/src/line_visualizer_system.rs b/crates/viewer/re_view_time_series/src/line_visualizer_system.rs index 3cc0a1c3eaee..2e227e8618dd 100644 --- a/crates/viewer/re_view_time_series/src/line_visualizer_system.rs +++ b/crates/viewer/re_view_time_series/src/line_visualizer_system.rs @@ -44,8 +44,7 @@ impl VisualizerSystem for SeriesLineSystem { .queried .extend(archetypes::SeriesLines::all_components().iter().cloned()); - query_info.indicators = - [archetypes::SeriesLines::descriptor_indicator().component_name].into(); + query_info.indicators = [archetypes::SeriesLines::descriptor_indicator()].into(); query_info } diff --git a/crates/viewer/re_view_time_series/src/point_visualizer_system.rs b/crates/viewer/re_view_time_series/src/point_visualizer_system.rs index 78ba6b88f6a7..2b41e2c7b87a 100644 --- a/crates/viewer/re_view_time_series/src/point_visualizer_system.rs +++ b/crates/viewer/re_view_time_series/src/point_visualizer_system.rs @@ -45,8 +45,7 @@ impl VisualizerSystem for SeriesPointSystem { .queried .extend(archetypes::SeriesPoints::all_components().iter().cloned()); - query_info.indicators = - [archetypes::SeriesPoints::descriptor_indicator().component_name].into(); + query_info.indicators = [archetypes::SeriesPoints::descriptor_indicator()].into(); query_info } diff --git a/crates/viewer/re_viewer_context/src/cache/tensor_stats_cache.rs b/crates/viewer/re_viewer_context/src/cache/tensor_stats_cache.rs index b49551b811d4..3808433932ea 100644 --- a/crates/viewer/re_viewer_context/src/cache/tensor_stats_cache.rs +++ b/crates/viewer/re_viewer_context/src/cache/tensor_stats_cache.rs @@ -3,7 +3,7 @@ use itertools::Either; use re_chunk_store::ChunkStoreEvent; use re_log_types::hash::Hash64; -use re_types::{datatypes::TensorData, Component as _}; +use re_types::{archetypes::Tensor, datatypes::TensorData}; use crate::{Cache, TensorStats}; @@ -41,7 +41,7 @@ impl Cache for TensorStatsCache { event .chunk .components() - .contains_component_name(re_types::components::TensorData::name()) + .contains_component(&Tensor::descriptor_data()) }; if is_deletion() && contains_tensor_data() { diff --git a/crates/viewer/re_viewer_context/src/view/view_context_system.rs b/crates/viewer/re_viewer_context/src/view/view_context_system.rs index 92b12ce6ee45..0ccb6bf55986 100644 --- a/crates/viewer/re_viewer_context/src/view/view_context_system.rs +++ b/crates/viewer/re_viewer_context/src/view/view_context_system.rs @@ -1,6 +1,6 @@ use ahash::HashMap; -use re_types::{ComponentNameSet, ViewClassIdentifier}; +use re_types::{ComponentDescriptorSet, ViewClassIdentifier}; use crate::{IdentifiedViewSystem, ViewQuery, ViewSystemExecutionError, ViewSystemIdentifier}; @@ -19,7 +19,7 @@ pub trait ViewContextSystem: Send + Sync { /// specific entities. /// It may still run once per frame as part of the global context if it has been registered to /// do so, see [`crate::ViewSystemRegistrator`]. - fn compatible_component_sets(&self) -> Vec; + fn compatible_component_sets(&self) -> Vec; /// Queries the chunk store and performs data conversions to make it ready for consumption by scene elements. fn execute(&mut self, ctx: &ViewContext<'_>, query: &ViewQuery<'_>); diff --git a/crates/viewer/re_viewer_context/src/view/visualizer_entity_subscriber.rs b/crates/viewer/re_viewer_context/src/view/visualizer_entity_subscriber.rs index 5e08db29bf7a..4eb2665323f1 100644 --- a/crates/viewer/re_viewer_context/src/view/visualizer_entity_subscriber.rs +++ b/crates/viewer/re_viewer_context/src/view/visualizer_entity_subscriber.rs @@ -4,7 +4,7 @@ use nohash_hasher::IntMap; use re_chunk_store::{ChunkStoreDiffKind, ChunkStoreEvent, ChunkStoreSubscriber}; use re_log_types::{EntityPathHash, StoreId}; -use re_types::{ComponentDescriptor, ComponentNameSet}; +use re_types::{ComponentDescriptor, ComponentDescriptorSet}; use crate::{ IdentifiedViewSystem, IndicatedEntities, MaybeVisualizableEntities, ViewSystemIdentifier, @@ -30,7 +30,7 @@ pub struct VisualizerEntitySubscriber { visualizer: ViewSystemIdentifier, /// See [`crate::VisualizerQueryInfo::indicators`] - indicator_components: ComponentNameSet, + indicator_components: ComponentDescriptorSet, /// Assigns each required component an index. required_components_indices: IntMap, @@ -172,12 +172,12 @@ impl ChunkStoreSubscriber for VisualizerEntitySubscriber { // Update indicator component tracking: if self.indicator_components.is_empty() - || self.indicator_components.iter().any(|component_name| { + || self.indicator_components.iter().any(|component_descr| { event .diff .chunk .components() - .contains_component_name(*component_name) + .contains_component(component_descr) }) { store_mapping diff --git a/crates/viewer/re_viewer_context/src/view/visualizer_system.rs b/crates/viewer/re_viewer_context/src/view/visualizer_system.rs index 558d56730c27..a23bb4f9242e 100644 --- a/crates/viewer/re_viewer_context/src/view/visualizer_system.rs +++ b/crates/viewer/re_viewer_context/src/view/visualizer_system.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use re_types::{Archetype, ComponentDescriptor, ComponentDescriptorSet, ComponentNameSet}; +use re_types::{Archetype, ComponentDescriptor, ComponentDescriptorSet}; use crate::{ ComponentFallbackProvider, DataBasedVisualizabilityFilter, IdentifiedViewSystem, @@ -39,7 +39,7 @@ impl FromIterator for SortedComponentDescriptorSet { pub struct VisualizerQueryInfo { /// These are not required, but if _any_ of these are found, it is a strong indication that this /// system should be active (if also the `required_components` are found). - pub indicators: ComponentNameSet, + pub indicators: ComponentDescriptorSet, /// Returns the minimal set of components that the system _requires_ in order to be instantiated. /// @@ -56,7 +56,7 @@ pub struct VisualizerQueryInfo { impl VisualizerQueryInfo { pub fn from_archetype() -> Self { Self { - indicators: std::iter::once(A::indicator().descriptor.component_name).collect(), + indicators: std::iter::once(A::indicator().descriptor).collect(), required: A::required_components().iter().cloned().collect(), queried: A::all_components().iter().cloned().collect(), } @@ -64,7 +64,7 @@ impl VisualizerQueryInfo { pub fn empty() -> Self { Self { - indicators: ComponentNameSet::default(), + indicators: ComponentDescriptorSet::default(), required: ComponentDescriptorSet::default(), queried: SortedComponentDescriptorSet::default(), } diff --git a/crates/viewer/re_viewport_blueprint/src/container.rs b/crates/viewer/re_viewport_blueprint/src/container.rs index 2d78a109fba1..5771a4440ce0 100644 --- a/crates/viewer/re_viewport_blueprint/src/container.rs +++ b/crates/viewer/re_viewport_blueprint/src/container.rs @@ -79,15 +79,15 @@ impl ContainerBlueprint { // This is a required component. Note that when loading containers we crawl the subtree and so // cleared empty container paths may exist transiently. The fact that they have an empty container_kind // is the marker that the have been cleared and not an error. - let container_kind = results.component_instance::(0)?; + let container_kind = results.component_mono::()?; - let display_name = results.component_instance::(0); + let display_name = results.component_mono::(); let contents = results.component_batch::(); let col_shares = results.component_batch::(); let row_shares = results.component_batch::(); - let active_tab = results.component_instance::(0); - let visible = results.component_instance::(0); - let grid_columns = results.component_instance::(0); + let active_tab = results.component_mono::(); + let visible = results.component_mono::(); + let grid_columns = results.component_mono::(); // ----