diff --git a/crates/store/re_types/definitions/rerun/archetypes/geo_line_strings.fbs b/crates/store/re_types/definitions/rerun/archetypes/geo_line_strings.fbs index 11f8397603a5..70d8ee2d35d4 100644 --- a/crates/store/re_types/definitions/rerun/archetypes/geo_line_strings.fbs +++ b/crates/store/re_types/definitions/rerun/archetypes/geo_line_strings.fbs @@ -25,6 +25,9 @@ table GeoLineStrings ( // --- Recommended --- /// Optional radii for the line strings. + /// + /// *Note*: scene units radiii are interpreted as meters. Currently, the display scale only considers the latitude of + /// the first vertex of each line string (see [this issue](https://github.com/rerun-io/rerun/issues/8013)). radii: [rerun.components.Radius] ("attr.rerun.component_recommended", nullable, order: 2000); /// Optional colors for the line strings. diff --git a/crates/store/re_types/definitions/rerun/archetypes/geo_points.fbs b/crates/store/re_types/definitions/rerun/archetypes/geo_points.fbs index 462a14191e37..198e8267614f 100644 --- a/crates/store/re_types/definitions/rerun/archetypes/geo_points.fbs +++ b/crates/store/re_types/definitions/rerun/archetypes/geo_points.fbs @@ -21,6 +21,8 @@ table GeoPoints ( // --- Recommended --- /// Optional radii for the points, effectively turning them into circles. + /// + /// *Note*: scene units radiii are interpreted as meters. radii: [rerun.components.Radius] ("attr.rerun.component_recommended", nullable, order: 2000); /// Optional colors for the points. diff --git a/crates/store/re_types/src/archetypes/geo_line_strings.rs b/crates/store/re_types/src/archetypes/geo_line_strings.rs index e19eae97a267..69b248278cb9 100644 --- a/crates/store/re_types/src/archetypes/geo_line_strings.rs +++ b/crates/store/re_types/src/archetypes/geo_line_strings.rs @@ -53,6 +53,9 @@ pub struct GeoLineStrings { pub line_strings: Vec, /// Optional radii for the line strings. + /// + /// *Note*: scene units radiii are interpreted as meters. Currently, the display scale only considers the latitude of + /// the first vertex of each line string (see [this issue](https://github.com/rerun-io/rerun/issues/8013)). pub radii: Option>, /// Optional colors for the line strings. @@ -237,6 +240,9 @@ impl GeoLineStrings { } /// Optional radii for the line strings. + /// + /// *Note*: scene units radiii are interpreted as meters. Currently, the display scale only considers the latitude of + /// the first vertex of each line string (see [this issue](https://github.com/rerun-io/rerun/issues/8013)). #[inline] pub fn with_radii( mut self, diff --git a/crates/store/re_types/src/archetypes/geo_points.rs b/crates/store/re_types/src/archetypes/geo_points.rs index 3a7cabc666cd..aaa32d63a97e 100644 --- a/crates/store/re_types/src/archetypes/geo_points.rs +++ b/crates/store/re_types/src/archetypes/geo_points.rs @@ -54,6 +54,8 @@ pub struct GeoPoints { pub positions: Vec, /// Optional radii for the points, effectively turning them into circles. + /// + /// *Note*: scene units radiii are interpreted as meters. pub radii: Option>, /// Optional colors for the points. @@ -238,6 +240,8 @@ impl GeoPoints { } /// Optional radii for the points, effectively turning them into circles. + /// + /// *Note*: scene units radiii are interpreted as meters. #[inline] pub fn with_radii( mut self, diff --git a/crates/viewer/re_space_view_map/src/visualizers/geo_line_strings.rs b/crates/viewer/re_space_view_map/src/visualizers/geo_line_strings.rs index aab84deedc3e..ba79e05afbf7 100644 --- a/crates/viewer/re_space_view_map/src/visualizers/geo_line_strings.rs +++ b/crates/viewer/re_space_view_map/src/visualizers/geo_line_strings.rs @@ -15,8 +15,7 @@ use re_viewer_context::{ #[derive(Debug, Default)] struct GeoLineStringsBatch { lines: Vec>, - //TODO(#7872): to be converted to scene vs. ui - radii: Vec, + radii: Vec, colors: Vec, instance_id: Vec, } @@ -93,7 +92,7 @@ impl VisualizerSystem for GeoLineStringsVisualizer { .map(|pos| walkers::Position::from_lat_lon(pos.x(), pos.y())) .collect(), ); - batch_data.radii.push(radius.0.abs()); + batch_data.radii.push(*radius); batch_data.colors.push(color.0.into()); batch_data .instance_id @@ -159,7 +158,15 @@ impl GeoLineStringsVisualizer { let ui_position = projector.project(*pos); glam::vec2(ui_position.x, ui_position.y) })) - .radius(re_renderer::Size(*radius)) + //TODO(#8013): we use the first vertex's latitude because `re_renderer` doesn't support per-vertex radii + .radius(super::radius_to_size( + *radius, + projector, + strip + .first() + .copied() + .unwrap_or(walkers::Position::from_lat_lon(0.0, 0.0)), + )) .color(*color) .picking_instance_id(*instance) .outline_mask_ids( diff --git a/crates/viewer/re_space_view_map/src/visualizers/geo_points.rs b/crates/viewer/re_space_view_map/src/visualizers/geo_points.rs index ba942faba8c3..25274d136cd3 100644 --- a/crates/viewer/re_space_view_map/src/visualizers/geo_points.rs +++ b/crates/viewer/re_space_view_map/src/visualizers/geo_points.rs @@ -15,8 +15,7 @@ use re_viewer_context::{ #[derive(Debug, Default)] pub struct GeoPointBatch { pub positions: Vec, - //TODO(#7872): to be converted to scene vs. ui - pub radii: Vec, + pub radii: Vec, pub colors: Vec, pub instance_id: Vec, } @@ -90,7 +89,7 @@ impl VisualizerSystem for GeoPointsVisualizer { position.latitude(), position.longitude(), )); - batch_data.radii.push(radius.0.abs()); + batch_data.radii.push(*radius); batch_data.colors.push(color.0.into()); batch_data .instance_id @@ -138,20 +137,16 @@ impl GeoPointsVisualizer { ); for (entity_path, batch) in &self.batches { - let positions = batch + let (positions, radii): (Vec<_>, Vec<_>) = batch .positions .iter() - .map(|pos| { + .zip(&batch.radii) + .map(|(pos, radius)| { + let size = super::radius_to_size(*radius, projector, *pos); let ui_position = projector.project(*pos); - glam::vec3(ui_position.x, ui_position.y, 0.0) + (glam::vec3(ui_position.x, ui_position.y, 0.0), size) }) - .collect::>(); - - let radii = batch - .radii - .iter() - .map(|radius| re_renderer::Size(*radius)) - .collect::>(); + .unzip(); let outline = highlight.entity_outline_mask(entity_path.hash()); @@ -190,7 +185,7 @@ impl TypedComponentFallbackProvider for GeoPointsVisualizer { impl TypedComponentFallbackProvider for GeoPointsVisualizer { fn fallback_for(&self, _ctx: &QueryContext<'_>) -> Radius { - Radius::from(5.0) + Radius::new_ui_points(5.0) } } diff --git a/crates/viewer/re_space_view_map/src/visualizers/mod.rs b/crates/viewer/re_space_view_map/src/visualizers/mod.rs index 189d27224730..d4c2b863a66c 100644 --- a/crates/viewer/re_space_view_map/src/visualizers/mod.rs +++ b/crates/viewer/re_space_view_map/src/visualizers/mod.rs @@ -92,6 +92,23 @@ pub fn update_span(span: &mut Option, other: Option) { } } +/// Convert a [`re_types::components::Radius`] to a [`re_renderer::Size`], considering scene units +/// as meters. +#[inline] +pub fn radius_to_size( + radius: re_types::components::Radius, + projector: &walkers::Projector, + position: walkers::Position, +) -> re_renderer::Size { + re_renderer::Size( + radius + .scene_units() + .map(|radius_meter| projector.scale_pixel_per_meter(position) * radius_meter) + .or(radius.ui_points()) + .unwrap_or_default(), + ) +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index c76fc051e2ce..fc47be92f0ce 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -1255,8 +1255,9 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { "The line strings, expressed in [EPSG:4326](https://epsg.io/4326) coordinates (North/East-positive degrees).", is_required : true, }, ArchetypeFieldReflection { component_name : "rerun.components.Radius".into(), display_name : "Radii", - docstring_md : "Optional radii for the line strings.", is_required : - false, }, ArchetypeFieldReflection { component_name : + docstring_md : + "Optional radii for the line strings.\n\n*Note*: scene units radiii are interpreted as meters. Currently, the display scale only considers the latitude of\nthe first vertex of each line string (see [this issue](https://github.com/rerun-io/rerun/issues/8013)).", + is_required : false, }, ArchetypeFieldReflection { component_name : "rerun.components.Color".into(), display_name : "Colors", docstring_md : "Optional colors for the line strings.", is_required : false, }, @@ -1274,7 +1275,7 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { is_required : true, }, ArchetypeFieldReflection { component_name : "rerun.components.Radius".into(), display_name : "Radii", docstring_md : - "Optional radii for the points, effectively turning them into circles.", + "Optional radii for the points, effectively turning them into circles.\n\n*Note*: scene units radiii are interpreted as meters.", is_required : false, }, ArchetypeFieldReflection { component_name : "rerun.components.Color".into(), display_name : "Colors", docstring_md : "Optional colors for the points.", is_required : diff --git a/rerun_cpp/src/rerun/archetypes/geo_line_strings.hpp b/rerun_cpp/src/rerun/archetypes/geo_line_strings.hpp index dbd48a1fcd1a..16748341f357 100644 --- a/rerun_cpp/src/rerun/archetypes/geo_line_strings.hpp +++ b/rerun_cpp/src/rerun/archetypes/geo_line_strings.hpp @@ -55,6 +55,9 @@ namespace rerun::archetypes { Collection line_strings; /// Optional radii for the line strings. + /// + /// *Note*: scene units radiii are interpreted as meters. Currently, the display scale only considers the latitude of + /// the first vertex of each line string (see [this issue](https://github.com/rerun-io/rerun/issues/8013)). std::optional> radii; /// Optional colors for the line strings. @@ -75,6 +78,9 @@ namespace rerun::archetypes { : line_strings(std::move(_line_strings)) {} /// Optional radii for the line strings. + /// + /// *Note*: scene units radiii are interpreted as meters. Currently, the display scale only considers the latitude of + /// the first vertex of each line string (see [this issue](https://github.com/rerun-io/rerun/issues/8013)). GeoLineStrings with_radii(Collection _radii) && { radii = std::move(_radii); // See: https://github.com/rerun-io/rerun/issues/4027 diff --git a/rerun_cpp/src/rerun/archetypes/geo_points.hpp b/rerun_cpp/src/rerun/archetypes/geo_points.hpp index 8f3ad38b0e3f..2246b45c2eb4 100644 --- a/rerun_cpp/src/rerun/archetypes/geo_points.hpp +++ b/rerun_cpp/src/rerun/archetypes/geo_points.hpp @@ -47,6 +47,8 @@ namespace rerun::archetypes { Collection positions; /// Optional radii for the points, effectively turning them into circles. + /// + /// *Note*: scene units radiii are interpreted as meters. std::optional> radii; /// Optional colors for the points. @@ -77,6 +79,8 @@ namespace rerun::archetypes { : positions(std::move(_positions)) {} /// Optional radii for the points, effectively turning them into circles. + /// + /// *Note*: scene units radiii are interpreted as meters. GeoPoints with_radii(Collection _radii) && { radii = std::move(_radii); // See: https://github.com/rerun-io/rerun/issues/4027 diff --git a/rerun_py/rerun_sdk/rerun/archetypes/geo_line_strings.py b/rerun_py/rerun_sdk/rerun/archetypes/geo_line_strings.py index c0791ccf7acd..00092fd548b1 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/geo_line_strings.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/geo_line_strings.py @@ -83,6 +83,9 @@ def _clear(cls) -> GeoLineStrings: ) # Optional radii for the line strings. # + # *Note*: scene units radiii are interpreted as meters. Currently, the display scale only considers the latitude of + # the first vertex of each line string (see [this issue](https://github.com/rerun-io/rerun/issues/8013)). + # # (Docstring intentionally commented out to hide this field from the docs) colors: components.ColorBatch | None = field( diff --git a/rerun_py/rerun_sdk/rerun/archetypes/geo_points.py b/rerun_py/rerun_sdk/rerun/archetypes/geo_points.py index c91b86e47f3e..92aa58553d59 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/geo_points.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/geo_points.py @@ -84,6 +84,8 @@ def _clear(cls) -> GeoPoints: ) # Optional radii for the points, effectively turning them into circles. # + # *Note*: scene units radiii are interpreted as meters. + # # (Docstring intentionally commented out to hide this field from the docs) colors: components.ColorBatch | None = field(