From 23ece01333170b7f2c2f7aed2f16874143fdfeb1 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Fri, 6 Dec 2024 12:50:03 -0500 Subject: [PATCH 01/14] Define new type for clipping plane --- .../rerun/blueprint/archetypes/visual_bounds2d.fbs | 3 +++ .../rerun/blueprint/components/clipping_plane.fbs | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs index 0e9dc2719a57..68e2144e11bd 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs @@ -16,4 +16,7 @@ table VisualBounds2D ( /// /// Use this to control pan & zoom of the view. range: rerun.blueprint.components.VisualBounds2D ("attr.rerun.component_required", order: 1000); + + /// Controls the distance to the clipping plane + clipping_plane: rerun.blueprint.components.ClippingPlane ("attr.rerun.component_optional", order: 2000); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs new file mode 100644 index 000000000000..d80dfff991e5 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs @@ -0,0 +1,13 @@ +namespace rerun.blueprint.components; + +// --- + +/// Distance to the clipping plane in used for `Spatial2DView`. +struct ClippingPlane ( + "attr.rerun.scope": "blueprint", + "attr.rust.derive": "Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable", + "attr.rust.repr": "transparent" +) { + /// Z distance to the clipping plane + clipping_plane: rerun.datatypes.Float32 (order: 100); +} From 59fc2060bccfe90aaf473d8b33801c74334262cf Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Fri, 6 Dec 2024 12:52:15 -0500 Subject: [PATCH 02/14] Codegen clipping plane definition --- .../rerun/blueprint/components.fbs | 1 + .../blueprint/archetypes/visual_bounds2d.rs | 42 +++++-- .../src/blueprint/components/.gitattributes | 1 + .../blueprint/components/clipping_plane.rs | 116 ++++++++++++++++++ .../re_types/src/blueprint/components/mod.rs | 2 + .../src/blueprint/validation_gen/mod.rs | 2 + crates/viewer/re_viewer/src/reflection/mod.rs | 14 ++- .../reference/types/views/graph_view.md | 3 + .../reference/types/views/spatial2d_view.md | 3 + .../blueprint/archetypes/visual_bounds2d.cpp | 7 +- .../blueprint/archetypes/visual_bounds2d.hpp | 11 +- rerun_cpp/src/rerun/blueprint/components.hpp | 1 + .../rerun/blueprint/components/.gitattributes | 1 + .../blueprint/components/clipping_plane.hpp | 77 ++++++++++++ .../blueprint/archetypes/visual_bounds2d.py | 9 ++ .../rerun/blueprint/components/.gitattributes | 1 + .../rerun/blueprint/components/__init__.py | 3 + .../blueprint/components/clipping_plane.py | 32 +++++ 18 files changed, 314 insertions(+), 12 deletions(-) create mode 100644 crates/store/re_types/src/blueprint/components/clipping_plane.rs create mode 100644 rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py diff --git a/crates/store/re_types/definitions/rerun/blueprint/components.fbs b/crates/store/re_types/definitions/rerun/blueprint/components.fbs index 1ee15c8acbe8..bed41a3e5312 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components.fbs @@ -5,6 +5,7 @@ include "./components/apply_latest_at.fbs"; include "./components/auto_layout.fbs"; include "./components/auto_space_views.fbs"; include "./components/background_kind.fbs"; +include "./components/clipping_plane.fbs"; include "./components/column_share.fbs"; include "./components/component_column_selector.fbs"; include "./components/container_kind.fbs"; diff --git a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs index f250112e9380..71157b7ee113 100644 --- a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs +++ b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs @@ -31,17 +31,21 @@ pub struct VisualBounds2D { /// /// Use this to control pan & zoom of the view. pub range: crate::blueprint::components::VisualBounds2D, + + /// Controls the distance to the clipping plane + pub clipping_plane: crate::blueprint::components::ClippingPlane, } impl ::re_types_core::SizeBytes for VisualBounds2D { #[inline] fn heap_size_bytes(&self) -> u64 { - self.range.heap_size_bytes() + self.range.heap_size_bytes() + self.clipping_plane.heap_size_bytes() } #[inline] fn is_pod() -> bool { ::is_pod() + && ::is_pod() } } @@ -51,20 +55,21 @@ static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.VisualBounds2DIndicator".into()]); -static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 0usize]> = - once_cell::sync::Lazy::new(|| []); +static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ClippingPlane".into()]); -static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 2usize]> = +static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.blueprint.components.VisualBounds2D".into(), "rerun.blueprint.components.VisualBounds2DIndicator".into(), + "rerun.blueprint.components.ClippingPlane".into(), ] }); impl VisualBounds2D { - /// The total number of components in the archetype: 1 required, 1 recommended, 0 optional - pub const NUM_COMPONENTS: usize = 2usize; + /// The total number of components in the archetype: 1 required, 1 recommended, 1 optional + pub const NUM_COMPONENTS: usize = 3usize; } /// Indicator component for the [`VisualBounds2D`] [`::re_types_core::Archetype`] @@ -132,7 +137,23 @@ impl ::re_types_core::Archetype for VisualBounds2D { .ok_or_else(DeserializationError::missing_data) .with_context("rerun.blueprint.archetypes.VisualBounds2D#range")? }; - Ok(Self { range }) + let clipping_plane = { + let array = arrays_by_name + .get("rerun.blueprint.components.ClippingPlane") + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.VisualBounds2D#clipping_plane")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.VisualBounds2D#clipping_plane")? + .into_iter() + .next() + .flatten() + .ok_or_else(DeserializationError::missing_data) + .with_context("rerun.blueprint.archetypes.VisualBounds2D#clipping_plane")? + }; + Ok(Self { + range, + clipping_plane, + }) } } @@ -143,6 +164,7 @@ impl ::re_types_core::AsComponents for VisualBounds2D { [ Some(Self::indicator()), Some((&self.range as &dyn ComponentBatch).into()), + Some((&self.clipping_plane as &dyn ComponentBatch).into()), ] .into_iter() .flatten() @@ -155,9 +177,13 @@ impl ::re_types_core::ArchetypeReflectionMarker for VisualBounds2D {} impl VisualBounds2D { /// Create a new `VisualBounds2D`. #[inline] - pub fn new(range: impl Into) -> Self { + pub fn new( + range: impl Into, + clipping_plane: impl Into, + ) -> Self { Self { range: range.into(), + clipping_plane: clipping_plane.into(), } } } diff --git a/crates/store/re_types/src/blueprint/components/.gitattributes b/crates/store/re_types/src/blueprint/components/.gitattributes index 238359328a19..ac9a3a4bb30f 100644 --- a/crates/store/re_types/src/blueprint/components/.gitattributes +++ b/crates/store/re_types/src/blueprint/components/.gitattributes @@ -4,6 +4,7 @@ active_tab.rs linguist-generated=true apply_latest_at.rs linguist-generated=true background_kind.rs linguist-generated=true +clipping_plane.rs linguist-generated=true column_share.rs linguist-generated=true component_column_selector.rs linguist-generated=true corner2d.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/components/clipping_plane.rs b/crates/store/re_types/src/blueprint/components/clipping_plane.rs new file mode 100644 index 000000000000..ed7b988f0fe8 --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/clipping_plane.rs @@ -0,0 +1,116 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::ComponentName; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Component**: Distance to the clipping plane in used for `Spatial2DView`. +#[derive(Clone, Debug, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)] +#[repr(transparent)] +pub struct ClippingPlane( + /// Z distance to the clipping plane + pub crate::datatypes::Float32, +); + +impl ::re_types_core::SizeBytes for ClippingPlane { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} + +impl> From for ClippingPlane { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for ClippingPlane { + #[inline] + fn borrow(&self) -> &crate::datatypes::Float32 { + &self.0 + } +} + +impl std::ops::Deref for ClippingPlane { + type Target = crate::datatypes::Float32; + + #[inline] + fn deref(&self) -> &crate::datatypes::Float32 { + &self.0 + } +} + +impl std::ops::DerefMut for ClippingPlane { + #[inline] + fn deref_mut(&mut self) -> &mut crate::datatypes::Float32 { + &mut self.0 + } +} + +::re_types_core::macros::impl_into_cow!(ClippingPlane); + +impl ::re_types_core::Loggable for ClippingPlane { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::datatypes::Float32::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::datatypes::Float32::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::datatypes::Float32::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } + + #[inline] + fn from_arrow2(arrow_data: &dyn arrow2::array::Array) -> DeserializationResult> + where + Self: Sized, + { + crate::datatypes::Float32::from_arrow2(arrow_data).map(bytemuck::cast_vec) + } +} + +impl ::re_types_core::Component for ClippingPlane { + #[inline] + fn name() -> ComponentName { + "rerun.blueprint.components.ClippingPlane".into() + } +} diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index ca655d4e56b3..cd3240c8e948 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -3,6 +3,7 @@ mod active_tab; mod apply_latest_at; mod background_kind; +mod clipping_plane; mod column_share; mod component_column_selector; mod component_column_selector_ext; @@ -45,6 +46,7 @@ mod zoom_level; pub use self::active_tab::ActiveTab; pub use self::apply_latest_at::ApplyLatestAt; pub use self::background_kind::BackgroundKind; +pub use self::clipping_plane::ClippingPlane; pub use self::column_share::ColumnShare; pub use self::component_column_selector::ComponentColumnSelector; pub use self::corner2d::Corner2D; diff --git a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs index 85bc964e87a8..5c4394388100 100644 --- a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs +++ b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs @@ -4,6 +4,7 @@ use re_entity_db::EntityDb; pub use re_types::blueprint::components::ActiveTab; pub use re_types::blueprint::components::ApplyLatestAt; pub use re_types::blueprint::components::BackgroundKind; +pub use re_types::blueprint::components::ClippingPlane; pub use re_types::blueprint::components::ColumnShare; pub use re_types::blueprint::components::ComponentColumnSelector; pub use re_types::blueprint::components::Corner2D; @@ -45,6 +46,7 @@ pub fn is_valid_blueprint(blueprint: &EntityDb) -> bool { && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) + && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index ed5806fd9f5b..565764c1e67c 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -74,6 +74,14 @@ fn generate_component_reflection() -> Result::name(), + ComponentReflection { + docstring_md: "Distance to the clipping plane in used for `Spatial2DView`.", + custom_placeholder: None, + datatype: ClippingPlane::arrow2_datatype(), + }, + ), ( ::name(), ComponentReflection { @@ -2202,7 +2210,11 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { "rerun.blueprint.components.VisualBounds2D".into(), display_name : "Range", docstring_md : "Controls the visible range of a 2D view.\n\nUse this to control pan & zoom of the view.", - is_required : true, }, + is_required : true, }, ArchetypeFieldReflection { component_name : + "rerun.blueprint.components.ClippingPlane".into(), display_name : + "Clipping plane", docstring_md : + "Controls the distance to the clipping plane", is_required : false, + }, ], }, ), diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index f6830c618ed6..5a5a66aef3de 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -12,6 +12,9 @@ Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. +* `range`: Controls the visible range of a 2D view. +* `clipping_plane`: Controls the distance to the clipping plane + ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/docs/content/reference/types/views/spatial2d_view.md b/docs/content/reference/types/views/spatial2d_view.md index 958e931f5efd..ba38a28c87f4 100644 --- a/docs/content/reference/types/views/spatial2d_view.md +++ b/docs/content/reference/types/views/spatial2d_view.md @@ -17,6 +17,9 @@ The visible parts of the scene, in the coordinate space of the scene. Everything within these bounds are guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. + +* `range`: Controls the visible range of a 2D view. +* `clipping_plane`: Controls the distance to the clipping plane ### `time_ranges` Configures which range on each timeline is shown by this view (unless specified differently per entity). diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp index 3b5c73dfe188..e011984dcfb7 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp @@ -15,13 +15,18 @@ namespace rerun { ) { using namespace blueprint::archetypes; std::vector cells; - cells.reserve(2); + cells.reserve(3); { auto result = ComponentBatch::from_loggable(archetype.range); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } + { + auto result = ComponentBatch::from_loggable(archetype.clipping_plane); + RR_RETURN_NOT_OK(result.error); + cells.push_back(std::move(result.value)); + } { auto indicator = VisualBounds2D::IndicatorComponent(); auto result = ComponentBatch::from_loggable(indicator); diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp index fc0f11e560f1..575bf01e7736 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp @@ -3,6 +3,7 @@ #pragma once +#include "../../blueprint/components/clipping_plane.hpp" #include "../../blueprint/components/visual_bounds2d.hpp" #include "../../collection.hpp" #include "../../component_batch.hpp" @@ -27,6 +28,9 @@ namespace rerun::blueprint::archetypes { /// Use this to control pan & zoom of the view. rerun::blueprint::components::VisualBounds2D range; + /// Controls the distance to the clipping plane + rerun::blueprint::components::ClippingPlane clipping_plane; + public: static constexpr const char IndicatorComponentName[] = "rerun.blueprint.components.VisualBounds2DIndicator"; @@ -38,8 +42,11 @@ namespace rerun::blueprint::archetypes { VisualBounds2D() = default; VisualBounds2D(VisualBounds2D&& other) = default; - explicit VisualBounds2D(rerun::blueprint::components::VisualBounds2D _range) - : range(std::move(_range)) {} + explicit VisualBounds2D( + rerun::blueprint::components::VisualBounds2D _range, + rerun::blueprint::components::ClippingPlane _clipping_plane + ) + : range(std::move(_range)), clipping_plane(std::move(_clipping_plane)) {} }; } // namespace rerun::blueprint::archetypes diff --git a/rerun_cpp/src/rerun/blueprint/components.hpp b/rerun_cpp/src/rerun/blueprint/components.hpp index 6dfe128cab3c..b82a71e2bacf 100644 --- a/rerun_cpp/src/rerun/blueprint/components.hpp +++ b/rerun_cpp/src/rerun/blueprint/components.hpp @@ -7,6 +7,7 @@ #include "blueprint/components/auto_layout.hpp" #include "blueprint/components/auto_space_views.hpp" #include "blueprint/components/background_kind.hpp" +#include "blueprint/components/clipping_plane.hpp" #include "blueprint/components/column_share.hpp" #include "blueprint/components/component_column_selector.hpp" #include "blueprint/components/container_kind.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/components/.gitattributes b/rerun_cpp/src/rerun/blueprint/components/.gitattributes index 50a1a60a3463..aca8c2fb51f9 100644 --- a/rerun_cpp/src/rerun/blueprint/components/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/components/.gitattributes @@ -7,6 +7,7 @@ auto_layout.hpp linguist-generated=true auto_space_views.hpp linguist-generated=true background_kind.cpp linguist-generated=true background_kind.hpp linguist-generated=true +clipping_plane.hpp linguist-generated=true column_share.hpp linguist-generated=true component_column_selector.hpp linguist-generated=true container_kind.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp b/rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp new file mode 100644 index 000000000000..286f94f17824 --- /dev/null +++ b/rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp @@ -0,0 +1,77 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs". + +#pragma once + +#include "../../datatypes/float32.hpp" +#include "../../result.hpp" + +#include +#include + +namespace rerun::blueprint::components { + /// **Component**: Distance to the clipping plane in used for `Spatial2DView`. + struct ClippingPlane { + /// Z distance to the clipping plane + rerun::datatypes::Float32 clipping_plane; + + public: + ClippingPlane() = default; + + ClippingPlane(rerun::datatypes::Float32 clipping_plane_) + : clipping_plane(clipping_plane_) {} + + ClippingPlane& operator=(rerun::datatypes::Float32 clipping_plane_) { + clipping_plane = clipping_plane_; + return *this; + } + + ClippingPlane(float value_) : clipping_plane(value_) {} + + ClippingPlane& operator=(float value_) { + clipping_plane = value_; + return *this; + } + + /// Cast to the underlying Float32 datatype + operator rerun::datatypes::Float32() const { + return clipping_plane; + } + }; +} // namespace rerun::blueprint::components + +namespace rerun { + static_assert( + sizeof(rerun::datatypes::Float32) == sizeof(blueprint::components::ClippingPlane) + ); + + /// \private + template <> + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.ClippingPlane"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::blueprint:: components::ClippingPlane` into an arrow array. + static Result> to_arrow( + const blueprint::components::ClippingPlane* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow( + &instances->clipping_plane, + num_instances + ); + } + } + }; +} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py index 7a6a5159dc0b..dd9e336a58db 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py @@ -34,6 +34,7 @@ def __attrs_clear__(self) -> None: """Convenience method for calling `__attrs_init__` with all `None`s.""" self.__attrs_init__( range=None, # type: ignore[arg-type] + clipping_plane=None, # type: ignore[arg-type] ) @classmethod @@ -53,5 +54,13 @@ def _clear(cls) -> VisualBounds2D: # # (Docstring intentionally commented out to hide this field from the docs) + clipping_plane: blueprint_components.ClippingPlaneBatch = field( + metadata={"component": "required"}, + converter=blueprint_components.ClippingPlaneBatch._required, # type: ignore[misc] + ) + # Controls the distance to the clipping plane + # + # (Docstring intentionally commented out to hide this field from the docs) + __str__ = Archetype.__str__ __repr__ = Archetype.__repr__ # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes index 320328225835..8fafaed413c5 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes @@ -7,6 +7,7 @@ apply_latest_at.py linguist-generated=true auto_layout.py linguist-generated=true auto_space_views.py linguist-generated=true background_kind.py linguist-generated=true +clipping_plane.py linguist-generated=true column_share.py linguist-generated=true component_column_selector.py linguist-generated=true container_kind.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py index 8f7f6182b390..2f2ea6cc67ef 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py @@ -7,6 +7,7 @@ from .auto_layout import AutoLayout, AutoLayoutBatch from .auto_space_views import AutoSpaceViews, AutoSpaceViewsBatch from .background_kind import BackgroundKind, BackgroundKindArrayLike, BackgroundKindBatch, BackgroundKindLike +from .clipping_plane import ClippingPlane, ClippingPlaneBatch from .column_share import ColumnShare, ColumnShareBatch from .component_column_selector import ComponentColumnSelector, ComponentColumnSelectorBatch from .container_kind import ContainerKind, ContainerKindArrayLike, ContainerKindBatch, ContainerKindLike @@ -50,6 +51,8 @@ "BackgroundKindArrayLike", "BackgroundKindBatch", "BackgroundKindLike", + "ClippingPlane", + "ClippingPlaneBatch", "ColumnShare", "ColumnShareBatch", "ComponentColumnSelector", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py b/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py new file mode 100644 index 000000000000..081f302f88dd --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py @@ -0,0 +1,32 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs". + +# You can extend this class by creating a "ClippingPlaneExt" class in "clipping_plane_ext.py". + +from __future__ import annotations + +from ... import datatypes +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) + +__all__ = ["ClippingPlane", "ClippingPlaneBatch"] + + +class ClippingPlane(datatypes.Float32, ComponentMixin): + """**Component**: Distance to the clipping plane in used for `Spatial2DView`.""" + + _BATCH_TYPE = None + # You can define your own __init__ function as a member of ClippingPlaneExt in clipping_plane_ext.py + + # Note: there are no fields here because ClippingPlane delegates to datatypes.Float32 + pass + + +class ClippingPlaneBatch(datatypes.Float32Batch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.ClippingPlane" + + +# This is patched in late to avoid circular dependencies. +ClippingPlane._BATCH_TYPE = ClippingPlaneBatch # type: ignore[assignment] From ef114e00c66cdef40801f492a2a545ca97334bc5 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Fri, 6 Dec 2024 13:02:47 -0500 Subject: [PATCH 03/14] Add a default for clipping plane --- .../src/blueprint/components/clipping_plane_ext.rs | 11 +++++++++++ crates/store/re_types/src/blueprint/components/mod.rs | 1 + crates/viewer/re_viewer/src/reflection/mod.rs | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 crates/store/re_types/src/blueprint/components/clipping_plane_ext.rs diff --git a/crates/store/re_types/src/blueprint/components/clipping_plane_ext.rs b/crates/store/re_types/src/blueprint/components/clipping_plane_ext.rs new file mode 100644 index 000000000000..21bb1e4dcca1 --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/clipping_plane_ext.rs @@ -0,0 +1,11 @@ +use re_types_core::datatypes::Float32; + +use super::ClippingPlane; + +impl Default for ClippingPlane { + #[inline] + fn default() -> Self { + // Default clipping plane set at a reasonable distance for common cameras + Self(Float32(0.1)) + } +} diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index cd3240c8e948..2f9d88ebb16b 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -4,6 +4,7 @@ mod active_tab; mod apply_latest_at; mod background_kind; mod clipping_plane; +mod clipping_plane_ext; mod column_share; mod component_column_selector; mod component_column_selector_ext; diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 565764c1e67c..9459f75b28b9 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -78,7 +78,7 @@ fn generate_component_reflection() -> Result::name(), ComponentReflection { docstring_md: "Distance to the clipping plane in used for `Spatial2DView`.", - custom_placeholder: None, + custom_placeholder: Some(ClippingPlane::default().to_arrow2()?), datatype: ClippingPlane::arrow2_datatype(), }, ), From beaeea3f37ae5c13fe106fc027b2d16658d521d0 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Fri, 6 Dec 2024 13:14:06 -0500 Subject: [PATCH 04/14] Make the clipping plane editable --- crates/viewer/re_component_ui/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index 55b7da2d4730..031df5435194 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -35,7 +35,8 @@ use datatype_uis::{ use re_types::{ blueprint::components::{ - BackgroundKind, Corner2D, GridSpacing, LockRangeDuringZoom, MapProvider, ViewFit, Visible, + BackgroundKind, ClippingPlane, Corner2D, GridSpacing, LockRangeDuringZoom, MapProvider, + ViewFit, Visible, }, components::{ AggregationPolicy, AlbedoFactor, AxisLength, Color, DepthMeter, DrawOrder, FillMode, @@ -76,6 +77,7 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_ui_points); registry.add_singleline_edit_or_view::(edit_ui_points); + registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); // float min-max components: registry.add_singleline_edit_or_view::(edit_f32_min_to_max_float); From 3f5162cddfcb089cafce332701374cf79a75d897 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Fri, 6 Dec 2024 13:14:18 -0500 Subject: [PATCH 05/14] Use the clipping plane --- .../viewer/re_space_view_spatial/src/ui_2d.rs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/viewer/re_space_view_spatial/src/ui_2d.rs b/crates/viewer/re_space_view_spatial/src/ui_2d.rs index 54d3a64c89b3..8624885d8365 100644 --- a/crates/viewer/re_space_view_spatial/src/ui_2d.rs +++ b/crates/viewer/re_space_view_spatial/src/ui_2d.rs @@ -15,8 +15,7 @@ use re_types::{ }; use re_ui::{ContextExt as _, ModifiersMarkdown, MouseButtonMarkdown}; use re_viewer_context::{ - gpu_bridge, ItemSpaceContext, SpaceViewId, SpaceViewSystemExecutionError, ViewQuery, - ViewerContext, + gpu_bridge, ItemSpaceContext, SpaceViewSystemExecutionError, ViewQuery, ViewerContext, }; use re_viewport_blueprint::ViewProperty; @@ -31,16 +30,11 @@ use crate::{ /// Pan and zoom, and return the current transform. fn ui_from_scene( ctx: &ViewerContext<'_>, - view_id: SpaceViewId, response: &egui::Response, view_class: &SpatialSpaceView2D, view_state: &mut SpatialSpaceViewState, + bounds_property: &ViewProperty, ) -> RectTransform { - let bounds_property = ViewProperty::from_archetype::( - ctx.blueprint_db(), - ctx.blueprint_query, - view_id, - ); let bounds: blueprint_components::VisualBounds2D = bounds_property .component_or_fallback(ctx, view_class, view_state) .ok_or_log_error() @@ -169,10 +163,21 @@ impl SpatialSpaceView2D { let (response, painter) = ui.allocate_painter(ui.available_size(), egui::Sense::click_and_drag()); + let bounds_property = ViewProperty::from_archetype::( + ctx.blueprint_db(), + ctx.blueprint_query, + query.space_view_id, + ); + // Convert ui coordinates to/from scene coordinates. - let ui_from_scene = ui_from_scene(ctx, query.space_view_id, &response, self, state); + let ui_from_scene = ui_from_scene(ctx, &response, self, state, &bounds_property); let scene_from_ui = ui_from_scene.inverse(); + let clipping_plane: blueprint_components::ClippingPlane = bounds_property + .component_or_fallback(ctx, self, state) + .ok_or_log_error() + .unwrap_or_default(); + // TODO(andreas): Use the same eye & transformations as in `setup_target_config`. let eye = Eye { world_from_rub_view: IsoTransform::IDENTITY, @@ -183,6 +188,7 @@ impl SpatialSpaceView2D { let Ok(target_config) = setup_target_config( &painter, scene_bounds, + *clipping_plane.0, &query.space_origin.to_string(), query.highlights.any_outlines(), &state.pinhole_at_origin, @@ -287,6 +293,7 @@ impl SpatialSpaceView2D { fn setup_target_config( egui_painter: &egui::Painter, scene_bounds: Rect, + clipping_plane: f32, space_name: &str, any_outlines: bool, scene_pinhole: &Option, @@ -350,7 +357,7 @@ fn setup_target_config( let projection_from_view = re_renderer::view_builder::Projection::Perspective { vertical_fov: pinhole.fov_y().unwrap_or(Eye::DEFAULT_FOV_Y), - near_plane_distance: 0.1, + near_plane_distance: clipping_plane, aspect_ratio: pinhole .aspect_ratio() .unwrap_or(scene_bounds_size.x / scene_bounds_size.y), // only happens if the pinhole lacks resolution From 0841c0c54d3676b07e562d4c831ed7b72c95e8c5 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Fri, 6 Dec 2024 13:33:38 -0500 Subject: [PATCH 06/14] Avoid panic if we hit zero --- crates/viewer/re_space_view_spatial/src/ui_2d.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/viewer/re_space_view_spatial/src/ui_2d.rs b/crates/viewer/re_space_view_spatial/src/ui_2d.rs index 8624885d8365..3c7a5ad512be 100644 --- a/crates/viewer/re_space_view_spatial/src/ui_2d.rs +++ b/crates/viewer/re_space_view_spatial/src/ui_2d.rs @@ -184,11 +184,14 @@ impl SpatialSpaceView2D { fov_y: None, }; + // Don't let clipping plane become zero + let clipping_plane = f32::max(f32::MIN_POSITIVE, *clipping_plane.0); + let scene_bounds = *scene_from_ui.to(); let Ok(target_config) = setup_target_config( &painter, scene_bounds, - *clipping_plane.0, + clipping_plane, &query.space_origin.to_string(), query.highlights.any_outlines(), &state.pinhole_at_origin, From 89a74cb3ce1e9030038e08d6718ca8557a9fdfe7 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Fri, 6 Dec 2024 13:33:54 -0500 Subject: [PATCH 07/14] Allow blueprint editing of clipping_plane --- .../archetypes/visual_bounds2d_ext.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py index 78cc1158bbfc..124fbf1cd03e 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py @@ -13,8 +13,9 @@ class VisualBounds2DExt: def __init__( self: Any, *, - x_range: datatypes.Range1DLike, - y_range: datatypes.Range1DLike, + x_range: datatypes.Range1DLike | None = None, + y_range: datatypes.Range1DLike | None = None, + clipping_plane: datatypes.Float32Like | None = None, ): """ Create a new instance of the VisualBounds2D archetype. @@ -25,10 +26,22 @@ def __init__( The minimum visible range of the X-axis (usually left and right bounds). y_range: The minimum visible range of the Y-axis (usually left and right bounds). + clipping_plane: + The distance to the near clipping plane. """ + if x_range is not None and y_range is not None: + range = blueprint_components.VisualBounds2D(x_range=x_range, y_range=y_range) + elif x_range is not None or y_range is not None: + raise ValueError("Both x_range and y_range must be specified.") + else: + range = None + with catch_and_log_exceptions(context=self.__class__.__name__): - self.__attrs_init__(range=blueprint_components.VisualBounds2D(x_range=x_range, y_range=y_range)) + self.__attrs_init__( + range=range, + clipping_plane=clipping_plane, + ) return self.__attrs_clear__() From 1a0fc86e1b4c6cd5ab1f71604905e509f5f4a638 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Fri, 6 Dec 2024 13:37:06 -0500 Subject: [PATCH 08/14] Docstrings and links --- .../rerun/blueprint/archetypes/visual_bounds2d.fbs | 2 +- .../rerun/blueprint/components/clipping_plane.fbs | 7 ++++--- .../re_types/src/blueprint/archetypes/visual_bounds2d.rs | 2 +- .../re_types/src/blueprint/components/clipping_plane.rs | 4 ++-- crates/viewer/re_viewer/src/reflection/mod.rs | 6 +++--- docs/content/reference/types/views/graph_view.md | 2 +- docs/content/reference/types/views/spatial2d_view.md | 2 +- .../src/rerun/blueprint/archetypes/visual_bounds2d.hpp | 2 +- .../src/rerun/blueprint/components/clipping_plane.hpp | 4 ++-- .../rerun/blueprint/archetypes/visual_bounds2d.py | 2 +- .../rerun_sdk/rerun/blueprint/components/clipping_plane.py | 2 +- 11 files changed, 18 insertions(+), 17 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs index 68e2144e11bd..2d14b549951d 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs @@ -17,6 +17,6 @@ table VisualBounds2D ( /// Use this to control pan & zoom of the view. range: rerun.blueprint.components.VisualBounds2D ("attr.rerun.component_required", order: 1000); - /// Controls the distance to the clipping plane + /// Controls the distance to the near clipping plane clipping_plane: rerun.blueprint.components.ClippingPlane ("attr.rerun.component_optional", order: 2000); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs index d80dfff991e5..0b76d4cddb6a 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs @@ -2,12 +2,13 @@ namespace rerun.blueprint.components; // --- -/// Distance to the clipping plane in used for `Spatial2DView`. +/// Distance to the near clipping plane in used for `Spatial2DView`. struct ClippingPlane ( "attr.rerun.scope": "blueprint", "attr.rust.derive": "Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable", - "attr.rust.repr": "transparent" + "attr.rust.repr": "transparent", + "attr.docs.unreleased" ) { - /// Z distance to the clipping plane + /// Z distance to the near clipping plane clipping_plane: rerun.datatypes.Float32 (order: 100); } diff --git a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs index 71157b7ee113..2c2b3c4c49c5 100644 --- a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs +++ b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs @@ -32,7 +32,7 @@ pub struct VisualBounds2D { /// Use this to control pan & zoom of the view. pub range: crate::blueprint::components::VisualBounds2D, - /// Controls the distance to the clipping plane + /// Controls the distance to the near clipping plane pub clipping_plane: crate::blueprint::components::ClippingPlane, } diff --git a/crates/store/re_types/src/blueprint/components/clipping_plane.rs b/crates/store/re_types/src/blueprint/components/clipping_plane.rs index ed7b988f0fe8..00b200e7263c 100644 --- a/crates/store/re_types/src/blueprint/components/clipping_plane.rs +++ b/crates/store/re_types/src/blueprint/components/clipping_plane.rs @@ -18,11 +18,11 @@ use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Component**: Distance to the clipping plane in used for `Spatial2DView`. +/// **Component**: Distance to the near clipping plane in used for `Spatial2DView`. #[derive(Clone, Debug, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)] #[repr(transparent)] pub struct ClippingPlane( - /// Z distance to the clipping plane + /// Z distance to the near clipping plane pub crate::datatypes::Float32, ); diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 9459f75b28b9..ed64a6d0f5d0 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -77,7 +77,7 @@ fn generate_component_reflection() -> Result::name(), ComponentReflection { - docstring_md: "Distance to the clipping plane in used for `Spatial2DView`.", + docstring_md: "Distance to the near clipping plane in used for `Spatial2DView`.", custom_placeholder: Some(ClippingPlane::default().to_arrow2()?), datatype: ClippingPlane::arrow2_datatype(), }, @@ -2213,8 +2213,8 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { is_required : true, }, ArchetypeFieldReflection { component_name : "rerun.blueprint.components.ClippingPlane".into(), display_name : "Clipping plane", docstring_md : - "Controls the distance to the clipping plane", is_required : false, - }, + "Controls the distance to the near clipping plane", is_required : + false, }, ], }, ), diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 5a5a66aef3de..9b660dd87f58 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -13,7 +13,7 @@ Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. * `range`: Controls the visible range of a 2D view. -* `clipping_plane`: Controls the distance to the clipping plane +* `clipping_plane`: Controls the distance to the near clipping plane ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/docs/content/reference/types/views/spatial2d_view.md b/docs/content/reference/types/views/spatial2d_view.md index ba38a28c87f4..df50ded00644 100644 --- a/docs/content/reference/types/views/spatial2d_view.md +++ b/docs/content/reference/types/views/spatial2d_view.md @@ -19,7 +19,7 @@ Everything within these bounds are guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. * `range`: Controls the visible range of a 2D view. -* `clipping_plane`: Controls the distance to the clipping plane +* `clipping_plane`: Controls the distance to the near clipping plane ### `time_ranges` Configures which range on each timeline is shown by this view (unless specified differently per entity). diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp index 575bf01e7736..11b5a8d729f0 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp @@ -28,7 +28,7 @@ namespace rerun::blueprint::archetypes { /// Use this to control pan & zoom of the view. rerun::blueprint::components::VisualBounds2D range; - /// Controls the distance to the clipping plane + /// Controls the distance to the near clipping plane rerun::blueprint::components::ClippingPlane clipping_plane; public: diff --git a/rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp b/rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp index 286f94f17824..565780e525dd 100644 --- a/rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp @@ -10,9 +10,9 @@ #include namespace rerun::blueprint::components { - /// **Component**: Distance to the clipping plane in used for `Spatial2DView`. + /// **Component**: Distance to the near clipping plane in used for `Spatial2DView`. struct ClippingPlane { - /// Z distance to the clipping plane + /// Z distance to the near clipping plane rerun::datatypes::Float32 clipping_plane; public: diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py index dd9e336a58db..6b2a5998924f 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py @@ -58,7 +58,7 @@ def _clear(cls) -> VisualBounds2D: metadata={"component": "required"}, converter=blueprint_components.ClippingPlaneBatch._required, # type: ignore[misc] ) - # Controls the distance to the clipping plane + # Controls the distance to the near clipping plane # # (Docstring intentionally commented out to hide this field from the docs) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py b/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py index 081f302f88dd..3826085c32e6 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py @@ -15,7 +15,7 @@ class ClippingPlane(datatypes.Float32, ComponentMixin): - """**Component**: Distance to the clipping plane in used for `Spatial2DView`.""" + """**Component**: Distance to the near clipping plane in used for `Spatial2DView`.""" _BATCH_TYPE = None # You can define your own __init__ function as a member of ClippingPlaneExt in clipping_plane_ext.py From 2a6a68a807096ea4dd7c9c42e6856f0dc6e81512 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Mon, 9 Dec 2024 10:15:55 -0500 Subject: [PATCH 09/14] Rename to near_clip_plane --- .../rerun/blueprint/archetypes/visual_bounds2d.fbs | 6 ++++-- .../{clipping_plane.fbs => near_clip_plane.fbs} | 8 ++++---- .../src/blueprint/components/clipping_plane_ext.rs | 11 ----------- .../src/blueprint/components/near_clip_plane_ext.rs | 11 +++++++++++ 4 files changed, 19 insertions(+), 17 deletions(-) rename crates/store/re_types/definitions/rerun/blueprint/components/{clipping_plane.fbs => near_clip_plane.fbs} (53%) delete mode 100644 crates/store/re_types/src/blueprint/components/clipping_plane_ext.rs create mode 100644 crates/store/re_types/src/blueprint/components/near_clip_plane_ext.rs diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs index 2d14b549951d..109cf5507440 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs @@ -17,6 +17,8 @@ table VisualBounds2D ( /// Use this to control pan & zoom of the view. range: rerun.blueprint.components.VisualBounds2D ("attr.rerun.component_required", order: 1000); - /// Controls the distance to the near clipping plane - clipping_plane: rerun.blueprint.components.ClippingPlane ("attr.rerun.component_optional", order: 2000); + /// Controls the distance to the near clip plane. + /// + /// Content closer than this distance will not be visible. + near_clip_plane: rerun.blueprint.components.NearClipPlane ("attr.rerun.component_optional", order: 2000); } diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs similarity index 53% rename from crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs rename to crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs index 0b76d4cddb6a..80bbcf3d5ca0 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs @@ -2,13 +2,13 @@ namespace rerun.blueprint.components; // --- -/// Distance to the near clipping plane in used for `Spatial2DView`. -struct ClippingPlane ( +/// Distance to the near clip plane used for `Spatial2DView`. +struct NearClipPlane ( "attr.rerun.scope": "blueprint", "attr.rust.derive": "Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable", "attr.rust.repr": "transparent", "attr.docs.unreleased" ) { - /// Z distance to the near clipping plane - clipping_plane: rerun.datatypes.Float32 (order: 100); + /// Distance to the near clip plane. + near_clip_plane: rerun.datatypes.Float32 (order: 100); } diff --git a/crates/store/re_types/src/blueprint/components/clipping_plane_ext.rs b/crates/store/re_types/src/blueprint/components/clipping_plane_ext.rs deleted file mode 100644 index 21bb1e4dcca1..000000000000 --- a/crates/store/re_types/src/blueprint/components/clipping_plane_ext.rs +++ /dev/null @@ -1,11 +0,0 @@ -use re_types_core::datatypes::Float32; - -use super::ClippingPlane; - -impl Default for ClippingPlane { - #[inline] - fn default() -> Self { - // Default clipping plane set at a reasonable distance for common cameras - Self(Float32(0.1)) - } -} diff --git a/crates/store/re_types/src/blueprint/components/near_clip_plane_ext.rs b/crates/store/re_types/src/blueprint/components/near_clip_plane_ext.rs new file mode 100644 index 000000000000..89f46e4246e6 --- /dev/null +++ b/crates/store/re_types/src/blueprint/components/near_clip_plane_ext.rs @@ -0,0 +1,11 @@ +use re_types_core::datatypes::Float32; + +use super::NearClipPlane; + +impl Default for NearClipPlane { + #[inline] + fn default() -> Self { + // Default near clip plane to reasonable distance for common cameras + Self(Float32(0.1)) + } +} From ff3366a1c73724beb420f9fff03bda3336080791 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Mon, 9 Dec 2024 10:18:42 -0500 Subject: [PATCH 10/14] Codegen --- .../rerun/blueprint/components.fbs | 2 +- .../blueprint/archetypes/visual_bounds2d.rs | 34 ++++++++-------- .../src/blueprint/components/.gitattributes | 2 +- .../re_types/src/blueprint/components/mod.rs | 6 +-- .../{clipping_plane.rs => near_clip_plane.rs} | 26 ++++++------ .../src/blueprint/validation_gen/mod.rs | 4 +- crates/viewer/re_viewer/src/reflection/mod.rs | 24 +++++------ .../reference/types/views/graph_view.md | 2 +- .../reference/types/views/spatial2d_view.md | 2 +- .../blueprint/archetypes/visual_bounds2d.cpp | 2 +- .../blueprint/archetypes/visual_bounds2d.hpp | 12 +++--- rerun_cpp/src/rerun/blueprint/components.hpp | 2 +- .../rerun/blueprint/components/.gitattributes | 2 +- ...clipping_plane.hpp => near_clip_plane.hpp} | 40 +++++++++---------- .../blueprint/archetypes/visual_bounds2d.py | 10 +++-- .../rerun/blueprint/components/.gitattributes | 2 +- .../rerun/blueprint/components/__init__.py | 6 +-- .../blueprint/components/clipping_plane.py | 32 --------------- .../blueprint/components/near_clip_plane.py | 32 +++++++++++++++ 19 files changed, 124 insertions(+), 118 deletions(-) rename crates/store/re_types/src/blueprint/components/{clipping_plane.rs => near_clip_plane.rs} (80%) rename rerun_cpp/src/rerun/blueprint/components/{clipping_plane.hpp => near_clip_plane.hpp} (64%) delete mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py create mode 100644 rerun_py/rerun_sdk/rerun/blueprint/components/near_clip_plane.py diff --git a/crates/store/re_types/definitions/rerun/blueprint/components.fbs b/crates/store/re_types/definitions/rerun/blueprint/components.fbs index bed41a3e5312..4f216593296d 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components.fbs @@ -5,7 +5,6 @@ include "./components/apply_latest_at.fbs"; include "./components/auto_layout.fbs"; include "./components/auto_space_views.fbs"; include "./components/background_kind.fbs"; -include "./components/clipping_plane.fbs"; include "./components/column_share.fbs"; include "./components/component_column_selector.fbs"; include "./components/container_kind.fbs"; @@ -18,6 +17,7 @@ include "./components/included_content.fbs"; include "./components/interactive.fbs"; include "./components/lock_range_during_zoom.fbs"; include "./components/map_provider.fbs"; +include "./components/near_clip_plane.fbs"; include "./components/panel_state.fbs"; include "./components/query_expression.fbs"; include "./components/root_container.fbs"; diff --git a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs index 2c2b3c4c49c5..dfc043ed1b1c 100644 --- a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs +++ b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs @@ -32,20 +32,22 @@ pub struct VisualBounds2D { /// Use this to control pan & zoom of the view. pub range: crate::blueprint::components::VisualBounds2D, - /// Controls the distance to the near clipping plane - pub clipping_plane: crate::blueprint::components::ClippingPlane, + /// Controls the distance to the near clip plane. + /// + /// Content closer than this distance will not be visible. + pub near_clip_plane: crate::blueprint::components::NearClipPlane, } impl ::re_types_core::SizeBytes for VisualBounds2D { #[inline] fn heap_size_bytes(&self) -> u64 { - self.range.heap_size_bytes() + self.clipping_plane.heap_size_bytes() + self.range.heap_size_bytes() + self.near_clip_plane.heap_size_bytes() } #[inline] fn is_pod() -> bool { ::is_pod() - && ::is_pod() + && ::is_pod() } } @@ -56,14 +58,14 @@ static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.VisualBounds2DIndicator".into()]); static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 1usize]> = - once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.ClippingPlane".into()]); + once_cell::sync::Lazy::new(|| ["rerun.blueprint.components.NearClipPlane".into()]); static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentName; 3usize]> = once_cell::sync::Lazy::new(|| { [ "rerun.blueprint.components.VisualBounds2D".into(), "rerun.blueprint.components.VisualBounds2DIndicator".into(), - "rerun.blueprint.components.ClippingPlane".into(), + "rerun.blueprint.components.NearClipPlane".into(), ] }); @@ -137,22 +139,22 @@ impl ::re_types_core::Archetype for VisualBounds2D { .ok_or_else(DeserializationError::missing_data) .with_context("rerun.blueprint.archetypes.VisualBounds2D#range")? }; - let clipping_plane = { + let near_clip_plane = { let array = arrays_by_name - .get("rerun.blueprint.components.ClippingPlane") + .get("rerun.blueprint.components.NearClipPlane") .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.VisualBounds2D#clipping_plane")?; - ::from_arrow2_opt(&**array) - .with_context("rerun.blueprint.archetypes.VisualBounds2D#clipping_plane")? + .with_context("rerun.blueprint.archetypes.VisualBounds2D#near_clip_plane")?; + ::from_arrow2_opt(&**array) + .with_context("rerun.blueprint.archetypes.VisualBounds2D#near_clip_plane")? .into_iter() .next() .flatten() .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.blueprint.archetypes.VisualBounds2D#clipping_plane")? + .with_context("rerun.blueprint.archetypes.VisualBounds2D#near_clip_plane")? }; Ok(Self { range, - clipping_plane, + near_clip_plane, }) } } @@ -164,7 +166,7 @@ impl ::re_types_core::AsComponents for VisualBounds2D { [ Some(Self::indicator()), Some((&self.range as &dyn ComponentBatch).into()), - Some((&self.clipping_plane as &dyn ComponentBatch).into()), + Some((&self.near_clip_plane as &dyn ComponentBatch).into()), ] .into_iter() .flatten() @@ -179,11 +181,11 @@ impl VisualBounds2D { #[inline] pub fn new( range: impl Into, - clipping_plane: impl Into, + near_clip_plane: impl Into, ) -> Self { Self { range: range.into(), - clipping_plane: clipping_plane.into(), + near_clip_plane: near_clip_plane.into(), } } } diff --git a/crates/store/re_types/src/blueprint/components/.gitattributes b/crates/store/re_types/src/blueprint/components/.gitattributes index ac9a3a4bb30f..65eeb1377804 100644 --- a/crates/store/re_types/src/blueprint/components/.gitattributes +++ b/crates/store/re_types/src/blueprint/components/.gitattributes @@ -4,7 +4,6 @@ active_tab.rs linguist-generated=true apply_latest_at.rs linguist-generated=true background_kind.rs linguist-generated=true -clipping_plane.rs linguist-generated=true column_share.rs linguist-generated=true component_column_selector.rs linguist-generated=true corner2d.rs linguist-generated=true @@ -16,6 +15,7 @@ interactive.rs linguist-generated=true lock_range_during_zoom.rs linguist-generated=true map_provider.rs linguist-generated=true mod.rs linguist-generated=true +near_clip_plane.rs linguist-generated=true panel_state.rs linguist-generated=true query_expression.rs linguist-generated=true row_share.rs linguist-generated=true diff --git a/crates/store/re_types/src/blueprint/components/mod.rs b/crates/store/re_types/src/blueprint/components/mod.rs index 2f9d88ebb16b..15647fbf1138 100644 --- a/crates/store/re_types/src/blueprint/components/mod.rs +++ b/crates/store/re_types/src/blueprint/components/mod.rs @@ -3,8 +3,6 @@ mod active_tab; mod apply_latest_at; mod background_kind; -mod clipping_plane; -mod clipping_plane_ext; mod column_share; mod component_column_selector; mod component_column_selector_ext; @@ -21,6 +19,8 @@ mod interactive; mod interactive_ext; mod lock_range_during_zoom; mod map_provider; +mod near_clip_plane; +mod near_clip_plane_ext; mod panel_state; mod panel_state_ext; mod query_expression; @@ -47,7 +47,6 @@ mod zoom_level; pub use self::active_tab::ActiveTab; pub use self::apply_latest_at::ApplyLatestAt; pub use self::background_kind::BackgroundKind; -pub use self::clipping_plane::ClippingPlane; pub use self::column_share::ColumnShare; pub use self::component_column_selector::ComponentColumnSelector; pub use self::corner2d::Corner2D; @@ -58,6 +57,7 @@ pub use self::included_content::IncludedContent; pub use self::interactive::Interactive; pub use self::lock_range_during_zoom::LockRangeDuringZoom; pub use self::map_provider::MapProvider; +pub use self::near_clip_plane::NearClipPlane; pub use self::panel_state::PanelState; pub use self::query_expression::QueryExpression; pub use self::row_share::RowShare; diff --git a/crates/store/re_types/src/blueprint/components/clipping_plane.rs b/crates/store/re_types/src/blueprint/components/near_clip_plane.rs similarity index 80% rename from crates/store/re_types/src/blueprint/components/clipping_plane.rs rename to crates/store/re_types/src/blueprint/components/near_clip_plane.rs index 00b200e7263c..9dd837e05896 100644 --- a/crates/store/re_types/src/blueprint/components/clipping_plane.rs +++ b/crates/store/re_types/src/blueprint/components/near_clip_plane.rs @@ -1,5 +1,5 @@ // DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs". +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs". #![allow(unused_imports)] #![allow(unused_parens)] @@ -18,15 +18,15 @@ use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, MaybeOwnedComponentBatch}; use ::re_types_core::{DeserializationError, DeserializationResult}; -/// **Component**: Distance to the near clipping plane in used for `Spatial2DView`. +/// **Component**: Distance to the near clip plane used for `Spatial2DView`. #[derive(Clone, Debug, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)] #[repr(transparent)] -pub struct ClippingPlane( - /// Z distance to the near clipping plane +pub struct NearClipPlane( + /// Distance to the near clip plane. pub crate::datatypes::Float32, ); -impl ::re_types_core::SizeBytes for ClippingPlane { +impl ::re_types_core::SizeBytes for NearClipPlane { #[inline] fn heap_size_bytes(&self) -> u64 { self.0.heap_size_bytes() @@ -38,20 +38,20 @@ impl ::re_types_core::SizeBytes for ClippingPlane { } } -impl> From for ClippingPlane { +impl> From for NearClipPlane { fn from(v: T) -> Self { Self(v.into()) } } -impl std::borrow::Borrow for ClippingPlane { +impl std::borrow::Borrow for NearClipPlane { #[inline] fn borrow(&self) -> &crate::datatypes::Float32 { &self.0 } } -impl std::ops::Deref for ClippingPlane { +impl std::ops::Deref for NearClipPlane { type Target = crate::datatypes::Float32; #[inline] @@ -60,16 +60,16 @@ impl std::ops::Deref for ClippingPlane { } } -impl std::ops::DerefMut for ClippingPlane { +impl std::ops::DerefMut for NearClipPlane { #[inline] fn deref_mut(&mut self) -> &mut crate::datatypes::Float32 { &mut self.0 } } -::re_types_core::macros::impl_into_cow!(ClippingPlane); +::re_types_core::macros::impl_into_cow!(NearClipPlane); -impl ::re_types_core::Loggable for ClippingPlane { +impl ::re_types_core::Loggable for NearClipPlane { #[inline] fn arrow_datatype() -> arrow::datatypes::DataType { crate::datatypes::Float32::arrow_datatype() @@ -108,9 +108,9 @@ impl ::re_types_core::Loggable for ClippingPlane { } } -impl ::re_types_core::Component for ClippingPlane { +impl ::re_types_core::Component for NearClipPlane { #[inline] fn name() -> ComponentName { - "rerun.blueprint.components.ClippingPlane".into() + "rerun.blueprint.components.NearClipPlane".into() } } diff --git a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs index 5c4394388100..e2ffaf50eb40 100644 --- a/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs +++ b/crates/viewer/re_viewer/src/blueprint/validation_gen/mod.rs @@ -4,7 +4,6 @@ use re_entity_db::EntityDb; pub use re_types::blueprint::components::ActiveTab; pub use re_types::blueprint::components::ApplyLatestAt; pub use re_types::blueprint::components::BackgroundKind; -pub use re_types::blueprint::components::ClippingPlane; pub use re_types::blueprint::components::ColumnShare; pub use re_types::blueprint::components::ComponentColumnSelector; pub use re_types::blueprint::components::Corner2D; @@ -15,6 +14,7 @@ pub use re_types::blueprint::components::IncludedContent; pub use re_types::blueprint::components::Interactive; pub use re_types::blueprint::components::LockRangeDuringZoom; pub use re_types::blueprint::components::MapProvider; +pub use re_types::blueprint::components::NearClipPlane; pub use re_types::blueprint::components::PanelState; pub use re_types::blueprint::components::QueryExpression; pub use re_types::blueprint::components::RowShare; @@ -46,7 +46,6 @@ pub fn is_valid_blueprint(blueprint: &EntityDb) -> bool { && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) - && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) @@ -59,6 +58,7 @@ pub fn is_valid_blueprint(blueprint: &EntityDb) -> bool { && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) + && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) && validate_component::(blueprint) diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index ed64a6d0f5d0..bf2a1c2704f8 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -74,14 +74,6 @@ fn generate_component_reflection() -> Result::name(), - ComponentReflection { - docstring_md: "Distance to the near clipping plane in used for `Spatial2DView`.", - custom_placeholder: Some(ClippingPlane::default().to_arrow2()?), - datatype: ClippingPlane::arrow2_datatype(), - }, - ), ( ::name(), ComponentReflection { @@ -180,6 +172,14 @@ fn generate_component_reflection() -> Result::name(), + ComponentReflection { + docstring_md: "Distance to the near clip plane used for `Spatial2DView`.", + custom_placeholder: Some(NearClipPlane::default().to_arrow2()?), + datatype: NearClipPlane::arrow2_datatype(), + }, + ), ( ::name(), ComponentReflection { @@ -2211,10 +2211,10 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { "Range", docstring_md : "Controls the visible range of a 2D view.\n\nUse this to control pan & zoom of the view.", is_required : true, }, ArchetypeFieldReflection { component_name : - "rerun.blueprint.components.ClippingPlane".into(), display_name : - "Clipping plane", docstring_md : - "Controls the distance to the near clipping plane", is_required : - false, }, + "rerun.blueprint.components.NearClipPlane".into(), display_name : + "Near clip plane", docstring_md : + "Controls the distance to the near clip plane.\n\nContent closer than this distance will not be visible.", + is_required : false, }, ], }, ), diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 9b660dd87f58..35c3d3e7e9ef 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -13,7 +13,7 @@ Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. * `range`: Controls the visible range of a 2D view. -* `clipping_plane`: Controls the distance to the near clipping plane +* `near_clip_plane`: Controls the distance to the near clip plane. ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/docs/content/reference/types/views/spatial2d_view.md b/docs/content/reference/types/views/spatial2d_view.md index df50ded00644..9162a52b4d3a 100644 --- a/docs/content/reference/types/views/spatial2d_view.md +++ b/docs/content/reference/types/views/spatial2d_view.md @@ -19,7 +19,7 @@ Everything within these bounds are guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. * `range`: Controls the visible range of a 2D view. -* `clipping_plane`: Controls the distance to the near clipping plane +* `near_clip_plane`: Controls the distance to the near clip plane. ### `time_ranges` Configures which range on each timeline is shown by this view (unless specified differently per entity). diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp index e011984dcfb7..4fe8376a198f 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.cpp @@ -23,7 +23,7 @@ namespace rerun { cells.push_back(std::move(result.value)); } { - auto result = ComponentBatch::from_loggable(archetype.clipping_plane); + auto result = ComponentBatch::from_loggable(archetype.near_clip_plane); RR_RETURN_NOT_OK(result.error); cells.push_back(std::move(result.value)); } diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp index 11b5a8d729f0..0147b25bd5be 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp @@ -3,7 +3,7 @@ #pragma once -#include "../../blueprint/components/clipping_plane.hpp" +#include "../../blueprint/components/near_clip_plane.hpp" #include "../../blueprint/components/visual_bounds2d.hpp" #include "../../collection.hpp" #include "../../component_batch.hpp" @@ -28,8 +28,10 @@ namespace rerun::blueprint::archetypes { /// Use this to control pan & zoom of the view. rerun::blueprint::components::VisualBounds2D range; - /// Controls the distance to the near clipping plane - rerun::blueprint::components::ClippingPlane clipping_plane; + /// Controls the distance to the near clip plane. + /// + /// Content closer than this distance will not be visible. + rerun::blueprint::components::NearClipPlane near_clip_plane; public: static constexpr const char IndicatorComponentName[] = @@ -44,9 +46,9 @@ namespace rerun::blueprint::archetypes { explicit VisualBounds2D( rerun::blueprint::components::VisualBounds2D _range, - rerun::blueprint::components::ClippingPlane _clipping_plane + rerun::blueprint::components::NearClipPlane _near_clip_plane ) - : range(std::move(_range)), clipping_plane(std::move(_clipping_plane)) {} + : range(std::move(_range)), near_clip_plane(std::move(_near_clip_plane)) {} }; } // namespace rerun::blueprint::archetypes diff --git a/rerun_cpp/src/rerun/blueprint/components.hpp b/rerun_cpp/src/rerun/blueprint/components.hpp index b82a71e2bacf..e5ed33415971 100644 --- a/rerun_cpp/src/rerun/blueprint/components.hpp +++ b/rerun_cpp/src/rerun/blueprint/components.hpp @@ -7,7 +7,6 @@ #include "blueprint/components/auto_layout.hpp" #include "blueprint/components/auto_space_views.hpp" #include "blueprint/components/background_kind.hpp" -#include "blueprint/components/clipping_plane.hpp" #include "blueprint/components/column_share.hpp" #include "blueprint/components/component_column_selector.hpp" #include "blueprint/components/container_kind.hpp" @@ -20,6 +19,7 @@ #include "blueprint/components/interactive.hpp" #include "blueprint/components/lock_range_during_zoom.hpp" #include "blueprint/components/map_provider.hpp" +#include "blueprint/components/near_clip_plane.hpp" #include "blueprint/components/panel_state.hpp" #include "blueprint/components/query_expression.hpp" #include "blueprint/components/root_container.hpp" diff --git a/rerun_cpp/src/rerun/blueprint/components/.gitattributes b/rerun_cpp/src/rerun/blueprint/components/.gitattributes index aca8c2fb51f9..01c332e58b9c 100644 --- a/rerun_cpp/src/rerun/blueprint/components/.gitattributes +++ b/rerun_cpp/src/rerun/blueprint/components/.gitattributes @@ -7,7 +7,6 @@ auto_layout.hpp linguist-generated=true auto_space_views.hpp linguist-generated=true background_kind.cpp linguist-generated=true background_kind.hpp linguist-generated=true -clipping_plane.hpp linguist-generated=true column_share.hpp linguist-generated=true component_column_selector.hpp linguist-generated=true container_kind.cpp linguist-generated=true @@ -23,6 +22,7 @@ interactive.hpp linguist-generated=true lock_range_during_zoom.hpp linguist-generated=true map_provider.cpp linguist-generated=true map_provider.hpp linguist-generated=true +near_clip_plane.hpp linguist-generated=true panel_state.cpp linguist-generated=true panel_state.hpp linguist-generated=true query_expression.hpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp b/rerun_cpp/src/rerun/blueprint/components/near_clip_plane.hpp similarity index 64% rename from rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp rename to rerun_cpp/src/rerun/blueprint/components/near_clip_plane.hpp index 565780e525dd..3080cf101e36 100644 --- a/rerun_cpp/src/rerun/blueprint/components/clipping_plane.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/near_clip_plane.hpp @@ -1,5 +1,5 @@ // DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs -// Based on "crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs". +// Based on "crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs". #pragma once @@ -10,54 +10,54 @@ #include namespace rerun::blueprint::components { - /// **Component**: Distance to the near clipping plane in used for `Spatial2DView`. - struct ClippingPlane { - /// Z distance to the near clipping plane - rerun::datatypes::Float32 clipping_plane; + /// **Component**: Distance to the near clip plane used for `Spatial2DView`. + struct NearClipPlane { + /// Distance to the near clip plane. + rerun::datatypes::Float32 near_clip_plane; public: - ClippingPlane() = default; + NearClipPlane() = default; - ClippingPlane(rerun::datatypes::Float32 clipping_plane_) - : clipping_plane(clipping_plane_) {} + NearClipPlane(rerun::datatypes::Float32 near_clip_plane_) + : near_clip_plane(near_clip_plane_) {} - ClippingPlane& operator=(rerun::datatypes::Float32 clipping_plane_) { - clipping_plane = clipping_plane_; + NearClipPlane& operator=(rerun::datatypes::Float32 near_clip_plane_) { + near_clip_plane = near_clip_plane_; return *this; } - ClippingPlane(float value_) : clipping_plane(value_) {} + NearClipPlane(float value_) : near_clip_plane(value_) {} - ClippingPlane& operator=(float value_) { - clipping_plane = value_; + NearClipPlane& operator=(float value_) { + near_clip_plane = value_; return *this; } /// Cast to the underlying Float32 datatype operator rerun::datatypes::Float32() const { - return clipping_plane; + return near_clip_plane; } }; } // namespace rerun::blueprint::components namespace rerun { static_assert( - sizeof(rerun::datatypes::Float32) == sizeof(blueprint::components::ClippingPlane) + sizeof(rerun::datatypes::Float32) == sizeof(blueprint::components::NearClipPlane) ); /// \private template <> - struct Loggable { - static constexpr const char Name[] = "rerun.blueprint.components.ClippingPlane"; + struct Loggable { + static constexpr const char Name[] = "rerun.blueprint.components.NearClipPlane"; /// Returns the arrow data type this type corresponds to. static const std::shared_ptr& arrow_datatype() { return Loggable::arrow_datatype(); } - /// Serializes an array of `rerun::blueprint:: components::ClippingPlane` into an arrow array. + /// Serializes an array of `rerun::blueprint:: components::NearClipPlane` into an arrow array. static Result> to_arrow( - const blueprint::components::ClippingPlane* instances, size_t num_instances + const blueprint::components::NearClipPlane* instances, size_t num_instances ) { if (num_instances == 0) { return Loggable::to_arrow(nullptr, 0); @@ -68,7 +68,7 @@ namespace rerun { ); } else { return Loggable::to_arrow( - &instances->clipping_plane, + &instances->near_clip_plane, num_instances ); } diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py index 6b2a5998924f..9e448fc149fc 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py @@ -34,7 +34,7 @@ def __attrs_clear__(self) -> None: """Convenience method for calling `__attrs_init__` with all `None`s.""" self.__attrs_init__( range=None, # type: ignore[arg-type] - clipping_plane=None, # type: ignore[arg-type] + near_clip_plane=None, # type: ignore[arg-type] ) @classmethod @@ -54,11 +54,13 @@ def _clear(cls) -> VisualBounds2D: # # (Docstring intentionally commented out to hide this field from the docs) - clipping_plane: blueprint_components.ClippingPlaneBatch = field( + near_clip_plane: blueprint_components.NearClipPlaneBatch = field( metadata={"component": "required"}, - converter=blueprint_components.ClippingPlaneBatch._required, # type: ignore[misc] + converter=blueprint_components.NearClipPlaneBatch._required, # type: ignore[misc] ) - # Controls the distance to the near clipping plane + # Controls the distance to the near clip plane. + # + # Content closer than this distance will not be visible. # # (Docstring intentionally commented out to hide this field from the docs) diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes index 8fafaed413c5..4fdcc51e8c50 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/.gitattributes @@ -7,7 +7,6 @@ apply_latest_at.py linguist-generated=true auto_layout.py linguist-generated=true auto_space_views.py linguist-generated=true background_kind.py linguist-generated=true -clipping_plane.py linguist-generated=true column_share.py linguist-generated=true component_column_selector.py linguist-generated=true container_kind.py linguist-generated=true @@ -20,6 +19,7 @@ included_content.py linguist-generated=true interactive.py linguist-generated=true lock_range_during_zoom.py linguist-generated=true map_provider.py linguist-generated=true +near_clip_plane.py linguist-generated=true panel_state.py linguist-generated=true query_expression.py linguist-generated=true root_container.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py index 2f2ea6cc67ef..18d213e617d7 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/__init__.py @@ -7,7 +7,6 @@ from .auto_layout import AutoLayout, AutoLayoutBatch from .auto_space_views import AutoSpaceViews, AutoSpaceViewsBatch from .background_kind import BackgroundKind, BackgroundKindArrayLike, BackgroundKindBatch, BackgroundKindLike -from .clipping_plane import ClippingPlane, ClippingPlaneBatch from .column_share import ColumnShare, ColumnShareBatch from .component_column_selector import ComponentColumnSelector, ComponentColumnSelectorBatch from .container_kind import ContainerKind, ContainerKindArrayLike, ContainerKindBatch, ContainerKindLike @@ -20,6 +19,7 @@ from .interactive import Interactive, InteractiveBatch from .lock_range_during_zoom import LockRangeDuringZoom, LockRangeDuringZoomBatch from .map_provider import MapProvider, MapProviderArrayLike, MapProviderBatch, MapProviderLike +from .near_clip_plane import NearClipPlane, NearClipPlaneBatch from .panel_state import PanelState, PanelStateArrayLike, PanelStateBatch, PanelStateLike from .query_expression import QueryExpression, QueryExpressionBatch from .root_container import RootContainer, RootContainerBatch @@ -51,8 +51,6 @@ "BackgroundKindArrayLike", "BackgroundKindBatch", "BackgroundKindLike", - "ClippingPlane", - "ClippingPlaneBatch", "ColumnShare", "ColumnShareBatch", "ComponentColumnSelector", @@ -83,6 +81,8 @@ "MapProviderArrayLike", "MapProviderBatch", "MapProviderLike", + "NearClipPlane", + "NearClipPlaneBatch", "PanelState", "PanelStateArrayLike", "PanelStateBatch", diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py b/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py deleted file mode 100644 index 3826085c32e6..000000000000 --- a/rerun_py/rerun_sdk/rerun/blueprint/components/clipping_plane.py +++ /dev/null @@ -1,32 +0,0 @@ -# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs -# Based on "crates/store/re_types/definitions/rerun/blueprint/components/clipping_plane.fbs". - -# You can extend this class by creating a "ClippingPlaneExt" class in "clipping_plane_ext.py". - -from __future__ import annotations - -from ... import datatypes -from ..._baseclasses import ( - ComponentBatchMixin, - ComponentMixin, -) - -__all__ = ["ClippingPlane", "ClippingPlaneBatch"] - - -class ClippingPlane(datatypes.Float32, ComponentMixin): - """**Component**: Distance to the near clipping plane in used for `Spatial2DView`.""" - - _BATCH_TYPE = None - # You can define your own __init__ function as a member of ClippingPlaneExt in clipping_plane_ext.py - - # Note: there are no fields here because ClippingPlane delegates to datatypes.Float32 - pass - - -class ClippingPlaneBatch(datatypes.Float32Batch, ComponentBatchMixin): - _COMPONENT_NAME: str = "rerun.blueprint.components.ClippingPlane" - - -# This is patched in late to avoid circular dependencies. -ClippingPlane._BATCH_TYPE = ClippingPlaneBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/blueprint/components/near_clip_plane.py b/rerun_py/rerun_sdk/rerun/blueprint/components/near_clip_plane.py new file mode 100644 index 000000000000..6049557a9aad --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/blueprint/components/near_clip_plane.py @@ -0,0 +1,32 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs". + +# You can extend this class by creating a "NearClipPlaneExt" class in "near_clip_plane_ext.py". + +from __future__ import annotations + +from ... import datatypes +from ..._baseclasses import ( + ComponentBatchMixin, + ComponentMixin, +) + +__all__ = ["NearClipPlane", "NearClipPlaneBatch"] + + +class NearClipPlane(datatypes.Float32, ComponentMixin): + """**Component**: Distance to the near clip plane used for `Spatial2DView`.""" + + _BATCH_TYPE = None + # You can define your own __init__ function as a member of NearClipPlaneExt in near_clip_plane_ext.py + + # Note: there are no fields here because NearClipPlane delegates to datatypes.Float32 + pass + + +class NearClipPlaneBatch(datatypes.Float32Batch, ComponentBatchMixin): + _COMPONENT_NAME: str = "rerun.blueprint.components.NearClipPlane" + + +# This is patched in late to avoid circular dependencies. +NearClipPlane._BATCH_TYPE = NearClipPlaneBatch # type: ignore[assignment] From 0b502d37da36ec9874531f44f79356b0ce68ace1 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Mon, 9 Dec 2024 10:22:43 -0500 Subject: [PATCH 11/14] More renames --- crates/viewer/re_component_ui/src/lib.rs | 4 ++-- crates/viewer/re_space_view_spatial/src/ui_2d.rs | 10 +++++----- .../rerun/blueprint/archetypes/visual_bounds2d_ext.py | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index 031df5435194..e598c046d3a0 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -35,7 +35,7 @@ use datatype_uis::{ use re_types::{ blueprint::components::{ - BackgroundKind, ClippingPlane, Corner2D, GridSpacing, LockRangeDuringZoom, MapProvider, + BackgroundKind, Corner2D, GridSpacing, LockRangeDuringZoom, MapProvider, NearClipPlane, ViewFit, Visible, }, components::{ @@ -77,7 +77,7 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); registry.add_singleline_edit_or_view::(edit_ui_points); registry.add_singleline_edit_or_view::(edit_ui_points); - registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); + registry.add_singleline_edit_or_view::(edit_f32_zero_to_max); // float min-max components: registry.add_singleline_edit_or_view::(edit_f32_min_to_max_float); diff --git a/crates/viewer/re_space_view_spatial/src/ui_2d.rs b/crates/viewer/re_space_view_spatial/src/ui_2d.rs index 3c7a5ad512be..b6a326801e54 100644 --- a/crates/viewer/re_space_view_spatial/src/ui_2d.rs +++ b/crates/viewer/re_space_view_spatial/src/ui_2d.rs @@ -173,7 +173,7 @@ impl SpatialSpaceView2D { let ui_from_scene = ui_from_scene(ctx, &response, self, state, &bounds_property); let scene_from_ui = ui_from_scene.inverse(); - let clipping_plane: blueprint_components::ClippingPlane = bounds_property + let near_clip_plane: blueprint_components::NearClipPlane = bounds_property .component_or_fallback(ctx, self, state) .ok_or_log_error() .unwrap_or_default(); @@ -185,13 +185,13 @@ impl SpatialSpaceView2D { }; // Don't let clipping plane become zero - let clipping_plane = f32::max(f32::MIN_POSITIVE, *clipping_plane.0); + let near_clip_plane = f32::max(f32::MIN_POSITIVE, *near_clip_plane.0); let scene_bounds = *scene_from_ui.to(); let Ok(target_config) = setup_target_config( &painter, scene_bounds, - clipping_plane, + near_clip_plane, &query.space_origin.to_string(), query.highlights.any_outlines(), &state.pinhole_at_origin, @@ -296,7 +296,7 @@ impl SpatialSpaceView2D { fn setup_target_config( egui_painter: &egui::Painter, scene_bounds: Rect, - clipping_plane: f32, + near_clip_plane: f32, space_name: &str, any_outlines: bool, scene_pinhole: &Option, @@ -360,7 +360,7 @@ fn setup_target_config( let projection_from_view = re_renderer::view_builder::Projection::Perspective { vertical_fov: pinhole.fov_y().unwrap_or(Eye::DEFAULT_FOV_Y), - near_plane_distance: clipping_plane, + near_plane_distance: near_clip_plane, aspect_ratio: pinhole .aspect_ratio() .unwrap_or(scene_bounds_size.x / scene_bounds_size.y), // only happens if the pinhole lacks resolution diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py index 124fbf1cd03e..f28c2ae1f359 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d_ext.py @@ -15,7 +15,7 @@ def __init__( *, x_range: datatypes.Range1DLike | None = None, y_range: datatypes.Range1DLike | None = None, - clipping_plane: datatypes.Float32Like | None = None, + near_clip_plane: datatypes.Float32Like | None = None, ): """ Create a new instance of the VisualBounds2D archetype. @@ -26,7 +26,7 @@ def __init__( The minimum visible range of the X-axis (usually left and right bounds). y_range: The minimum visible range of the Y-axis (usually left and right bounds). - clipping_plane: + near_clip_plane: The distance to the near clipping plane. """ @@ -41,7 +41,7 @@ def __init__( with catch_and_log_exceptions(context=self.__class__.__name__): self.__attrs_init__( range=range, - clipping_plane=clipping_plane, + near_clip_plane=near_clip_plane, ) return self.__attrs_clear__() From ab8e901ef6c7d3a71ed0be03ab9103b98d23702b Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Mon, 9 Dec 2024 12:40:29 -0500 Subject: [PATCH 12/14] Scale near_clip_plane according to focal length --- crates/viewer/re_space_view_spatial/src/ui_2d.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/viewer/re_space_view_spatial/src/ui_2d.rs b/crates/viewer/re_space_view_spatial/src/ui_2d.rs index b6a326801e54..6f5ae55cfd15 100644 --- a/crates/viewer/re_space_view_spatial/src/ui_2d.rs +++ b/crates/viewer/re_space_view_spatial/src/ui_2d.rs @@ -358,17 +358,17 @@ fn setup_target_config( } let pinhole_rect = Rect::from_min_size(Pos2::ZERO, egui::vec2(resolution.x, resolution.y)); + let focal_length = pinhole.focal_length_in_pixels(); + let focal_length = 2.0 / (1.0 / focal_length.x() + 1.0 / focal_length.y()); // harmonic mean (lack of anamorphic support) + let projection_from_view = re_renderer::view_builder::Projection::Perspective { vertical_fov: pinhole.fov_y().unwrap_or(Eye::DEFAULT_FOV_Y), - near_plane_distance: near_clip_plane, + near_plane_distance: near_clip_plane * focal_length / 500.0, // TODO(#8373): The need to scale this by 500 is quite hacky. aspect_ratio: pinhole .aspect_ratio() .unwrap_or(scene_bounds_size.x / scene_bounds_size.y), // only happens if the pinhole lacks resolution }; - let focal_length = pinhole.focal_length_in_pixels(); - let focal_length = 2.0 / (1.0 / focal_length.x() + 1.0 / focal_length.y()); // harmonic mean (lack of anamorphic support) - // Position the camera looking straight at the principal point: let view_from_world = re_math::IsoTransform::look_at_rh( pinhole.principal_point().extend(-focal_length), From e24f5f2bdb582d26a8ad7bf11a6a18ada468fb02 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Mon, 9 Dec 2024 12:43:47 -0500 Subject: [PATCH 13/14] Update comments --- .../definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs | 2 +- .../definitions/rerun/blueprint/components/near_clip_plane.fbs | 2 +- .../store/re_types/src/blueprint/archetypes/visual_bounds2d.rs | 2 +- .../store/re_types/src/blueprint/components/near_clip_plane.rs | 2 +- crates/viewer/re_viewer/src/reflection/mod.rs | 2 +- docs/content/reference/types/views/graph_view.md | 2 +- docs/content/reference/types/views/spatial2d_view.md | 2 +- rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp | 2 +- rerun_cpp/src/rerun/blueprint/components/near_clip_plane.hpp | 2 +- .../rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs index 109cf5507440..21b8599e5383 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/archetypes/visual_bounds2d.fbs @@ -17,7 +17,7 @@ table VisualBounds2D ( /// Use this to control pan & zoom of the view. range: rerun.blueprint.components.VisualBounds2D ("attr.rerun.component_required", order: 1000); - /// Controls the distance to the near clip plane. + /// Controls the distance to the near clip plane in 3D scene units. /// /// Content closer than this distance will not be visible. near_clip_plane: rerun.blueprint.components.NearClipPlane ("attr.rerun.component_optional", order: 2000); diff --git a/crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs b/crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs index 80bbcf3d5ca0..200fc64ef33b 100644 --- a/crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs +++ b/crates/store/re_types/definitions/rerun/blueprint/components/near_clip_plane.fbs @@ -9,6 +9,6 @@ struct NearClipPlane ( "attr.rust.repr": "transparent", "attr.docs.unreleased" ) { - /// Distance to the near clip plane. + /// Distance to the near clip plane in 3D scene units. near_clip_plane: rerun.datatypes.Float32 (order: 100); } diff --git a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs index dfc043ed1b1c..dfb9ba30caa5 100644 --- a/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs +++ b/crates/store/re_types/src/blueprint/archetypes/visual_bounds2d.rs @@ -32,7 +32,7 @@ pub struct VisualBounds2D { /// Use this to control pan & zoom of the view. pub range: crate::blueprint::components::VisualBounds2D, - /// Controls the distance to the near clip plane. + /// Controls the distance to the near clip plane in 3D scene units. /// /// Content closer than this distance will not be visible. pub near_clip_plane: crate::blueprint::components::NearClipPlane, diff --git a/crates/store/re_types/src/blueprint/components/near_clip_plane.rs b/crates/store/re_types/src/blueprint/components/near_clip_plane.rs index 9dd837e05896..ec22d988b6b8 100644 --- a/crates/store/re_types/src/blueprint/components/near_clip_plane.rs +++ b/crates/store/re_types/src/blueprint/components/near_clip_plane.rs @@ -22,7 +22,7 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; #[derive(Clone, Debug, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable)] #[repr(transparent)] pub struct NearClipPlane( - /// Distance to the near clip plane. + /// Distance to the near clip plane in 3D scene units. pub crate::datatypes::Float32, ); diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index bf2a1c2704f8..115d4817f4a3 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -2213,7 +2213,7 @@ fn generate_archetype_reflection() -> ArchetypeReflectionMap { is_required : true, }, ArchetypeFieldReflection { component_name : "rerun.blueprint.components.NearClipPlane".into(), display_name : "Near clip plane", docstring_md : - "Controls the distance to the near clip plane.\n\nContent closer than this distance will not be visible.", + "Controls the distance to the near clip plane in 3D scene units.\n\nContent closer than this distance will not be visible.", is_required : false, }, ], }, diff --git a/docs/content/reference/types/views/graph_view.md b/docs/content/reference/types/views/graph_view.md index 35c3d3e7e9ef..58432cb123b8 100644 --- a/docs/content/reference/types/views/graph_view.md +++ b/docs/content/reference/types/views/graph_view.md @@ -13,7 +13,7 @@ Everything within these bounds is guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. * `range`: Controls the visible range of a 2D view. -* `near_clip_plane`: Controls the distance to the near clip plane. +* `near_clip_plane`: Controls the distance to the near clip plane in 3D scene units. ## API reference links * 🐍 [Python API docs for `GraphView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views?speculative-link#rerun.blueprint.views.GraphView) diff --git a/docs/content/reference/types/views/spatial2d_view.md b/docs/content/reference/types/views/spatial2d_view.md index 9162a52b4d3a..e4f40d2374ea 100644 --- a/docs/content/reference/types/views/spatial2d_view.md +++ b/docs/content/reference/types/views/spatial2d_view.md @@ -19,7 +19,7 @@ Everything within these bounds are guaranteed to be visible. Somethings outside of these bounds may also be visible due to letterboxing. * `range`: Controls the visible range of a 2D view. -* `near_clip_plane`: Controls the distance to the near clip plane. +* `near_clip_plane`: Controls the distance to the near clip plane in 3D scene units. ### `time_ranges` Configures which range on each timeline is shown by this view (unless specified differently per entity). diff --git a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp index 0147b25bd5be..0cf72032e464 100644 --- a/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp +++ b/rerun_cpp/src/rerun/blueprint/archetypes/visual_bounds2d.hpp @@ -28,7 +28,7 @@ namespace rerun::blueprint::archetypes { /// Use this to control pan & zoom of the view. rerun::blueprint::components::VisualBounds2D range; - /// Controls the distance to the near clip plane. + /// Controls the distance to the near clip plane in 3D scene units. /// /// Content closer than this distance will not be visible. rerun::blueprint::components::NearClipPlane near_clip_plane; diff --git a/rerun_cpp/src/rerun/blueprint/components/near_clip_plane.hpp b/rerun_cpp/src/rerun/blueprint/components/near_clip_plane.hpp index 3080cf101e36..0e32dcd0eda3 100644 --- a/rerun_cpp/src/rerun/blueprint/components/near_clip_plane.hpp +++ b/rerun_cpp/src/rerun/blueprint/components/near_clip_plane.hpp @@ -12,7 +12,7 @@ namespace rerun::blueprint::components { /// **Component**: Distance to the near clip plane used for `Spatial2DView`. struct NearClipPlane { - /// Distance to the near clip plane. + /// Distance to the near clip plane in 3D scene units. rerun::datatypes::Float32 near_clip_plane; public: diff --git a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py index 9e448fc149fc..110ebd5c2d69 100644 --- a/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py +++ b/rerun_py/rerun_sdk/rerun/blueprint/archetypes/visual_bounds2d.py @@ -58,7 +58,7 @@ def _clear(cls) -> VisualBounds2D: metadata={"component": "required"}, converter=blueprint_components.NearClipPlaneBatch._required, # type: ignore[misc] ) - # Controls the distance to the near clip plane. + # Controls the distance to the near clip plane in 3D scene units. # # Content closer than this distance will not be visible. # From b8a538a2d6b093c4219d568cc10e629dbf66d9ae Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Mon, 9 Dec 2024 12:58:03 -0500 Subject: [PATCH 14/14] Add to 0.21 migration guide --- .../reference/migration/migration-0-21.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs/content/reference/migration/migration-0-21.md diff --git a/docs/content/reference/migration/migration-0-21.md b/docs/content/reference/migration/migration-0-21.md new file mode 100644 index 000000000000..e0b0a5d693a7 --- /dev/null +++ b/docs/content/reference/migration/migration-0-21.md @@ -0,0 +1,27 @@ +--- +title: Migrating from 0.20 to 0.21 +order: 989 +--- + +### Near clip plane for `Spatial2D` views now defaults to `0.1` in 3D scene units. + +Previously, the clip plane was set an arbitrary value that worked reasonably for +cameras with large focal lengths, but become problematic for cameras with smaller +focal length values. This value is now normalized based on the focal length of +the camera. + +If the default value of `0.1` is still too large for your use-case it can be configured +using the new `near_clip_plane` of the `VisualBounds2D` blueprint property, either +through the UI, or through the SDK in Python: +```python +rr.send_blueprint( + rrb.Spatial2DView( + origin="world/cam", + contents="/**", + visual_bounds=rrb.VisualBounds2D( + near_clip_plane=0.01, + ), + ) +) +``` +