From c7b4d7841116c38d5de9119bcde3b1201574439b Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Thu, 25 Jul 2024 18:14:15 +0200 Subject: [PATCH 1/4] remove Scale3D/Transform3D/TranslationRotationScale3D datatypes, remove Transform3D component --- .../re_types/definitions/rerun/components.fbs | 1 - .../rerun/components/transform3d.fbs | 11 - .../re_types/definitions/rerun/datatypes.fbs | 3 - .../definitions/rerun/datatypes/scale3d.fbs | 27 -- .../rerun/datatypes/transform3d.fbs | 16 - .../translation_rotation_scale3d.fbs | 33 -- .../re_types/src/components/.gitattributes | 1 - crates/store/re_types/src/components/mod.rs | 3 - .../re_types/src/components/transform3d.rs | 107 ----- .../src/components/transform3d_ext.rs | 97 ----- .../re_types/src/datatypes/.gitattributes | 3 - crates/store/re_types/src/datatypes/mod.rs | 9 - .../store/re_types/src/datatypes/scale3d.rs | 363 ---------------- .../re_types/src/datatypes/scale3d_ext.rs | 33 -- .../re_types/src/datatypes/transform3d.rs | 234 ---------- .../re_types/src/datatypes/transform3d_ext.rs | 126 ------ .../datatypes/translation_rotation_scale3d.rs | 411 ------------------ .../translation_rotation_scale3d_ext.rs | 143 ------ crates/top/rerun/src/sdk.rs | 7 +- .../re_data_ui/src/component_ui_registry.rs | 1 - crates/viewer/re_data_ui/src/lib.rs | 1 - crates/viewer/re_data_ui/src/transform3d.rs | 136 ------ .../src/contexts/transform_context.rs | 10 +- crates/viewer/re_viewer/src/reflection/mod.rs | 7 - docs/content/reference/types/components.md | 1 - .../reference/types/components/.gitattributes | 1 - .../reference/types/components/transform3d.md | 17 - docs/content/reference/types/datatypes.md | 3 - .../reference/types/datatypes/.gitattributes | 3 - .../reference/types/datatypes/rotation3d.md | 1 - .../reference/types/datatypes/scale3d.md | 21 - .../reference/types/datatypes/transform3d.md | 20 - .../datatypes/translation_rotation_scale3d.md | 23 - .../reference/types/datatypes/vec3d.md | 2 - rerun_cpp/src/rerun.hpp | 2 - rerun_cpp/src/rerun/components.hpp | 1 - rerun_cpp/src/rerun/components/.gitattributes | 1 - .../src/rerun/components/transform3d.hpp | 69 --- rerun_cpp/src/rerun/datatypes.hpp | 3 - rerun_cpp/src/rerun/datatypes/.gitattributes | 6 - rerun_cpp/src/rerun/datatypes/scale3d.cpp | 91 ---- rerun_cpp/src/rerun/datatypes/scale3d.hpp | 171 -------- rerun_cpp/src/rerun/datatypes/transform3d.cpp | 91 ---- rerun_cpp/src/rerun/datatypes/transform3d.hpp | 149 ------- .../translation_rotation_scale3d.cpp | 129 ------ .../translation_rotation_scale3d.hpp | 232 ---------- .../translation_rotation_scale3d_ext.cpp | 184 -------- .../rerun_sdk/rerun/components/.gitattributes | 1 - .../rerun_sdk/rerun/components/__init__.py | 4 - .../rerun_sdk/rerun/components/transform3d.py | 36 -- .../rerun_sdk/rerun/datatypes/.gitattributes | 3 - .../rerun_sdk/rerun/datatypes/__init__.py | 24 - rerun_py/rerun_sdk/rerun/datatypes/scale3d.py | 145 ------ .../rerun_sdk/rerun/datatypes/scale3d_ext.py | 26 -- .../rerun_sdk/rerun/datatypes/transform3d.py | 128 ------ .../rerun/datatypes/transform3d_ext.py | 135 ------ .../datatypes/translation_rotation_scale3d.py | 176 -------- .../translation_rotation_scale3d_ext.py | 32 -- rerun_py/tests/unit/test_transform3d.py | 12 - 59 files changed, 7 insertions(+), 3719 deletions(-) delete mode 100644 crates/store/re_types/definitions/rerun/components/transform3d.fbs delete mode 100644 crates/store/re_types/definitions/rerun/datatypes/scale3d.fbs delete mode 100644 crates/store/re_types/definitions/rerun/datatypes/transform3d.fbs delete mode 100644 crates/store/re_types/definitions/rerun/datatypes/translation_rotation_scale3d.fbs delete mode 100644 crates/store/re_types/src/components/transform3d.rs delete mode 100644 crates/store/re_types/src/components/transform3d_ext.rs delete mode 100644 crates/store/re_types/src/datatypes/scale3d.rs delete mode 100644 crates/store/re_types/src/datatypes/scale3d_ext.rs delete mode 100644 crates/store/re_types/src/datatypes/transform3d.rs delete mode 100644 crates/store/re_types/src/datatypes/transform3d_ext.rs delete mode 100644 crates/store/re_types/src/datatypes/translation_rotation_scale3d.rs delete mode 100644 crates/store/re_types/src/datatypes/translation_rotation_scale3d_ext.rs delete mode 100644 crates/viewer/re_data_ui/src/transform3d.rs delete mode 100644 docs/content/reference/types/components/transform3d.md delete mode 100644 docs/content/reference/types/datatypes/scale3d.md delete mode 100644 docs/content/reference/types/datatypes/transform3d.md delete mode 100644 docs/content/reference/types/datatypes/translation_rotation_scale3d.md delete mode 100644 rerun_cpp/src/rerun/components/transform3d.hpp delete mode 100644 rerun_cpp/src/rerun/datatypes/scale3d.cpp delete mode 100644 rerun_cpp/src/rerun/datatypes/scale3d.hpp delete mode 100644 rerun_cpp/src/rerun/datatypes/transform3d.cpp delete mode 100644 rerun_cpp/src/rerun/datatypes/transform3d.hpp delete mode 100644 rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d.cpp delete mode 100644 rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d.hpp delete mode 100644 rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d_ext.cpp delete mode 100644 rerun_py/rerun_sdk/rerun/components/transform3d.py delete mode 100644 rerun_py/rerun_sdk/rerun/datatypes/scale3d.py delete mode 100644 rerun_py/rerun_sdk/rerun/datatypes/scale3d_ext.py delete mode 100644 rerun_py/rerun_sdk/rerun/datatypes/transform3d.py delete mode 100644 rerun_py/rerun_sdk/rerun/datatypes/transform3d_ext.py delete mode 100644 rerun_py/rerun_sdk/rerun/datatypes/translation_rotation_scale3d.py delete mode 100644 rerun_py/rerun_sdk/rerun/datatypes/translation_rotation_scale3d_ext.py diff --git a/crates/store/re_types/definitions/rerun/components.fbs b/crates/store/re_types/definitions/rerun/components.fbs index 5140b0b39b4b..8235ddc49b72 100644 --- a/crates/store/re_types/definitions/rerun/components.fbs +++ b/crates/store/re_types/definitions/rerun/components.fbs @@ -47,7 +47,6 @@ include "./components/tensor_dimension_selection.fbs"; include "./components/texcoord2d.fbs"; include "./components/text.fbs"; include "./components/text_log_level.fbs"; -include "./components/transform3d.fbs"; include "./components/transform_mat3x3.fbs"; include "./components/transform_relation.fbs"; include "./components/translation3d.fbs"; diff --git a/crates/store/re_types/definitions/rerun/components/transform3d.fbs b/crates/store/re_types/definitions/rerun/components/transform3d.fbs deleted file mode 100644 index 77c04942a456..000000000000 --- a/crates/store/re_types/definitions/rerun/components/transform3d.fbs +++ /dev/null @@ -1,11 +0,0 @@ -namespace rerun.components; - -// --- - -/// An affine transform between two 3D spaces, represented in a given direction. -table Transform3D ( - "attr.rust.derive": "Default, PartialEq" -) { - /// Representation of the transform. - repr: rerun.datatypes.Transform3D (order: 100); -} diff --git a/crates/store/re_types/definitions/rerun/datatypes.fbs b/crates/store/re_types/definitions/rerun/datatypes.fbs index b8167dd46f14..56953b0fa2ff 100644 --- a/crates/store/re_types/definitions/rerun/datatypes.fbs +++ b/crates/store/re_types/definitions/rerun/datatypes.fbs @@ -20,14 +20,11 @@ include "./datatypes/range2d.fbs"; include "./datatypes/rgba32.fbs"; include "./datatypes/rotation3d.fbs"; include "./datatypes/rotation_axis_angle.fbs"; -include "./datatypes/scale3d.fbs"; include "./datatypes/tensor_buffer.fbs"; include "./datatypes/tensor_data.fbs"; include "./datatypes/tensor_dimension.fbs"; include "./datatypes/tensor_dimension_selection.fbs"; include "./datatypes/time_int.fbs"; -include "./datatypes/transform3d.fbs"; -include "./datatypes/translation_rotation_scale3d.fbs"; include "./datatypes/uint32.fbs"; include "./datatypes/uint64.fbs"; include "./datatypes/utf8.fbs"; diff --git a/crates/store/re_types/definitions/rerun/datatypes/scale3d.fbs b/crates/store/re_types/definitions/rerun/datatypes/scale3d.fbs deleted file mode 100644 index b4475c630720..000000000000 --- a/crates/store/re_types/definitions/rerun/datatypes/scale3d.fbs +++ /dev/null @@ -1,27 +0,0 @@ -namespace rerun.datatypes; - -// --- - -/// 3D scaling factor, part of a transform representation. -/// -/// \py Example -/// \py ------- -/// \py -/// \py ```python -/// \py # uniform scaling -/// \py scale = rr.datatypes.Scale3D(3.) -/// \py -/// \py # non-uniform scaling -/// \py scale = rr.datatypes.Scale3D([1, 1, -1]) -/// \py scale = rr.datatypes.Scale3D(rr.datatypes.Vec3D([1, 1, -1])) -/// \py ``` -union Scale3D ( - "attr.python.aliases": "datatypes.Vec3DLike", - "attr.rust.derive": "Copy, PartialEq" -) { - /// Individual scaling factors for each axis, distorting the original object. - ThreeD: rerun.datatypes.Vec3D, - - /// Uniform scaling factor along all axis. - Uniform: rerun.datatypes.Float32 (transparent), -} diff --git a/crates/store/re_types/definitions/rerun/datatypes/transform3d.fbs b/crates/store/re_types/definitions/rerun/datatypes/transform3d.fbs deleted file mode 100644 index 37a235e8901c..000000000000 --- a/crates/store/re_types/definitions/rerun/datatypes/transform3d.fbs +++ /dev/null @@ -1,16 +0,0 @@ -namespace rerun.datatypes; - -// --- - -/// Representation of a 3D affine transform. -/// -/// \rs Rarely used directly, prefer using the underlying representation classes and pass them -/// \rs directly to `Transform3D::child_from_parent` or `Transform3D::parent_from_child`. -union Transform3D ( - "attr.rust.derive": "Copy, PartialEq" -) { - /// Translation, rotation and scale, decomposed. - TranslationRotationScale: TranslationRotationScale3D, - - // TODO(andreas): Raw 4x4 matrix. -} diff --git a/crates/store/re_types/definitions/rerun/datatypes/translation_rotation_scale3d.fbs b/crates/store/re_types/definitions/rerun/datatypes/translation_rotation_scale3d.fbs deleted file mode 100644 index e41ec59b69d5..000000000000 --- a/crates/store/re_types/definitions/rerun/datatypes/translation_rotation_scale3d.fbs +++ /dev/null @@ -1,33 +0,0 @@ -namespace rerun.datatypes; - -// --- - -/// Representation of an affine transform via separate translation, rotation & scale. -table TranslationRotationScale3D ( - "attr.rust.derive": "Copy, PartialEq" -) { - /// 3D translation vector, applied last. - // - // NOTE: Nullable rather than defaulting to an identity-like value because we want to be able - // to differentiate between no value vs. default value in the backend. - translation: rerun.datatypes.Vec3D (nullable, order: 100); - - /// 3D rotation, applied second. - // - // NOTE: Nullable rather than defaulting to an identity-like value because we want to be able - // to differentiate between no value vs. default value in the backend. - rotation: rerun.datatypes.Rotation3D (nullable, order: 200); - - /// 3D scale, applied first. - // - // NOTE: Nullable rather than defaulting to an identity-like value because we want to be able - // to differentiate between no value vs. default value in the backend. - scale: rerun.datatypes.Scale3D (nullable, order: 300); - - // TODO(#2641): make this field non-nullable when default values are supported - /// If true, this transform is from the parent space to the space where the transform was logged. - /// - /// If false (default), the transform maps from this space to its parent, - /// i.e. the translation is the position in the parent space. - from_parent: bool = false (order: 400); -} diff --git a/crates/store/re_types/src/components/.gitattributes b/crates/store/re_types/src/components/.gitattributes index 7b321253b632..cadff36085a5 100644 --- a/crates/store/re_types/src/components/.gitattributes +++ b/crates/store/re_types/src/components/.gitattributes @@ -55,7 +55,6 @@ tensor_width_dimension.rs linguist-generated=true texcoord2d.rs linguist-generated=true text.rs linguist-generated=true text_log_level.rs linguist-generated=true -transform3d.rs linguist-generated=true transform_mat3x3.rs linguist-generated=true transform_relation.rs linguist-generated=true translation3d.rs linguist-generated=true diff --git a/crates/store/re_types/src/components/mod.rs b/crates/store/re_types/src/components/mod.rs index 47b442724b8c..771037481c3c 100644 --- a/crates/store/re_types/src/components/mod.rs +++ b/crates/store/re_types/src/components/mod.rs @@ -97,8 +97,6 @@ mod text; mod text_ext; mod text_log_level; mod text_log_level_ext; -mod transform3d; -mod transform3d_ext; mod transform_mat3x3; mod transform_mat3x3_ext; mod transform_relation; @@ -166,7 +164,6 @@ pub use self::tensor_width_dimension::TensorWidthDimension; pub use self::texcoord2d::Texcoord2D; pub use self::text::Text; pub use self::text_log_level::TextLogLevel; -pub use self::transform3d::Transform3D; pub use self::transform_mat3x3::TransformMat3x3; pub use self::transform_relation::TransformRelation; pub use self::translation3d::Translation3D; diff --git a/crates/store/re_types/src/components/transform3d.rs b/crates/store/re_types/src/components/transform3d.rs deleted file mode 100644 index bfa171adf8d9..000000000000 --- a/crates/store/re_types/src/components/transform3d.rs +++ /dev/null @@ -1,107 +0,0 @@ -// 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/components/transform3d.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**: An affine transform between two 3D spaces, represented in a given direction. -#[derive(Clone, Debug, Default, PartialEq)] -pub struct Transform3D( - /// Representation of the transform. - pub crate::datatypes::Transform3D, -); - -impl ::re_types_core::SizeBytes for Transform3D { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.0.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -impl> From for Transform3D { - fn from(v: T) -> Self { - Self(v.into()) - } -} - -impl std::borrow::Borrow for Transform3D { - #[inline] - fn borrow(&self) -> &crate::datatypes::Transform3D { - &self.0 - } -} - -impl std::ops::Deref for Transform3D { - type Target = crate::datatypes::Transform3D; - - #[inline] - fn deref(&self) -> &crate::datatypes::Transform3D { - &self.0 - } -} - -impl std::ops::DerefMut for Transform3D { - #[inline] - fn deref_mut(&mut self) -> &mut crate::datatypes::Transform3D { - &mut self.0 - } -} - -::re_types_core::macros::impl_into_cow!(Transform3D); - -impl ::re_types_core::Loggable for Transform3D { - type Name = ::re_types_core::ComponentName; - - #[inline] - fn name() -> Self::Name { - "rerun.components.Transform3D".into() - } - - #[inline] - fn arrow_datatype() -> arrow2::datatypes::DataType { - crate::datatypes::Transform3D::arrow_datatype() - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult> - where - Self: Clone + 'a, - { - crate::datatypes::Transform3D::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_arrow_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - crate::datatypes::Transform3D::from_arrow_opt(arrow_data) - .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) - } -} diff --git a/crates/store/re_types/src/components/transform3d_ext.rs b/crates/store/re_types/src/components/transform3d_ext.rs deleted file mode 100644 index 2e8e239d01f1..000000000000 --- a/crates/store/re_types/src/components/transform3d_ext.rs +++ /dev/null @@ -1,97 +0,0 @@ -use super::Transform3D; - -use crate::datatypes::{ - Rotation3D, Scale3D, Transform3D as Transform3DDatatype, TranslationRotationScale3D, Vec3D, -}; - -impl Transform3D { - /// Identity transform, i.e. parent & child are in the same space. - pub const IDENTITY: Self = Self(Transform3DDatatype::IDENTITY); - - /// Creates a new transform with a given representation, transforming from the parent space into the child space. - #[inline] - pub fn new>(t: T) -> Self { - Self(t.into()) - } - - /// From a translation. - #[inline] - pub fn from_translation(translation: impl Into) -> Self { - Self::from(TranslationRotationScale3D::from_translation(translation)) - } - - /// From a translation applied after a rotation, known as a rigid transformation. - #[inline] - pub fn from_translation_rotation( - translation: impl Into, - rotation: impl Into, - ) -> Self { - Self::from(TranslationRotationScale3D::from_translation_rotation( - translation, - rotation, - )) - } - - /// From a translation, applied after a rotation & scale, known as an affine transformation. - #[inline] - pub fn from_translation_rotation_scale( - translation: impl Into, - rotation: impl Into, - scale: impl Into, - ) -> Self { - Self::from(TranslationRotationScale3D::from_translation_rotation_scale( - translation, - rotation, - scale, - )) - } - - /// From a rotation & scale - #[inline] - pub fn from_rotation_scale(rotation: impl Into, scale: impl Into) -> Self { - Self::from(TranslationRotationScale3D::from_rotation_scale( - rotation, scale, - )) - } - - /// Indicate that this transform is from parent to child. - /// This is the oppositve of the default, which is from child to parent. - #[allow(clippy::wrong_self_convention)] - #[inline] - pub fn from_parent(mut self) -> Self { - self.0 = self.0.from_parent(); - self - } -} - -#[cfg(feature = "glam")] -impl Transform3D { - /// Returns the transform from child space to the parent space. - /// - /// For instance, if we have an entity at position `[1, 2, 3]` in the parent space, - /// then this transform would be the translation `+[1, 2, 3]`, - /// transforming the child's origin `[0, 0, 0]` to its position - /// in parent space (`[1, 2, 3]`). - #[inline] - pub fn into_parent_from_child_transform(self) -> glam::Affine3A { - let transform: glam::Affine3A = self.0.into(); - if self.0.is_from_parent() { - transform.inverse() - } else { - transform - } - } - - /// Returns the transform from parent space to the child space. - /// - /// This is the inverse of [`Self::into_parent_from_child_transform`]. - #[inline] - pub fn into_child_from_parent_transform(self) -> glam::Affine3A { - let transform: glam::Affine3A = self.0.into(); - if self.0.is_from_parent() { - transform - } else { - transform.inverse() - } - } -} diff --git a/crates/store/re_types/src/datatypes/.gitattributes b/crates/store/re_types/src/datatypes/.gitattributes index aff736f4e372..49589d36e3f3 100644 --- a/crates/store/re_types/src/datatypes/.gitattributes +++ b/crates/store/re_types/src/datatypes/.gitattributes @@ -18,14 +18,11 @@ range2d.rs linguist-generated=true rgba32.rs linguist-generated=true rotation3d.rs linguist-generated=true rotation_axis_angle.rs linguist-generated=true -scale3d.rs linguist-generated=true tensor_buffer.rs linguist-generated=true tensor_data.rs linguist-generated=true tensor_dimension.rs linguist-generated=true tensor_dimension_index_selection.rs linguist-generated=true tensor_dimension_selection.rs linguist-generated=true -transform3d.rs linguist-generated=true -translation_rotation_scale3d.rs linguist-generated=true uuid.rs linguist-generated=true uvec2d.rs linguist-generated=true uvec3d.rs linguist-generated=true diff --git a/crates/store/re_types/src/datatypes/mod.rs b/crates/store/re_types/src/datatypes/mod.rs index 31f50297f441..536bd15df391 100644 --- a/crates/store/re_types/src/datatypes/mod.rs +++ b/crates/store/re_types/src/datatypes/mod.rs @@ -32,8 +32,6 @@ mod rotation3d; mod rotation3d_ext; mod rotation_axis_angle; mod rotation_axis_angle_ext; -mod scale3d; -mod scale3d_ext; mod tensor_buffer; mod tensor_buffer_ext; mod tensor_data; @@ -43,10 +41,6 @@ mod tensor_dimension_ext; mod tensor_dimension_index_selection; mod tensor_dimension_selection; mod tensor_dimension_selection_ext; -mod transform3d; -mod transform3d_ext; -mod translation_rotation_scale3d; -mod translation_rotation_scale3d_ext; mod uuid; mod uuid_ext; mod uvec2d; @@ -80,14 +74,11 @@ pub use self::range2d::Range2D; pub use self::rgba32::Rgba32; pub use self::rotation3d::Rotation3D; pub use self::rotation_axis_angle::RotationAxisAngle; -pub use self::scale3d::Scale3D; pub use self::tensor_buffer::TensorBuffer; pub use self::tensor_data::TensorData; pub use self::tensor_dimension::TensorDimension; pub use self::tensor_dimension_index_selection::TensorDimensionIndexSelection; pub use self::tensor_dimension_selection::TensorDimensionSelection; -pub use self::transform3d::Transform3D; -pub use self::translation_rotation_scale3d::TranslationRotationScale3D; pub use self::uuid::Uuid; pub use self::uvec2d::UVec2D; pub use self::uvec3d::UVec3D; diff --git a/crates/store/re_types/src/datatypes/scale3d.rs b/crates/store/re_types/src/datatypes/scale3d.rs deleted file mode 100644 index 144a185212ba..000000000000 --- a/crates/store/re_types/src/datatypes/scale3d.rs +++ /dev/null @@ -1,363 +0,0 @@ -// 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/datatypes/scale3d.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}; - -/// **Datatype**: 3D scaling factor, part of a transform representation. -#[derive(Clone, Debug, Copy, PartialEq)] -pub enum Scale3D { - /// Individual scaling factors for each axis, distorting the original object. - ThreeD(crate::datatypes::Vec3D), - - /// Uniform scaling factor along all axis. - Uniform(f32), -} - -impl ::re_types_core::SizeBytes for Scale3D { - #[inline] - fn heap_size_bytes(&self) -> u64 { - #![allow(clippy::match_same_arms)] - match self { - Self::ThreeD(v) => v.heap_size_bytes(), - Self::Uniform(v) => v.heap_size_bytes(), - } - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() && ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(Scale3D); - -impl ::re_types_core::Loggable for Scale3D { - type Name = ::re_types_core::DatatypeName; - - #[inline] - fn name() -> Self::Name { - "rerun.datatypes.Scale3D".into() - } - - #[inline] - fn arrow_datatype() -> arrow2::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow2::datatypes::*; - DataType::Union( - std::sync::Arc::new(vec![ - Field::new("_null_markers", DataType::Null, true), - Field::new("ThreeD", ::arrow_datatype(), false), - Field::new("Uniform", DataType::Float32, false), - ]), - Some(std::sync::Arc::new(vec![0i32, 1i32, 2i32])), - UnionMode::Dense, - ) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult> - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow2::{array::*, datatypes::*}; - Ok({ - // Dense Arrow union - let data: Vec<_> = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - datum - }) - .collect(); - let types = data - .iter() - .map(|a| match a.as_deref() { - None => 0, - Some(Self::ThreeD(_)) => 1i8, - Some(Self::Uniform(_)) => 2i8, - }) - .collect(); - let fields = vec![ - NullArray::new(DataType::Null, data.iter().filter(|v| v.is_none()).count()).boxed(), - { - let three_d: Vec<_> = data - .iter() - .filter_map(|datum| match datum.as_deref() { - Some(Self::ThreeD(v)) => Some(v.clone()), - _ => None, - }) - .collect(); - let three_d_bitmap: Option = None; - { - use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let three_d_inner_data: Vec<_> = - three_d.into_iter().map(|datum| datum.0).flatten().collect(); - let three_d_inner_bitmap: Option = None; - FixedSizeListArray::new( - DataType::FixedSizeList( - std::sync::Arc::new(Field::new("item", DataType::Float32, false)), - 3usize, - ), - PrimitiveArray::new( - DataType::Float32, - three_d_inner_data.into_iter().collect(), - three_d_inner_bitmap, - ) - .boxed(), - three_d_bitmap, - ) - .boxed() - } - }, - { - let uniform: Vec<_> = data - .iter() - .filter_map(|datum| match datum.as_deref() { - Some(Self::Uniform(v)) => Some(v.clone()), - _ => None, - }) - .collect(); - let uniform_bitmap: Option = None; - PrimitiveArray::new( - DataType::Float32, - uniform.into_iter().collect(), - uniform_bitmap, - ) - .boxed() - }, - ]; - let offsets = Some({ - let mut three_d_offset = 0; - let mut uniform_offset = 0; - let mut nulls_offset = 0; - data.iter() - .map(|v| match v.as_deref() { - None => { - let offset = nulls_offset; - nulls_offset += 1; - offset - } - Some(Self::ThreeD(_)) => { - let offset = three_d_offset; - three_d_offset += 1; - offset - } - Some(Self::Uniform(_)) => { - let offset = uniform_offset; - uniform_offset += 1; - offset - } - }) - .collect() - }); - UnionArray::new(Self::arrow_datatype(), types, fields, offsets).boxed() - }) - } - - fn from_arrow_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow2::{array::*, buffer::*, datatypes::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.datatypes.Scale3D")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_types, arrow_data_arrays) = - (arrow_data.types(), arrow_data.fields()); - let arrow_data_offsets = arrow_data - .offsets() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.datatypes.Scale3D")?; - if arrow_data_types.len() != arrow_data_offsets.len() { - return Err(DeserializationError::offset_slice_oob( - (0, arrow_data_types.len()), - arrow_data_offsets.len(), - )) - .with_context("rerun.datatypes.Scale3D"); - } - let three_d = { - if 1usize >= arrow_data_arrays.len() { - return Ok(Vec::new()); - } - let arrow_data = &*arrow_data_arrays[1usize]; - { - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::FixedSizeList( - std::sync::Arc::new(Field::new( - "item", - DataType::Float32, - false, - )), - 3usize, - ); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.datatypes.Scale3D#ThreeD")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let offsets = (0..) - .step_by(3usize) - .zip((3usize..).step_by(3usize).take(arrow_data.len())); - let arrow_data_inner = { - let arrow_data_inner = &**arrow_data.values(); - arrow_data_inner - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float32; - let actual = arrow_data_inner.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.datatypes.Scale3D#ThreeD")? - .into_iter() - .map(|opt| opt.copied()) - .collect::>() - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, end): (usize, usize)| { - debug_assert!(end - start == 3usize); - if end > arrow_data_inner.len() { - return Err(DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } - - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = - unsafe { arrow_data_inner.get_unchecked(start..end) }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - - // NOTE: Unwrapping cannot fail: the length must be correct. - #[allow(clippy::unwrap_used)] - Ok(array_init::from_iter(data).unwrap()) - }) - .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| res_or_opt.map(crate::datatypes::Vec3D)) - }) - .collect::>>>()? - } - .into_iter() - } - .collect::>() - }; - let uniform = { - if 2usize >= arrow_data_arrays.len() { - return Ok(Vec::new()); - } - let arrow_data = &*arrow_data_arrays[2usize]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float32; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.datatypes.Scale3D#Uniform")? - .into_iter() - .map(|opt| opt.copied()) - .collect::>() - }; - arrow_data_types - .iter() - .enumerate() - .map(|(i, typ)| { - let offset = arrow_data_offsets[i]; - if *typ == 0 { - Ok(None) - } else { - Ok(Some(match typ { - 1i8 => Self::ThreeD({ - if offset as usize >= three_d.len() { - return Err(DeserializationError::offset_oob( - offset as _, - three_d.len(), - )) - .with_context("rerun.datatypes.Scale3D#ThreeD"); - } - - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - unsafe { three_d.get_unchecked(offset as usize) } - .clone() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.datatypes.Scale3D#ThreeD")? - }), - 2i8 => Self::Uniform({ - if offset as usize >= uniform.len() { - return Err(DeserializationError::offset_oob( - offset as _, - uniform.len(), - )) - .with_context("rerun.datatypes.Scale3D#Uniform"); - } - - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - unsafe { uniform.get_unchecked(offset as usize) } - .clone() - .ok_or_else(DeserializationError::missing_data) - .with_context("rerun.datatypes.Scale3D#Uniform")? - }), - _ => { - return Err(DeserializationError::missing_union_arm( - Self::arrow_datatype(), - "", - *typ as _, - )); - } - })) - } - }) - .collect::>>() - .with_context("rerun.datatypes.Scale3D")? - } - }) - } -} diff --git a/crates/store/re_types/src/datatypes/scale3d_ext.rs b/crates/store/re_types/src/datatypes/scale3d_ext.rs deleted file mode 100644 index d745ea870188..000000000000 --- a/crates/store/re_types/src/datatypes/scale3d_ext.rs +++ /dev/null @@ -1,33 +0,0 @@ -use super::Scale3D; - -impl From for Scale3D { - #[inline] - fn from(v: crate::datatypes::Vec3D) -> Self { - Self::ThreeD(v) - } -} - -impl From for Scale3D { - #[inline] - fn from(v: f32) -> Self { - Self::Uniform(v) - } -} - -impl From<[f32; 3]> for Scale3D { - #[inline] - fn from(v: [f32; 3]) -> Self { - Self::ThreeD(v.into()) - } -} - -#[cfg(feature = "glam")] -impl From for glam::Vec3 { - #[inline] - fn from(val: Scale3D) -> Self { - match val { - Scale3D::ThreeD(v) => v.into(), - Scale3D::Uniform(v) => Self::splat(v), - } - } -} diff --git a/crates/store/re_types/src/datatypes/transform3d.rs b/crates/store/re_types/src/datatypes/transform3d.rs deleted file mode 100644 index 219a8cc702a7..000000000000 --- a/crates/store/re_types/src/datatypes/transform3d.rs +++ /dev/null @@ -1,234 +0,0 @@ -// 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/datatypes/transform3d.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}; - -/// **Datatype**: Representation of a 3D affine transform. -/// -/// Rarely used directly, prefer using the underlying representation classes and pass them -/// directly to `Transform3D::child_from_parent` or `Transform3D::parent_from_child`. -#[derive(Clone, Debug, Copy, PartialEq)] -pub enum Transform3D { - /// Translation, rotation and scale, decomposed. - TranslationRotationScale(crate::datatypes::TranslationRotationScale3D), -} - -impl ::re_types_core::SizeBytes for Transform3D { - #[inline] - fn heap_size_bytes(&self) -> u64 { - #![allow(clippy::match_same_arms)] - match self { - Self::TranslationRotationScale(v) => v.heap_size_bytes(), - } - } - - #[inline] - fn is_pod() -> bool { - ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(Transform3D); - -impl ::re_types_core::Loggable for Transform3D { - type Name = ::re_types_core::DatatypeName; - - #[inline] - fn name() -> Self::Name { - "rerun.datatypes.Transform3D".into() - } - - #[inline] - fn arrow_datatype() -> arrow2::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow2::datatypes::*; - DataType::Union( - std::sync::Arc::new(vec![ - Field::new("_null_markers", DataType::Null, true), - Field::new( - "TranslationRotationScale", - ::arrow_datatype(), - false, - ), - ]), - Some(std::sync::Arc::new(vec![0i32, 1i32])), - UnionMode::Dense, - ) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult> - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow2::{array::*, datatypes::*}; - Ok({ - // Dense Arrow union - let data: Vec<_> = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - datum - }) - .collect(); - let types = data - .iter() - .map(|a| match a.as_deref() { - None => 0, - Some(Self::TranslationRotationScale(_)) => 1i8, - }) - .collect(); - let fields = vec![ - NullArray::new(DataType::Null, data.iter().filter(|v| v.is_none()).count()).boxed(), - { - let translation_rotation_scale: Vec<_> = data - .iter() - .filter_map(|datum| match datum.as_deref() { - Some(Self::TranslationRotationScale(v)) => Some(v.clone()), - _ => None, - }) - .collect(); - let translation_rotation_scale_bitmap: Option = None; - { - _ = translation_rotation_scale_bitmap; - crate::datatypes::TranslationRotationScale3D::to_arrow_opt( - translation_rotation_scale.into_iter().map(Some), - )? - } - }, - ]; - let offsets = Some({ - let mut translation_rotation_scale_offset = 0; - let mut nulls_offset = 0; - data.iter() - .map(|v| match v.as_deref() { - None => { - let offset = nulls_offset; - nulls_offset += 1; - offset - } - Some(Self::TranslationRotationScale(_)) => { - let offset = translation_rotation_scale_offset; - translation_rotation_scale_offset += 1; - offset - } - }) - .collect() - }); - UnionArray::new(Self::arrow_datatype(), types, fields, offsets).boxed() - }) - } - - fn from_arrow_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow2::{array::*, buffer::*, datatypes::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.datatypes.Transform3D")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_types, arrow_data_arrays) = - (arrow_data.types(), arrow_data.fields()); - let arrow_data_offsets = arrow_data - .offsets() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.datatypes.Transform3D")?; - if arrow_data_types.len() != arrow_data_offsets.len() { - return Err(DeserializationError::offset_slice_oob( - (0, arrow_data_types.len()), - arrow_data_offsets.len(), - )) - .with_context("rerun.datatypes.Transform3D"); - } - let translation_rotation_scale = { - if 1usize >= arrow_data_arrays.len() { - return Ok(Vec::new()); - } - let arrow_data = &*arrow_data_arrays[1usize]; - crate::datatypes::TranslationRotationScale3D::from_arrow_opt(arrow_data) - .with_context("rerun.datatypes.Transform3D#TranslationRotationScale")? - .into_iter() - .collect::>() - }; - arrow_data_types - .iter() - .enumerate() - .map(|(i, typ)| { - let offset = arrow_data_offsets[i]; - if *typ == 0 { - Ok(None) - } else { - Ok(Some(match typ { - 1i8 => Self::TranslationRotationScale({ - if offset as usize >= translation_rotation_scale.len() { - return Err(DeserializationError::offset_oob( - offset as _, - translation_rotation_scale.len(), - )) - .with_context( - "rerun.datatypes.Transform3D#TranslationRotationScale", - ); - } - - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - unsafe { - translation_rotation_scale.get_unchecked(offset as usize) - } - .clone() - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.datatypes.Transform3D#TranslationRotationScale", - )? - }), - _ => { - return Err(DeserializationError::missing_union_arm( - Self::arrow_datatype(), - "", - *typ as _, - )); - } - })) - } - }) - .collect::>>() - .with_context("rerun.datatypes.Transform3D")? - } - }) - } -} diff --git a/crates/store/re_types/src/datatypes/transform3d_ext.rs b/crates/store/re_types/src/datatypes/transform3d_ext.rs deleted file mode 100644 index cfa6e76c8ae3..000000000000 --- a/crates/store/re_types/src/datatypes/transform3d_ext.rs +++ /dev/null @@ -1,126 +0,0 @@ -use super::{Scale3D, Transform3D}; - -use crate::datatypes::{Rotation3D, RotationAxisAngle, TranslationRotationScale3D, Vec3D}; - -impl Transform3D { - /// The identity transform, representing no transform. - pub const IDENTITY: Self = Self::TranslationRotationScale(TranslationRotationScale3D::IDENTITY); - - /// From a translation. - #[inline] - pub fn from_translation(translation: impl Into) -> Self { - Self::from(TranslationRotationScale3D::from_translation(translation)) - } - - /// From a translation applied after a rotation, known as a rigid transformation. - #[inline] - pub fn from_translation_rotation( - translation: impl Into, - rotation: impl Into, - ) -> Self { - Self::from(TranslationRotationScale3D::from_translation_rotation( - translation, - rotation, - )) - } - - /// From a translation, applied after a rotation & scale, known as an affine transformation. - #[inline] - pub fn from_translation_rotation_scale( - translation: impl Into, - rotation: impl Into, - scale: impl Into, - ) -> Self { - Self::from(TranslationRotationScale3D::from_translation_rotation_scale( - translation, - rotation, - scale, - )) - } - - /// From a rotation & scale - #[inline] - pub fn from_rotation_scale(rotation: impl Into, scale: impl Into) -> Self { - Self::from(TranslationRotationScale3D::from_rotation_scale( - rotation, scale, - )) - } - - /// Indicate that this transform is from parent to child. - /// This is the oppositve of the default, which is from child to parent. - #[allow(clippy::wrong_self_convention)] - #[inline] - pub fn from_parent(mut self) -> Self { - match &mut self { - Self::TranslationRotationScale(t) => { - t.from_parent = true; - } - } - self - } - - /// Indicates whether this transform is from parent to child. - /// This is the oppositve of the default, which is from child to parent. - #[inline] - #[allow(clippy::wrong_self_convention)] - pub fn is_from_parent(&self) -> bool { - match self { - Self::TranslationRotationScale(t) => t.from_parent, - } - } -} - -impl Default for Transform3D { - #[inline] - fn default() -> Self { - Self::IDENTITY - } -} - -impl From for Transform3D { - #[inline] - fn from(v: TranslationRotationScale3D) -> Self { - Self::TranslationRotationScale(v) - } -} - -impl From for Transform3D { - #[inline] - fn from(v: Vec3D) -> Self { - Self::TranslationRotationScale(v.into()) - } -} - -#[cfg(feature = "glam")] -impl From for Transform3D { - #[inline] - fn from(v: glam::Vec3) -> Self { - Self::TranslationRotationScale(v.into()) - } -} - -impl From for Transform3D { - #[inline] - fn from(v: RotationAxisAngle) -> Self { - let rotation = Rotation3D::from(v); - Self::TranslationRotationScale(rotation.into()) - } -} - -#[cfg(feature = "glam")] -impl From for glam::Affine3A { - fn from(value: Transform3D) -> Self { - match value { - Transform3D::TranslationRotationScale(TranslationRotationScale3D { - translation, - rotation, - scale, - from_parent: _, - }) => Self::from_scale_rotation_translation( - scale.map_or(glam::Vec3::ONE, |s| s.into()), - rotation.map_or(glam::Quat::IDENTITY, |q| q.into()), - translation.map_or(glam::Vec3::ZERO, |v| v.into()), - ), - } - } -} diff --git a/crates/store/re_types/src/datatypes/translation_rotation_scale3d.rs b/crates/store/re_types/src/datatypes/translation_rotation_scale3d.rs deleted file mode 100644 index 3c221fefe22f..000000000000 --- a/crates/store/re_types/src/datatypes/translation_rotation_scale3d.rs +++ /dev/null @@ -1,411 +0,0 @@ -// 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/datatypes/translation_rotation_scale3d.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}; - -/// **Datatype**: Representation of an affine transform via separate translation, rotation & scale. -#[derive(Clone, Debug, Copy, PartialEq)] -pub struct TranslationRotationScale3D { - /// 3D translation vector, applied last. - pub translation: Option, - - /// 3D rotation, applied second. - pub rotation: Option, - - /// 3D scale, applied first. - pub scale: Option, - - /// If true, this transform is from the parent space to the space where the transform was logged. - /// - /// If false (default), the transform maps from this space to its parent, - /// i.e. the translation is the position in the parent space. - pub from_parent: bool, -} - -impl ::re_types_core::SizeBytes for TranslationRotationScale3D { - #[inline] - fn heap_size_bytes(&self) -> u64 { - self.translation.heap_size_bytes() - + self.rotation.heap_size_bytes() - + self.scale.heap_size_bytes() - + self.from_parent.heap_size_bytes() - } - - #[inline] - fn is_pod() -> bool { - >::is_pod() - && >::is_pod() - && >::is_pod() - && ::is_pod() - } -} - -::re_types_core::macros::impl_into_cow!(TranslationRotationScale3D); - -impl ::re_types_core::Loggable for TranslationRotationScale3D { - type Name = ::re_types_core::DatatypeName; - - #[inline] - fn name() -> Self::Name { - "rerun.datatypes.TranslationRotationScale3D".into() - } - - #[inline] - fn arrow_datatype() -> arrow2::datatypes::DataType { - #![allow(clippy::wildcard_imports)] - use arrow2::datatypes::*; - DataType::Struct(std::sync::Arc::new(vec![ - Field::new( - "translation", - ::arrow_datatype(), - true, - ), - Field::new( - "rotation", - ::arrow_datatype(), - true, - ), - Field::new("scale", ::arrow_datatype(), true), - Field::new("from_parent", DataType::Boolean, false), - ])) - } - - fn to_arrow_opt<'a>( - data: impl IntoIterator>>>, - ) -> SerializationResult> - where - Self: Clone + 'a, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow2::{array::*, datatypes::*}; - Ok({ - let (somes, data): (Vec<_>, Vec<_>) = data - .into_iter() - .map(|datum| { - let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); - (datum.is_some(), datum) - }) - .unzip(); - let bitmap: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - StructArray::new( - Self::arrow_datatype(), - vec![ - { - let (somes, translation): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum - .as_ref() - .map(|datum| datum.translation.clone()) - .flatten(); - (datum.is_some(), datum) - }) - .unzip(); - let translation_bitmap: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - { - use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let translation_inner_data: Vec<_> = translation - .into_iter() - .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) - .flatten() - .collect(); - let translation_inner_bitmap: Option = - translation_bitmap.as_ref().map(|bitmap| { - bitmap - .iter() - .map(|b| std::iter::repeat(b).take(3usize)) - .flatten() - .collect::>() - .into() - }); - FixedSizeListArray::new( - DataType::FixedSizeList( - std::sync::Arc::new(Field::new( - "item", - DataType::Float32, - false, - )), - 3usize, - ), - PrimitiveArray::new( - DataType::Float32, - translation_inner_data.into_iter().collect(), - translation_inner_bitmap, - ) - .boxed(), - translation_bitmap, - ) - .boxed() - } - }, - { - let (somes, rotation): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = - datum.as_ref().map(|datum| datum.rotation.clone()).flatten(); - (datum.is_some(), datum) - }) - .unzip(); - let rotation_bitmap: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - { - _ = rotation_bitmap; - crate::datatypes::Rotation3D::to_arrow_opt(rotation)? - } - }, - { - let (somes, scale): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = - datum.as_ref().map(|datum| datum.scale.clone()).flatten(); - (datum.is_some(), datum) - }) - .unzip(); - let scale_bitmap: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - { - _ = scale_bitmap; - crate::datatypes::Scale3D::to_arrow_opt(scale)? - } - }, - { - let (somes, from_parent): (Vec<_>, Vec<_>) = data - .iter() - .map(|datum| { - let datum = datum.as_ref().map(|datum| datum.from_parent.clone()); - (datum.is_some(), datum) - }) - .unzip(); - let from_parent_bitmap: Option = { - let any_nones = somes.iter().any(|some| !*some); - any_nones.then(|| somes.into()) - }; - BooleanArray::new( - DataType::Boolean, - from_parent - .into_iter() - .map(|v| v.unwrap_or_default()) - .collect(), - from_parent_bitmap, - ) - .boxed() - }, - ], - bitmap, - ) - .boxed() - }) - } - - fn from_arrow_opt( - arrow_data: &dyn arrow2::array::Array, - ) -> DeserializationResult>> - where - Self: Sized, - { - #![allow(clippy::wildcard_imports)] - use ::re_types_core::{Loggable as _, ResultExt as _}; - use arrow2::{array::*, buffer::*, datatypes::*}; - Ok({ - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = Self::arrow_datatype(); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.datatypes.TranslationRotationScale3D")?; - if arrow_data.is_empty() { - Vec::new() - } else { - let (arrow_data_fields, arrow_data_arrays) = - (arrow_data.fields(), arrow_data.values()); - let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data_fields - .iter() - .map(|field| field.name.as_str()) - .zip(arrow_data_arrays) - .collect(); - let translation = { - if !arrays_by_name.contains_key("translation") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "translation", - )) - .with_context("rerun.datatypes.TranslationRotationScale3D"); - } - let arrow_data = &**arrays_by_name["translation"]; - { - let arrow_data = arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::FixedSizeList( - std::sync::Arc::new(Field::new( - "item", - DataType::Float32, - false, - )), - 3usize, - ); - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context( - "rerun.datatypes.TranslationRotationScale3D#translation", - )?; - if arrow_data.is_empty() { - Vec::new() - } else { - let offsets = (0..) - .step_by(3usize) - .zip((3usize..).step_by(3usize).take(arrow_data.len())); - let arrow_data_inner = { - let arrow_data_inner = &**arrow_data.values(); - arrow_data_inner - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Float32; - let actual = arrow_data_inner.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context( - "rerun.datatypes.TranslationRotationScale3D#translation", - )? - .into_iter() - .map(|opt| opt.copied()) - .collect::>() - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - offsets, - arrow_data.validity(), - ) - .map(|elem| { - elem.map(|(start, end): (usize, usize)| { - debug_assert!(end - start == 3usize); - if end > arrow_data_inner.len() { - return Err(DeserializationError::offset_slice_oob( - (start, end), - arrow_data_inner.len(), - )); - } - - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let data = - unsafe { arrow_data_inner.get_unchecked(start..end) }; - let data = data.iter().cloned().map(Option::unwrap_or_default); - - // NOTE: Unwrapping cannot fail: the length must be correct. - #[allow(clippy::unwrap_used)] - Ok(array_init::from_iter(data).unwrap()) - }) - .transpose() - }) - .map(|res_or_opt| { - res_or_opt.map(|res_or_opt| res_or_opt.map(crate::datatypes::Vec3D)) - }) - .collect::>>>()? - } - .into_iter() - } - }; - let rotation = { - if !arrays_by_name.contains_key("rotation") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "rotation", - )) - .with_context("rerun.datatypes.TranslationRotationScale3D"); - } - let arrow_data = &**arrays_by_name["rotation"]; - crate::datatypes::Rotation3D::from_arrow_opt(arrow_data) - .with_context("rerun.datatypes.TranslationRotationScale3D#rotation")? - .into_iter() - }; - let scale = { - if !arrays_by_name.contains_key("scale") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "scale", - )) - .with_context("rerun.datatypes.TranslationRotationScale3D"); - } - let arrow_data = &**arrays_by_name["scale"]; - crate::datatypes::Scale3D::from_arrow_opt(arrow_data) - .with_context("rerun.datatypes.TranslationRotationScale3D#scale")? - .into_iter() - }; - let from_parent = { - if !arrays_by_name.contains_key("from_parent") { - return Err(DeserializationError::missing_struct_field( - Self::arrow_datatype(), - "from_parent", - )) - .with_context("rerun.datatypes.TranslationRotationScale3D"); - } - let arrow_data = &**arrays_by_name["from_parent"]; - arrow_data - .as_any() - .downcast_ref::() - .ok_or_else(|| { - let expected = DataType::Boolean; - let actual = arrow_data.data_type().clone(); - DeserializationError::datatype_mismatch(expected, actual) - }) - .with_context("rerun.datatypes.TranslationRotationScale3D#from_parent")? - .into_iter() - }; - arrow2::bitmap::utils::ZipValidity::new_with_validity( - ::itertools::izip!(translation, rotation, scale, from_parent), - arrow_data.validity(), - ) - .map(|opt| { - opt.map(|(translation, rotation, scale, from_parent)| { - Ok(Self { - translation, - rotation, - scale, - from_parent: from_parent - .ok_or_else(DeserializationError::missing_data) - .with_context( - "rerun.datatypes.TranslationRotationScale3D#from_parent", - )?, - }) - }) - .transpose() - }) - .collect::>>() - .with_context("rerun.datatypes.TranslationRotationScale3D")? - } - }) - } -} diff --git a/crates/store/re_types/src/datatypes/translation_rotation_scale3d_ext.rs b/crates/store/re_types/src/datatypes/translation_rotation_scale3d_ext.rs deleted file mode 100644 index 091acf343ef0..000000000000 --- a/crates/store/re_types/src/datatypes/translation_rotation_scale3d_ext.rs +++ /dev/null @@ -1,143 +0,0 @@ -use super::TranslationRotationScale3D; - -use crate::datatypes::{Rotation3D, Scale3D, Vec3D}; - -impl TranslationRotationScale3D { - /// The identity transform, representing no transform. - pub const IDENTITY: Self = Self { - translation: None, - rotation: None, - scale: None, - from_parent: false, - }; - - /// From a translation. - #[inline] - pub fn from_translation(translation: impl Into) -> Self { - Self { - translation: Some(translation.into()), - rotation: None, - scale: None, - from_parent: false, - } - } - - /// From a rotation - #[inline] - pub fn from_rotation(rotation: impl Into) -> Self { - Self { - translation: None, - rotation: Some(rotation.into()), - scale: None, - from_parent: false, - } - } - - /// From a rotation & scale - #[inline] - pub fn from_scale(scale: impl Into) -> Self { - Self { - translation: None, - rotation: None, - scale: Some(scale.into()), - from_parent: false, - } - } - - /// From a translation applied after a rotation, known as a rigid transformation. - #[inline] - pub fn from_translation_rotation( - translation: impl Into, - rotation: impl Into, - ) -> Self { - Self { - translation: Some(translation.into()), - rotation: Some(rotation.into()), - scale: None, - from_parent: false, - } - } - - /// From a rotation & scale - #[inline] - pub fn from_rotation_scale(rotation: impl Into, scale: impl Into) -> Self { - Self { - translation: None, - rotation: Some(rotation.into()), - scale: Some(scale.into()), - from_parent: false, - } - } - - /// From a translation, applied after a rotation & scale, known as an affine transformation. - #[inline] - pub fn from_translation_rotation_scale( - translation: impl Into, - rotation: impl Into, - scale: impl Into, - ) -> Self { - Self { - translation: Some(translation.into()), - rotation: Some(rotation.into()), - scale: Some(scale.into()), - from_parent: false, - } - } - - /// Indicate that this transform is from parent to child. - /// This is the opposite of the default, which is from child to parent. - #[allow(clippy::wrong_self_convention)] - #[inline] - pub fn from_parent(mut self) -> Self { - self.from_parent = true; - self - } -} - -impl Default for TranslationRotationScale3D { - #[inline] - fn default() -> Self { - Self::IDENTITY - } -} - -impl From for TranslationRotationScale3D { - #[inline] - fn from(v: Vec3D) -> Self { - Self { - translation: Some(v), - ..Default::default() - } - } -} - -#[cfg(feature = "glam")] -impl From for TranslationRotationScale3D { - #[inline] - fn from(v: glam::Vec3) -> Self { - Self { - translation: Some(v.into()), - ..Default::default() - } - } -} - -impl From for TranslationRotationScale3D { - #[inline] - fn from(v: Rotation3D) -> Self { - Self { - rotation: Some(v), - ..Default::default() - } - } -} - -impl From for TranslationRotationScale3D { - #[inline] - fn from(v: Scale3D) -> Self { - Self { - scale: Some(v), - ..Default::default() - } - } -} diff --git a/crates/top/rerun/src/sdk.rs b/crates/top/rerun/src/sdk.rs index fa335708472f..51ae286ce7f5 100644 --- a/crates/top/rerun/src/sdk.rs +++ b/crates/top/rerun/src/sdk.rs @@ -3,9 +3,7 @@ pub use re_sdk::*; /// Transform helpers, for use with [`components::Transform3D`]. pub mod transform { - pub use re_types::datatypes::{ - Angle, Rotation3D, RotationAxisAngle, Scale3D, Transform3D, TranslationRotationScale3D, - }; + pub use re_types::datatypes::{Angle, Quaternion, Rotation3D, RotationAxisAngle}; } /// Coordinate system helpers, for use with [`components::ViewCoordinates`]. @@ -32,8 +30,7 @@ mod prelude { }; pub use re_types::datatypes::{ Angle, AnnotationInfo, ClassDescription, Float32, KeypointPair, Mat3x3, Quaternion, Rgba32, - RotationAxisAngle, TensorBuffer, TensorData, TensorDimension, TranslationRotationScale3D, - Vec2D, Vec3D, Vec4D, + RotationAxisAngle, TensorBuffer, TensorData, TensorDimension, Vec2D, Vec3D, Vec4D, }; } pub use prelude::*; diff --git a/crates/viewer/re_data_ui/src/component_ui_registry.rs b/crates/viewer/re_data_ui/src/component_ui_registry.rs index 79a185606d3d..bf0ece80beea 100644 --- a/crates/viewer/re_data_ui/src/component_ui_registry.rs +++ b/crates/viewer/re_data_ui/src/component_ui_registry.rs @@ -21,7 +21,6 @@ pub fn create_component_ui_registry() -> ComponentUiRegistry { add_to_registry::(&mut registry); add_to_registry::(&mut registry); add_to_registry::(&mut registry); - add_to_registry::(&mut registry); add_to_registry::(&mut registry); add_to_registry::(&mut registry); diff --git a/crates/viewer/re_data_ui/src/lib.rs b/crates/viewer/re_data_ui/src/lib.rs index 71cb5790943a..8837e7040c7c 100644 --- a/crates/viewer/re_data_ui/src/lib.rs +++ b/crates/viewer/re_data_ui/src/lib.rs @@ -25,7 +25,6 @@ mod log_msg; mod pinhole; mod rotation3d; mod store_id; -mod transform3d; pub mod item_ui; diff --git a/crates/viewer/re_data_ui/src/transform3d.rs b/crates/viewer/re_data_ui/src/transform3d.rs deleted file mode 100644 index 65e89ca80d4a..000000000000 --- a/crates/viewer/re_data_ui/src/transform3d.rs +++ /dev/null @@ -1,136 +0,0 @@ -use re_types::datatypes::{Scale3D, Transform3D, TranslationRotationScale3D}; -use re_viewer_context::{UiLayout, ViewerContext}; - -use crate::DataUi; - -impl DataUi for re_types::components::Transform3D { - #[allow(clippy::only_used_in_recursion)] - fn data_ui( - &self, - ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - ui_layout: UiLayout, - query: &re_chunk_store::LatestAtQuery, - db: &re_entity_db::EntityDb, - ) { - match ui_layout { - UiLayout::List => { - // TODO(andreas): Preview some information instead of just a label with hover ui. - ui_layout.label(ui, "3D transform").on_hover_ui(|ui| { - self.data_ui(ctx, ui, UiLayout::Tooltip, query, db); - }); - } - - UiLayout::SelectionPanelFull - | UiLayout::SelectionPanelLimitHeight - | UiLayout::Tooltip => { - let from_parent = match &self.0 { - Transform3D::TranslationRotationScale(t) => t.from_parent, - }; - let dir_string = if from_parent { - "parent ➡ child" - } else { - "child ➡ parent" - }; - - ui.vertical(|ui| { - ui_layout.label(ui, "3D transform"); - ui.indent("transform_repr", |ui| { - ui_layout.label(ui, dir_string); - self.0.data_ui(ctx, ui, ui_layout, query, db); - }); - }); - } - } - } -} - -impl DataUi for Transform3D { - #[allow(clippy::only_used_in_recursion)] - fn data_ui( - &self, - ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - ui_layout: UiLayout, - query: &re_chunk_store::LatestAtQuery, - db: &re_entity_db::EntityDb, - ) { - match ui_layout { - UiLayout::List => { - ui.label("3D transform").on_hover_ui(|ui| { - self.data_ui(ctx, ui, UiLayout::SelectionPanelLimitHeight, query, db); - }); - } - - UiLayout::SelectionPanelFull - | UiLayout::SelectionPanelLimitHeight - | UiLayout::Tooltip => match self { - Self::TranslationRotationScale(translation_rotation_scale) => { - translation_rotation_scale.data_ui(ctx, ui, ui_layout, query, db); - } - }, - } - } -} - -impl DataUi for TranslationRotationScale3D { - fn data_ui( - &self, - ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - ui_layout: UiLayout, - query: &re_chunk_store::LatestAtQuery, - db: &re_entity_db::EntityDb, - ) { - let Self { - translation, - rotation, - scale, - from_parent: _, - } = self; - - egui::Grid::new("translation_rotation_scale") - .num_columns(2) - .show(ui, |ui| { - // Unlike Rotation/Scale, we don't have a value that indicates that nothing was logged. - // We still skip zero translations though since they are typically not logged explicitly. - if let Some(translation) = translation { - ui.label("translation"); - translation.data_ui(ctx, ui, ui_layout, query, db); - ui.end_row(); - } - - if let Some(rotation) = rotation { - ui.label("rotation"); - rotation.data_ui(ctx, ui, ui_layout, query, db); - ui.end_row(); - } - - if let Some(scale) = scale { - ui.label("scale"); - scale.data_ui(ctx, ui, ui_layout, query, db); - ui.end_row(); - } - }); - } -} - -impl DataUi for Scale3D { - fn data_ui( - &self, - ctx: &ViewerContext<'_>, - ui: &mut egui::Ui, - ui_layout: UiLayout, - query: &re_chunk_store::LatestAtQuery, - db: &re_entity_db::EntityDb, - ) { - match self { - Self::Uniform(scale) => { - ui.label(re_format::format_f32(*scale)); - } - Self::ThreeD(v) => { - v.data_ui(ctx, ui, ui_layout, query, db); - } - } - } -} diff --git a/crates/viewer/re_space_view_spatial/src/contexts/transform_context.rs b/crates/viewer/re_space_view_spatial/src/contexts/transform_context.rs index f202a828d7c6..c7d5f3610527 100644 --- a/crates/viewer/re_space_view_spatial/src/contexts/transform_context.rs +++ b/crates/viewer/re_space_view_spatial/src/contexts/transform_context.rs @@ -5,14 +5,13 @@ use re_chunk_store::LatestAtQuery; use re_entity_db::{EntityDb, EntityPath, EntityTree}; use re_space_view::DataResultQuery as _; use re_types::{ - archetypes::Pinhole, + archetypes::{LeafTransforms3D, Pinhole, Transform3D}, components::{ DisconnectedSpace, ImagePlaneDistance, LeafRotationAxisAngle, LeafRotationQuat, LeafScale3D, LeafTransformMat3x3, LeafTranslation3D, PinholeProjection, RotationAxisAngle, - RotationQuat, Scale3D, Transform3D, TransformMat3x3, TransformRelation, Translation3D, - ViewCoordinates, + RotationQuat, Scale3D, TransformMat3x3, TransformRelation, Translation3D, ViewCoordinates, }, - ComponentNameSet, Loggable as _, + Archetype, ComponentNameSet, Loggable as _, }; use re_viewer_context::{IdentifiedViewSystem, ViewContext, ViewContextSystem}; use vec1::smallvec_v1::SmallVec1; @@ -151,7 +150,8 @@ impl Default for TransformContext { impl ViewContextSystem for TransformContext { fn compatible_component_sets(&self) -> Vec { vec![ - std::iter::once(Transform3D::name()).collect(), + Transform3D::all_components().iter().copied().collect(), + LeafTransforms3D::all_components().iter().copied().collect(), std::iter::once(PinholeProjection::name()).collect(), std::iter::once(DisconnectedSpace::name()).collect(), ] diff --git a/crates/viewer/re_viewer/src/reflection/mod.rs b/crates/viewer/re_viewer/src/reflection/mod.rs index 7e3e463182fa..2335020c5e1f 100644 --- a/crates/viewer/re_viewer/src/reflection/mod.rs +++ b/crates/viewer/re_viewer/src/reflection/mod.rs @@ -615,13 +615,6 @@ fn generate_component_reflection() -> Result::name(), - ComponentReflection { - docstring_md: "An affine transform between two 3D spaces, represented in a given direction.", - placeholder: Some(Transform3D::default().to_arrow()?), - }, - ), ( ::name(), ComponentReflection { diff --git a/docs/content/reference/types/components.md b/docs/content/reference/types/components.md index 3a2e31e2e8b0..9f71ce060cef 100644 --- a/docs/content/reference/types/components.md +++ b/docs/content/reference/types/components.md @@ -67,7 +67,6 @@ on [Entities and Components](../../concepts/entity-component.md). * [`Texcoord2D`](components/texcoord2d.md): A 2D texture UV coordinate. * [`Text`](components/text.md): A string of text, e.g. for labels and text documents. * [`TextLogLevel`](components/text_log_level.md): The severity level of a text log message. -* [`Transform3D`](components/transform3d.md): An affine transform between two 3D spaces, represented in a given direction. * [`TransformMat3x3`](components/transform_mat3x3.md): A 3x3 transformation matrix Matrix. * [`TransformRelation`](components/transform_relation.md): Specifies relation a spatial transform describes. * [`Translation3D`](components/translation3d.md): A translation vector in 3D space. diff --git a/docs/content/reference/types/components/.gitattributes b/docs/content/reference/types/components/.gitattributes index b4fe052cf41f..10c069c6e3a8 100644 --- a/docs/content/reference/types/components/.gitattributes +++ b/docs/content/reference/types/components/.gitattributes @@ -55,7 +55,6 @@ tensor_width_dimension.md linguist-generated=true texcoord2d.md linguist-generated=true text.md linguist-generated=true text_log_level.md linguist-generated=true -transform3d.md linguist-generated=true transform_mat3x3.md linguist-generated=true transform_relation.md linguist-generated=true translation3d.md linguist-generated=true diff --git a/docs/content/reference/types/components/transform3d.md b/docs/content/reference/types/components/transform3d.md deleted file mode 100644 index 118d127a4581..000000000000 --- a/docs/content/reference/types/components/transform3d.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: "Transform3D" ---- - - -An affine transform between two 3D spaces, represented in a given direction. - -## Fields - -* repr: [`Transform3D`](../datatypes/transform3d.md) - -## API reference links - * 🌊 [C++ API docs for `Transform3D`](https://ref.rerun.io/docs/cpp/stable/structrerun_1_1components_1_1Transform3D.html) - * 🐍 [Python API docs for `Transform3D`](https://ref.rerun.io/docs/python/stable/common/components#rerun.components.Transform3D) - * 🦀 [Rust API docs for `Transform3D`](https://docs.rs/rerun/latest/rerun/components/struct.Transform3D.html) - - diff --git a/docs/content/reference/types/datatypes.md b/docs/content/reference/types/datatypes.md index 4920c78a37bb..8d71043e6da6 100644 --- a/docs/content/reference/types/datatypes.md +++ b/docs/content/reference/types/datatypes.md @@ -27,7 +27,6 @@ Data types are the lowest layer of the data model hierarchy. They are re-usable * [`Rgba32`](datatypes/rgba32.md): An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha. * [`Rotation3D`](datatypes/rotation3d.md): A 3D rotation. * [`RotationAxisAngle`](datatypes/rotation_axis_angle.md): 3D rotation represented by a rotation around a given axis. -* [`Scale3D`](datatypes/scale3d.md): 3D scaling factor, part of a transform representation. * [`TensorBuffer`](datatypes/tensor_buffer.md): The underlying storage for [`archetypes.Tensor`](https://rerun.io/docs/reference/types/archetypes/tensor). * [`TensorData`](datatypes/tensor_data.md): An N-dimensional array of numbers. * [`TensorDimension`](datatypes/tensor_dimension.md): A single dimension within a multi-dimensional tensor. @@ -36,8 +35,6 @@ Data types are the lowest layer of the data model hierarchy. They are re-usable * [`TimeInt`](datatypes/time_int.md): A 64-bit number describing either nanoseconds OR sequence numbers. * [`TimeRange`](datatypes/time_range.md): Visible time range bounds for a specific timeline. * [`TimeRangeBoundary`](datatypes/time_range_boundary.md): Left or right boundary of a time range. -* [`Transform3D`](datatypes/transform3d.md): Representation of a 3D affine transform. -* [`TranslationRotationScale3D`](datatypes/translation_rotation_scale3d.md): Representation of an affine transform via separate translation, rotation & scale. * [`UInt32`](datatypes/uint32.md): A 32bit unsigned integer. * [`UInt64`](datatypes/uint64.md): A 64bit unsigned integer. * [`UVec2D`](datatypes/uvec2d.md): A uint32 vector in 2D space. diff --git a/docs/content/reference/types/datatypes/.gitattributes b/docs/content/reference/types/datatypes/.gitattributes index ead9c945a227..9a90ab4573be 100644 --- a/docs/content/reference/types/datatypes/.gitattributes +++ b/docs/content/reference/types/datatypes/.gitattributes @@ -21,7 +21,6 @@ range2d.md linguist-generated=true rgba32.md linguist-generated=true rotation3d.md linguist-generated=true rotation_axis_angle.md linguist-generated=true -scale3d.md linguist-generated=true tensor_buffer.md linguist-generated=true tensor_data.md linguist-generated=true tensor_dimension.md linguist-generated=true @@ -30,8 +29,6 @@ tensor_dimension_selection.md linguist-generated=true time_int.md linguist-generated=true time_range.md linguist-generated=true time_range_boundary.md linguist-generated=true -transform3d.md linguist-generated=true -translation_rotation_scale3d.md linguist-generated=true uint32.md linguist-generated=true uint64.md linguist-generated=true utf8.md linguist-generated=true diff --git a/docs/content/reference/types/datatypes/rotation3d.md b/docs/content/reference/types/datatypes/rotation3d.md index 27c3b7d1f213..35f7ae71371a 100644 --- a/docs/content/reference/types/datatypes/rotation3d.md +++ b/docs/content/reference/types/datatypes/rotation3d.md @@ -19,4 +19,3 @@ A 3D rotation. ## Used by * [`Rotation3D`](../components/rotation3d.md) -* [`TranslationRotationScale3D`](../datatypes/translation_rotation_scale3d.md) diff --git a/docs/content/reference/types/datatypes/scale3d.md b/docs/content/reference/types/datatypes/scale3d.md deleted file mode 100644 index 3393077b896b..000000000000 --- a/docs/content/reference/types/datatypes/scale3d.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: "Scale3D" ---- - - -3D scaling factor, part of a transform representation. - -## Variants - -* ThreeD: [`Vec3D`](../datatypes/vec3d.md) -* Uniform: `f32` - -## API reference links - * 🌊 [C++ API docs for `Scale3D`](https://ref.rerun.io/docs/cpp/stable/structrerun_1_1datatypes_1_1Scale3D.html) - * 🐍 [Python API docs for `Scale3D`](https://ref.rerun.io/docs/python/stable/common/datatypes#rerun.datatypes.Scale3D) - * 🦀 [Rust API docs for `Scale3D`](https://docs.rs/rerun/latest/rerun/datatypes/enum.Scale3D.html) - - -## Used by - -* [`TranslationRotationScale3D`](../datatypes/translation_rotation_scale3d.md) diff --git a/docs/content/reference/types/datatypes/transform3d.md b/docs/content/reference/types/datatypes/transform3d.md deleted file mode 100644 index 443132c49da3..000000000000 --- a/docs/content/reference/types/datatypes/transform3d.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: "Transform3D" ---- - - -Representation of a 3D affine transform. - -## Variants - -* TranslationRotationScale: [`TranslationRotationScale3D`](../datatypes/translation_rotation_scale3d.md) - -## API reference links - * 🌊 [C++ API docs for `Transform3D`](https://ref.rerun.io/docs/cpp/stable/structrerun_1_1datatypes_1_1Transform3D.html) - * 🐍 [Python API docs for `Transform3D`](https://ref.rerun.io/docs/python/stable/common/datatypes#rerun.datatypes.Transform3D) - * 🦀 [Rust API docs for `Transform3D`](https://docs.rs/rerun/latest/rerun/datatypes/enum.Transform3D.html) - - -## Used by - -* [`Transform3D`](../components/transform3d.md) diff --git a/docs/content/reference/types/datatypes/translation_rotation_scale3d.md b/docs/content/reference/types/datatypes/translation_rotation_scale3d.md deleted file mode 100644 index 6dfae74e6d3e..000000000000 --- a/docs/content/reference/types/datatypes/translation_rotation_scale3d.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: "TranslationRotationScale3D" ---- - - -Representation of an affine transform via separate translation, rotation & scale. - -## Fields - -* translation: [`Vec3D`](../datatypes/vec3d.md) -* rotation: [`Rotation3D`](../datatypes/rotation3d.md) -* scale: [`Scale3D`](../datatypes/scale3d.md) -* from_parent: `bool` - -## API reference links - * 🌊 [C++ API docs for `TranslationRotationScale3D`](https://ref.rerun.io/docs/cpp/stable/structrerun_1_1datatypes_1_1TranslationRotationScale3D.html) - * 🐍 [Python API docs for `TranslationRotationScale3D`](https://ref.rerun.io/docs/python/stable/common/datatypes#rerun.datatypes.TranslationRotationScale3D) - * 🦀 [Rust API docs for `TranslationRotationScale3D`](https://docs.rs/rerun/latest/rerun/datatypes/struct.TranslationRotationScale3D.html) - - -## Used by - -* [`Transform3D`](../datatypes/transform3d.md) diff --git a/docs/content/reference/types/datatypes/vec3d.md b/docs/content/reference/types/datatypes/vec3d.md index 38a2abe96f46..d3ccedc488f1 100644 --- a/docs/content/reference/types/datatypes/vec3d.md +++ b/docs/content/reference/types/datatypes/vec3d.md @@ -24,7 +24,5 @@ A vector in 3D space. * [`Position3D`](../components/position3d.md) * [`RotationAxisAngle`](../datatypes/rotation_axis_angle.md) * [`Scale3D`](../components/scale3d.md?speculative-link) -* [`Scale3D`](../datatypes/scale3d.md) * [`Translation3D`](../components/translation3d.md?speculative-link) -* [`TranslationRotationScale3D`](../datatypes/translation_rotation_scale3d.md) * [`Vector3D`](../components/vector3d.md) diff --git a/rerun_cpp/src/rerun.hpp b/rerun_cpp/src/rerun.hpp index 5a82929634e9..f04d2e6aa932 100644 --- a/rerun_cpp/src/rerun.hpp +++ b/rerun_cpp/src/rerun.hpp @@ -57,11 +57,9 @@ namespace rerun { using datatypes::Quaternion; using datatypes::Rgba32; using datatypes::RotationAxisAngle; - using datatypes::Scale3D; using datatypes::TensorBuffer; using datatypes::TensorData; using datatypes::TensorDimension; - using datatypes::TranslationRotationScale3D; using datatypes::Vec2D; using datatypes::Vec3D; using datatypes::Vec4D; diff --git a/rerun_cpp/src/rerun/components.hpp b/rerun_cpp/src/rerun/components.hpp index a579c12e7828..0c64585e659e 100644 --- a/rerun_cpp/src/rerun/components.hpp +++ b/rerun_cpp/src/rerun/components.hpp @@ -56,7 +56,6 @@ #include "components/texcoord2d.hpp" #include "components/text.hpp" #include "components/text_log_level.hpp" -#include "components/transform3d.hpp" #include "components/transform_mat3x3.hpp" #include "components/transform_relation.hpp" #include "components/translation3d.hpp" diff --git a/rerun_cpp/src/rerun/components/.gitattributes b/rerun_cpp/src/rerun/components/.gitattributes index 943e213436a7..ba3e99b2d0c8 100644 --- a/rerun_cpp/src/rerun/components/.gitattributes +++ b/rerun_cpp/src/rerun/components/.gitattributes @@ -65,7 +65,6 @@ tensor_width_dimension.hpp linguist-generated=true texcoord2d.hpp linguist-generated=true text.hpp linguist-generated=true text_log_level.hpp linguist-generated=true -transform3d.hpp linguist-generated=true transform_mat3x3.hpp linguist-generated=true transform_relation.cpp linguist-generated=true transform_relation.hpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/components/transform3d.hpp b/rerun_cpp/src/rerun/components/transform3d.hpp deleted file mode 100644 index 1d1cbccf9a44..000000000000 --- a/rerun_cpp/src/rerun/components/transform3d.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// 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/components/transform3d.fbs". - -#pragma once - -#include "../datatypes/transform3d.hpp" -#include "../datatypes/translation_rotation_scale3d.hpp" -#include "../result.hpp" - -#include -#include - -namespace rerun::components { - /// **Component**: An affine transform between two 3D spaces, represented in a given direction. - struct Transform3D { - /// Representation of the transform. - rerun::datatypes::Transform3D repr; - - public: - Transform3D() = default; - - Transform3D(rerun::datatypes::Transform3D repr_) : repr(repr_) {} - - Transform3D& operator=(rerun::datatypes::Transform3D repr_) { - repr = repr_; - return *this; - } - - Transform3D(rerun::datatypes::TranslationRotationScale3D TranslationRotationScale_) - : repr(TranslationRotationScale_) {} - - Transform3D& operator=( - rerun::datatypes::TranslationRotationScale3D TranslationRotationScale_ - ) { - repr = TranslationRotationScale_; - return *this; - } - - /// Cast to the underlying Transform3D datatype - operator rerun::datatypes::Transform3D() const { - return repr; - } - }; -} // namespace rerun::components - -namespace rerun { - static_assert(sizeof(rerun::datatypes::Transform3D) == sizeof(components::Transform3D)); - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.components.Transform3D"; - - /// 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::components::Transform3D` into an arrow array. - static Result> to_arrow( - const components::Transform3D* instances, size_t num_instances - ) { - return Loggable::to_arrow( - &instances->repr, - num_instances - ); - } - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/datatypes.hpp b/rerun_cpp/src/rerun/datatypes.hpp index 72fd303d2a6b..d2ecad033d1e 100644 --- a/rerun_cpp/src/rerun/datatypes.hpp +++ b/rerun_cpp/src/rerun/datatypes.hpp @@ -22,7 +22,6 @@ #include "datatypes/rgba32.hpp" #include "datatypes/rotation3d.hpp" #include "datatypes/rotation_axis_angle.hpp" -#include "datatypes/scale3d.hpp" #include "datatypes/tensor_buffer.hpp" #include "datatypes/tensor_data.hpp" #include "datatypes/tensor_dimension.hpp" @@ -31,8 +30,6 @@ #include "datatypes/time_int.hpp" #include "datatypes/time_range.hpp" #include "datatypes/time_range_boundary.hpp" -#include "datatypes/transform3d.hpp" -#include "datatypes/translation_rotation_scale3d.hpp" #include "datatypes/uint32.hpp" #include "datatypes/uint64.hpp" #include "datatypes/utf8.hpp" diff --git a/rerun_cpp/src/rerun/datatypes/.gitattributes b/rerun_cpp/src/rerun/datatypes/.gitattributes index e3c319732145..f12b776cc9ce 100644 --- a/rerun_cpp/src/rerun/datatypes/.gitattributes +++ b/rerun_cpp/src/rerun/datatypes/.gitattributes @@ -41,8 +41,6 @@ rotation3d.cpp linguist-generated=true rotation3d.hpp linguist-generated=true rotation_axis_angle.cpp linguist-generated=true rotation_axis_angle.hpp linguist-generated=true -scale3d.cpp linguist-generated=true -scale3d.hpp linguist-generated=true tensor_buffer.cpp linguist-generated=true tensor_buffer.hpp linguist-generated=true tensor_data.cpp linguist-generated=true @@ -59,10 +57,6 @@ time_range.cpp linguist-generated=true time_range.hpp linguist-generated=true time_range_boundary.cpp linguist-generated=true time_range_boundary.hpp linguist-generated=true -transform3d.cpp linguist-generated=true -transform3d.hpp linguist-generated=true -translation_rotation_scale3d.cpp linguist-generated=true -translation_rotation_scale3d.hpp linguist-generated=true uint32.cpp linguist-generated=true uint32.hpp linguist-generated=true uint64.cpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/datatypes/scale3d.cpp b/rerun_cpp/src/rerun/datatypes/scale3d.cpp deleted file mode 100644 index e072a0c07485..000000000000 --- a/rerun_cpp/src/rerun/datatypes/scale3d.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// 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/datatypes/scale3d.fbs". - -#include "scale3d.hpp" - -#include "vec3d.hpp" - -#include -#include - -namespace rerun::datatypes {} - -namespace rerun { - const std::shared_ptr& Loggable::arrow_datatype() { - static const auto datatype = arrow::dense_union({ - arrow::field("_null_markers", arrow::null(), true, nullptr), - arrow::field("ThreeD", Loggable::arrow_datatype(), false), - arrow::field("Uniform", arrow::float32(), false), - }); - return datatype; - } - - Result> Loggable::to_arrow( - const datatypes::Scale3D* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK(Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - )); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::DenseUnionBuilder* builder, const datatypes::Scale3D* elements, size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - ARROW_RETURN_NOT_OK(builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - const auto& union_instance = elements[elem_idx]; - ARROW_RETURN_NOT_OK(builder->Append(static_cast(union_instance.get_union_tag())) - ); - - auto variant_index = static_cast(union_instance.get_union_tag()); - auto variant_builder_untyped = builder->child_builder(variant_index).get(); - - using TagType = datatypes::detail::Scale3DTag; - switch (union_instance.get_union_tag()) { - case TagType::None: { - ARROW_RETURN_NOT_OK(variant_builder_untyped->AppendNull()); - } break; - case TagType::ThreeD: { - auto variant_builder = - static_cast(variant_builder_untyped); - RR_RETURN_NOT_OK(Loggable::fill_arrow_array_builder( - variant_builder, - &union_instance.get_union_data().three_d, - 1 - )); - } break; - case TagType::Uniform: { - auto variant_builder = - static_cast(variant_builder_untyped); - ARROW_RETURN_NOT_OK( - variant_builder->Append(union_instance.get_union_data().uniform) - ); - } break; - } - } - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/datatypes/scale3d.hpp b/rerun_cpp/src/rerun/datatypes/scale3d.hpp deleted file mode 100644 index ce936cb46d3a..000000000000 --- a/rerun_cpp/src/rerun/datatypes/scale3d.hpp +++ /dev/null @@ -1,171 +0,0 @@ -// 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/datatypes/scale3d.fbs". - -#pragma once - -#include "../result.hpp" -#include "vec3d.hpp" - -#include -#include -#include -#include -#include - -namespace arrow { - class Array; - class DataType; - class DenseUnionBuilder; -} // namespace arrow - -namespace rerun::datatypes { - namespace detail { - /// \private - enum class Scale3DTag : uint8_t { - /// Having a special empty state makes it possible to implement move-semantics. We need to be able to leave the object in a state which we can run the destructor on. - None = 0, - ThreeD, - Uniform, - }; - - /// \private - union Scale3DData { - /// Individual scaling factors for each axis, distorting the original object. - rerun::datatypes::Vec3D three_d; - - /// Uniform scaling factor along all axis. - float uniform; - - Scale3DData() { - std::memset(reinterpret_cast(this), 0, sizeof(Scale3DData)); - } - - ~Scale3DData() {} - - void swap(Scale3DData& other) noexcept { - // This bitwise swap would fail for self-referential types, but we don't have any of those. - char temp[sizeof(Scale3DData)]; - void* otherbytes = reinterpret_cast(&other); - void* thisbytes = reinterpret_cast(this); - std::memcpy(temp, thisbytes, sizeof(Scale3DData)); - std::memcpy(thisbytes, otherbytes, sizeof(Scale3DData)); - std::memcpy(otherbytes, temp, sizeof(Scale3DData)); - } - }; - } // namespace detail - - /// **Datatype**: 3D scaling factor, part of a transform representation. - struct Scale3D { - Scale3D() : _tag(detail::Scale3DTag::None) {} - - /// Copy constructor - Scale3D(const Scale3D& other) : _tag(other._tag) { - const void* otherbytes = reinterpret_cast(&other._data); - void* thisbytes = reinterpret_cast(&this->_data); - std::memcpy(thisbytes, otherbytes, sizeof(detail::Scale3DData)); - } - - Scale3D& operator=(const Scale3D& other) noexcept { - Scale3D tmp(other); - this->swap(tmp); - return *this; - } - - Scale3D(Scale3D&& other) noexcept : Scale3D() { - this->swap(other); - } - - Scale3D& operator=(Scale3D&& other) noexcept { - this->swap(other); - return *this; - } - - void swap(Scale3D& other) noexcept { - std::swap(this->_tag, other._tag); - this->_data.swap(other._data); - } - - /// Individual scaling factors for each axis, distorting the original object. - Scale3D(rerun::datatypes::Vec3D three_d) : Scale3D() { - *this = Scale3D::three_d(std::move(three_d)); - } - - /// Uniform scaling factor along all axis. - Scale3D(float uniform) : Scale3D() { - *this = Scale3D::uniform(std::move(uniform)); - } - - /// Individual scaling factors for each axis, distorting the original object. - static Scale3D three_d(rerun::datatypes::Vec3D three_d) { - Scale3D self; - self._tag = detail::Scale3DTag::ThreeD; - new (&self._data.three_d) rerun::datatypes::Vec3D(std::move(three_d)); - return self; - } - - /// Uniform scaling factor along all axis. - static Scale3D uniform(float uniform) { - Scale3D self; - self._tag = detail::Scale3DTag::Uniform; - new (&self._data.uniform) float(std::move(uniform)); - return self; - } - - /// Return a pointer to three_d if the union is in that state, otherwise `nullptr`. - const rerun::datatypes::Vec3D* get_three_d() const { - if (_tag == detail::Scale3DTag::ThreeD) { - return &_data.three_d; - } else { - return nullptr; - } - } - - /// Return a pointer to uniform if the union is in that state, otherwise `nullptr`. - const float* get_uniform() const { - if (_tag == detail::Scale3DTag::Uniform) { - return &_data.uniform; - } else { - return nullptr; - } - } - - /// \private - const detail::Scale3DData& get_union_data() const { - return _data; - } - - /// \private - detail::Scale3DTag get_union_tag() const { - return _tag; - } - - private: - detail::Scale3DTag _tag; - detail::Scale3DData _data; - }; -} // namespace rerun::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.datatypes.Scale3D"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::datatypes::Scale3D` into an arrow array. - static Result> to_arrow( - const datatypes::Scale3D* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::DenseUnionBuilder* builder, const datatypes::Scale3D* elements, - size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/datatypes/transform3d.cpp b/rerun_cpp/src/rerun/datatypes/transform3d.cpp deleted file mode 100644 index d28eb081c07b..000000000000 --- a/rerun_cpp/src/rerun/datatypes/transform3d.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// 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/datatypes/transform3d.fbs". - -#include "transform3d.hpp" - -#include "translation_rotation_scale3d.hpp" - -#include -#include - -namespace rerun::datatypes {} - -namespace rerun { - const std::shared_ptr& Loggable::arrow_datatype() { - static const auto datatype = arrow::dense_union({ - arrow::field("_null_markers", arrow::null(), true, nullptr), - arrow::field( - "TranslationRotationScale", - Loggable::arrow_datatype(), - false - ), - }); - return datatype; - } - - Result> Loggable::to_arrow( - const datatypes::Transform3D* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK(Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - )); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::DenseUnionBuilder* builder, const datatypes::Transform3D* elements, - size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - ARROW_RETURN_NOT_OK(builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - const auto& union_instance = elements[elem_idx]; - ARROW_RETURN_NOT_OK(builder->Append(static_cast(union_instance.get_union_tag())) - ); - - auto variant_index = static_cast(union_instance.get_union_tag()); - auto variant_builder_untyped = builder->child_builder(variant_index).get(); - - using TagType = datatypes::detail::Transform3DTag; - switch (union_instance.get_union_tag()) { - case TagType::None: { - ARROW_RETURN_NOT_OK(variant_builder_untyped->AppendNull()); - } break; - case TagType::TranslationRotationScale: { - auto variant_builder = - static_cast(variant_builder_untyped); - RR_RETURN_NOT_OK( - Loggable:: - fill_arrow_array_builder( - variant_builder, - &union_instance.get_union_data().translation_rotation_scale, - 1 - ) - ); - } break; - } - } - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/datatypes/transform3d.hpp b/rerun_cpp/src/rerun/datatypes/transform3d.hpp deleted file mode 100644 index 346754b15c3a..000000000000 --- a/rerun_cpp/src/rerun/datatypes/transform3d.hpp +++ /dev/null @@ -1,149 +0,0 @@ -// 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/datatypes/transform3d.fbs". - -#pragma once - -#include "../result.hpp" -#include "translation_rotation_scale3d.hpp" - -#include -#include -#include -#include -#include - -namespace arrow { - class Array; - class DataType; - class DenseUnionBuilder; -} // namespace arrow - -namespace rerun::datatypes { - namespace detail { - /// \private - enum class Transform3DTag : uint8_t { - /// Having a special empty state makes it possible to implement move-semantics. We need to be able to leave the object in a state which we can run the destructor on. - None = 0, - TranslationRotationScale, - }; - - /// \private - union Transform3DData { - /// Translation, rotation and scale, decomposed. - rerun::datatypes::TranslationRotationScale3D translation_rotation_scale; - - Transform3DData() { - std::memset(reinterpret_cast(this), 0, sizeof(Transform3DData)); - } - - ~Transform3DData() {} - - void swap(Transform3DData& other) noexcept { - // This bitwise swap would fail for self-referential types, but we don't have any of those. - char temp[sizeof(Transform3DData)]; - void* otherbytes = reinterpret_cast(&other); - void* thisbytes = reinterpret_cast(this); - std::memcpy(temp, thisbytes, sizeof(Transform3DData)); - std::memcpy(thisbytes, otherbytes, sizeof(Transform3DData)); - std::memcpy(otherbytes, temp, sizeof(Transform3DData)); - } - }; - } // namespace detail - - /// **Datatype**: Representation of a 3D affine transform. - struct Transform3D { - Transform3D() : _tag(detail::Transform3DTag::None) {} - - /// Copy constructor - Transform3D(const Transform3D& other) : _tag(other._tag) { - const void* otherbytes = reinterpret_cast(&other._data); - void* thisbytes = reinterpret_cast(&this->_data); - std::memcpy(thisbytes, otherbytes, sizeof(detail::Transform3DData)); - } - - Transform3D& operator=(const Transform3D& other) noexcept { - Transform3D tmp(other); - this->swap(tmp); - return *this; - } - - Transform3D(Transform3D&& other) noexcept : Transform3D() { - this->swap(other); - } - - Transform3D& operator=(Transform3D&& other) noexcept { - this->swap(other); - return *this; - } - - void swap(Transform3D& other) noexcept { - std::swap(this->_tag, other._tag); - this->_data.swap(other._data); - } - - /// Translation, rotation and scale, decomposed. - Transform3D(rerun::datatypes::TranslationRotationScale3D translation_rotation_scale) - : Transform3D() { - *this = Transform3D::translation_rotation_scale(std::move(translation_rotation_scale)); - } - - /// Translation, rotation and scale, decomposed. - static Transform3D translation_rotation_scale( - rerun::datatypes::TranslationRotationScale3D translation_rotation_scale - ) { - Transform3D self; - self._tag = detail::Transform3DTag::TranslationRotationScale; - new (&self._data.translation_rotation_scale) - rerun::datatypes::TranslationRotationScale3D(std::move(translation_rotation_scale)); - return self; - } - - /// Return a pointer to translation_rotation_scale if the union is in that state, otherwise `nullptr`. - const rerun::datatypes::TranslationRotationScale3D* get_translation_rotation_scale() const { - if (_tag == detail::Transform3DTag::TranslationRotationScale) { - return &_data.translation_rotation_scale; - } else { - return nullptr; - } - } - - /// \private - const detail::Transform3DData& get_union_data() const { - return _data; - } - - /// \private - detail::Transform3DTag get_union_tag() const { - return _tag; - } - - private: - detail::Transform3DTag _tag; - detail::Transform3DData _data; - }; -} // namespace rerun::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.datatypes.Transform3D"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::datatypes::Transform3D` into an arrow array. - static Result> to_arrow( - const datatypes::Transform3D* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::DenseUnionBuilder* builder, const datatypes::Transform3D* elements, - size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d.cpp b/rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d.cpp deleted file mode 100644 index 060c2ec56aa8..000000000000 --- a/rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// 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/datatypes/translation_rotation_scale3d.fbs". - -#include "translation_rotation_scale3d.hpp" - -#include "rotation3d.hpp" -#include "scale3d.hpp" -#include "vec3d.hpp" - -#include -#include - -namespace rerun::datatypes {} - -namespace rerun { - const std::shared_ptr& - Loggable::arrow_datatype() { - static const auto datatype = arrow::struct_({ - arrow::field("translation", Loggable::arrow_datatype(), true), - arrow::field( - "rotation", - Loggable::arrow_datatype(), - true - ), - arrow::field("scale", Loggable::arrow_datatype(), true), - arrow::field("from_parent", arrow::boolean(), false), - }); - return datatype; - } - - Result> Loggable::to_arrow( - const datatypes::TranslationRotationScale3D* instances, size_t num_instances - ) { - // TODO(andreas): Allow configuring the memory pool. - arrow::MemoryPool* pool = arrow::default_memory_pool(); - auto datatype = arrow_datatype(); - - ARROW_ASSIGN_OR_RAISE(auto builder, arrow::MakeBuilder(datatype, pool)) - if (instances && num_instances > 0) { - RR_RETURN_NOT_OK( - Loggable::fill_arrow_array_builder( - static_cast(builder.get()), - instances, - num_instances - ) - ); - } - std::shared_ptr array; - ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return array; - } - - rerun::Error Loggable::fill_arrow_array_builder( - arrow::StructBuilder* builder, const datatypes::TranslationRotationScale3D* elements, - size_t num_elements - ) { - if (builder == nullptr) { - return rerun::Error(ErrorCode::UnexpectedNullArgument, "Passed array builder is null."); - } - if (elements == nullptr) { - return rerun::Error( - ErrorCode::UnexpectedNullArgument, - "Cannot serialize null pointer to arrow array." - ); - } - - { - auto field_builder = - static_cast(builder->field_builder(0)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - const auto& element = elements[elem_idx]; - if (element.translation.has_value()) { - RR_RETURN_NOT_OK(Loggable::fill_arrow_array_builder( - field_builder, - &element.translation.value(), - 1 - )); - } else { - ARROW_RETURN_NOT_OK(field_builder->AppendNull()); - } - } - } - { - auto field_builder = static_cast(builder->field_builder(1)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - const auto& element = elements[elem_idx]; - if (element.rotation.has_value()) { - RR_RETURN_NOT_OK( - Loggable::fill_arrow_array_builder( - field_builder, - &element.rotation.value(), - 1 - ) - ); - } else { - ARROW_RETURN_NOT_OK(field_builder->AppendNull()); - } - } - } - { - auto field_builder = static_cast(builder->field_builder(2)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - const auto& element = elements[elem_idx]; - if (element.scale.has_value()) { - RR_RETURN_NOT_OK(Loggable::fill_arrow_array_builder( - field_builder, - &element.scale.value(), - 1 - )); - } else { - ARROW_RETURN_NOT_OK(field_builder->AppendNull()); - } - } - } - { - auto field_builder = static_cast(builder->field_builder(3)); - ARROW_RETURN_NOT_OK(field_builder->Reserve(static_cast(num_elements))); - for (size_t elem_idx = 0; elem_idx < num_elements; elem_idx += 1) { - ARROW_RETURN_NOT_OK(field_builder->Append(elements[elem_idx].from_parent)); - } - } - ARROW_RETURN_NOT_OK(builder->AppendValues(static_cast(num_elements), nullptr)); - - return Error::ok(); - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d.hpp b/rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d.hpp deleted file mode 100644 index 99e6598b8f38..000000000000 --- a/rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d.hpp +++ /dev/null @@ -1,232 +0,0 @@ -// 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/datatypes/translation_rotation_scale3d.fbs". - -#pragma once - -#include "../compiler_utils.hpp" -#include "../rerun_sdk_export.hpp" -#include "../result.hpp" -#include "rotation3d.hpp" -#include "scale3d.hpp" -#include "vec3d.hpp" - -#include -#include -#include - -namespace arrow { - class Array; - class DataType; - class StructBuilder; -} // namespace arrow - -namespace rerun::datatypes { - /// **Datatype**: Representation of an affine transform via separate translation, rotation & scale. - struct TranslationRotationScale3D { - /// 3D translation vector, applied last. - std::optional translation; - - /// 3D rotation, applied second. - std::optional rotation; - - /// 3D scale, applied first. - std::optional scale; - - /// If true, this transform is from the parent space to the space where the transform was logged. - /// - /// If false (default), the transform maps from this space to its parent, - /// i.e. the translation is the position in the parent space. - bool from_parent; - - public: - // Extensions to generated type defined in 'translation_rotation_scale3d_ext.cpp' - - /// Identity transformation. - /// - /// Applying this transform does not alter an entity's transformation. - /// It has all optional fields set to `std::nullopt`. - RERUN_SDK_EXPORT static const TranslationRotationScale3D IDENTITY; - - // Need to disable the maybe-uninitialized here because the compiler gets confused by the combination - // of union-types datatypes inside of an optional component. - // - // See: https://github.com/rerun-io/rerun/issues/4027 - RERUN_DISABLE_MAYBE_UNINITIALIZED_PUSH - TranslationRotationScale3D(const TranslationRotationScale3D& other) - : translation(other.translation), - rotation(other.rotation), - scale(other.scale), - from_parent(other.from_parent) {} - - RR_DISABLE_MAYBE_UNINITIALIZED_POP - - /// Creates a new 3D transform from translation/rotation/scale. - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param scale_ \copydoc TranslationRotationScale3D::scale - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D( - const std::optional& translation_, const std::optional& rotation_, - const std::optional& scale_, bool from_parent_ = false - ) - : translation(translation_), - rotation(rotation_), - scale(scale_), - from_parent(from_parent_) {} - - /// Creates a new 3D transform from translation/rotation/uniform-scale. - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param uniform_scale Uniform scale factor that is applied to all axis equally. - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - /// - /// _Implementation note:_ This explicit overload prevents interpretation of the float as - /// bool, leading to a call to the wrong overload. - TranslationRotationScale3D( - const Vec3D& translation_, const Rotation3D& rotation_, float uniform_scale, - bool from_parent_ = false - ) - : translation(translation_), - rotation(rotation_), - scale(uniform_scale), - from_parent(from_parent_) {} - - /// Creates a new rigid transform (translation & rotation only). - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D( - const Vec3D& translation_, const Rotation3D& rotation_, bool from_parent_ = false - ) - : translation(translation_), - rotation(rotation_), - scale(std::nullopt), - from_parent(from_parent_) {} - - /// From translation & scale only. - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param scale_ \copydoc TranslationRotationScale3D::scale - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D( - const Vec3D& translation_, const Scale3D& scale_, bool from_parent_ = false - ) - : translation(translation_), - rotation(std::nullopt), - scale(scale_), - from_parent(from_parent_) {} - - /// From translation & uniform scale. - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param uniform_scale Uniform scale factor that is applied to all axis equally. - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - /// - /// _Implementation note:_ This explicit overload prevents interpretation of the float as - /// bool, leading to a call to the wrong overload. - TranslationRotationScale3D( - const Vec3D& translation_, float uniform_scale, bool from_parent_ = false - ) - : translation(translation_), - rotation(std::nullopt), - scale(uniform_scale), - from_parent(from_parent_) {} - - /// From rotation & scale only. - /// - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param scale_ \copydoc TranslationRotationScale3D::scale - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D( - const Rotation3D& rotation_, const Scale3D& scale_, bool from_parent_ = false - ) - : translation(std::nullopt), - rotation(rotation_), - scale(scale_), - from_parent(from_parent_) {} - - /// From rotation & uniform scale. - /// - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param uniform_scale Uniform scale factor that is applied to all axis equally. - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - /// - /// _Implementation note:_ This explicit overload prevents interpretation of the float as - /// bool, leading to a call to the wrong overload. - TranslationRotationScale3D( - const Rotation3D& rotation_, float uniform_scale, bool from_parent_ = false - ) - : translation(std::nullopt), - rotation(rotation_), - scale(uniform_scale), - from_parent(from_parent_) {} - - /// From translation only. - /// - /// \param translation_ 3D translation. - /// \param from_parent_ - TranslationRotationScale3D(const Vec3D& translation_, bool from_parent_ = false) - : translation(translation_), - rotation(std::nullopt), - scale(std::nullopt), - from_parent(from_parent_) {} - - /// From rotation only. - /// - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D(const Rotation3D& rotation_, bool from_parent_ = false) - : translation(std::nullopt), - rotation(rotation_), - scale(std::nullopt), - from_parent(from_parent_) {} - - /// From scale only. - /// - /// \param scale_ \copydoc TranslationRotationScale3D::scale - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D(const Scale3D& scale_, bool from_parent_ = false) - : translation(std::nullopt), - rotation(std::nullopt), - scale(scale_), - from_parent(from_parent_) {} - - /// TODO(#6831): temporary utility until from_parent is its own component - TranslationRotationScale3D(bool from_parent_) - : translation(std::nullopt), - rotation(std::nullopt), - scale(std::nullopt), - from_parent(from_parent_) {} - - public: - TranslationRotationScale3D() = default; - }; -} // namespace rerun::datatypes - -namespace rerun { - template - struct Loggable; - - /// \private - template <> - struct Loggable { - static constexpr const char Name[] = "rerun.datatypes.TranslationRotationScale3D"; - - /// Returns the arrow data type this type corresponds to. - static const std::shared_ptr& arrow_datatype(); - - /// Serializes an array of `rerun::datatypes::TranslationRotationScale3D` into an arrow array. - static Result> to_arrow( - const datatypes::TranslationRotationScale3D* instances, size_t num_instances - ); - - /// Fills an arrow array builder with an array of this type. - static rerun::Error fill_arrow_array_builder( - arrow::StructBuilder* builder, const datatypes::TranslationRotationScale3D* elements, - size_t num_elements - ); - }; -} // namespace rerun diff --git a/rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d_ext.cpp b/rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d_ext.cpp deleted file mode 100644 index a24178afb71b..000000000000 --- a/rerun_cpp/src/rerun/datatypes/translation_rotation_scale3d_ext.cpp +++ /dev/null @@ -1,184 +0,0 @@ -#include "translation_rotation_scale3d.hpp" - -// -#include "../compiler_utils.hpp" -#include "../rerun_sdk_export.hpp" - -// -namespace rerun { - namespace datatypes { - -#if 0 - // - - /// Identity transformation. - /// - /// Applying this transform does not alter an entity's transformation. - /// It has all optional fields set to `std::nullopt`. - RERUN_SDK_EXPORT static const TranslationRotationScale3D IDENTITY; - - // Need to disable the maybe-uninitialized here because the compiler gets confused by the combination - // of union-types datatypes inside of an optional component. - // - // See: https://github.com/rerun-io/rerun/issues/4027 - RERUN_DISABLE_MAYBE_UNINITIALIZED_PUSH - TranslationRotationScale3D(const TranslationRotationScale3D& other) - : translation(other.translation), - rotation(other.rotation), - scale(other.scale), - from_parent(other.from_parent) {} - - RR_DISABLE_MAYBE_UNINITIALIZED_POP - - /// Creates a new 3D transform from translation/rotation/scale. - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param scale_ \copydoc TranslationRotationScale3D::scale - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D( - const std::optional& translation_, - const std::optional& rotation_, const std::optional& scale_, - bool from_parent_ = false - ) - : translation(translation_), - rotation(rotation_), - scale(scale_), - from_parent(from_parent_) {} - - /// Creates a new 3D transform from translation/rotation/uniform-scale. - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param uniform_scale Uniform scale factor that is applied to all axis equally. - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - /// - /// _Implementation note:_ This explicit overload prevents interpretation of the float as - /// bool, leading to a call to the wrong overload. - TranslationRotationScale3D( - const Vec3D& translation_, const Rotation3D& rotation_, - float uniform_scale, bool from_parent_ = false - ) - : translation(translation_), - rotation(rotation_), - scale(uniform_scale), - from_parent(from_parent_) {} - - /// Creates a new rigid transform (translation & rotation only). - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D( - const Vec3D& translation_, const Rotation3D& rotation_, bool from_parent_ = false - ) - : translation(translation_), - rotation(rotation_), - scale(std::nullopt), - from_parent(from_parent_) {} - - /// From translation & scale only. - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param scale_ \copydoc TranslationRotationScale3D::scale - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D( - const Vec3D& translation_, const Scale3D& scale_, bool from_parent_ = false - ) - : translation(translation_), - rotation(std::nullopt), - scale(scale_), - from_parent(from_parent_) {} - - /// From translation & uniform scale. - /// - /// \param translation_ \copydoc TranslationRotationScale3D::translation - /// \param uniform_scale Uniform scale factor that is applied to all axis equally. - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - /// - /// _Implementation note:_ This explicit overload prevents interpretation of the float as - /// bool, leading to a call to the wrong overload. - TranslationRotationScale3D( - const Vec3D& translation_, float uniform_scale, bool from_parent_ = false - ) - : translation(translation_), - rotation(std::nullopt), - scale(uniform_scale), - from_parent(from_parent_) {} - - /// From rotation & scale only. - /// - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param scale_ \copydoc TranslationRotationScale3D::scale - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D( - const Rotation3D& rotation_, const Scale3D& scale_, bool from_parent_ = false - ) - : translation(std::nullopt), - rotation(rotation_), - scale(scale_), - from_parent(from_parent_) {} - - /// From rotation & uniform scale. - /// - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param uniform_scale Uniform scale factor that is applied to all axis equally. - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - /// - /// _Implementation note:_ This explicit overload prevents interpretation of the float as - /// bool, leading to a call to the wrong overload. - TranslationRotationScale3D( - const Rotation3D& rotation_, float uniform_scale, bool from_parent_ = false - ) - : translation(std::nullopt), - rotation(rotation_), - scale(uniform_scale), - from_parent(from_parent_) {} - - /// From translation only. - /// - /// \param translation_ 3D translation. - /// \param from_parent_ - TranslationRotationScale3D(const Vec3D& translation_, bool from_parent_ = false) - : translation(translation_), - rotation(std::nullopt), - scale(std::nullopt), - from_parent(from_parent_) {} - - /// From rotation only. - /// - /// \param rotation_ \copydoc TranslationRotationScale3D::rotation - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D(const Rotation3D& rotation_, bool from_parent_ = false) - : translation(std::nullopt), - rotation(rotation_), - scale(std::nullopt), - from_parent(from_parent_) {} - - - /// From scale only. - /// - /// \param scale_ \copydoc TranslationRotationScale3D::scale - /// \param from_parent_ \copydoc TranslationRotationScale3D::from_parent - TranslationRotationScale3D(const Scale3D& scale_, bool from_parent_ = false) - : translation(std::nullopt), - rotation(std::nullopt), - scale(scale_), - from_parent(from_parent_) {} - - /// TODO(#6831): temporary utility until from_parent is its own component - TranslationRotationScale3D(bool from_parent_) - : translation(std::nullopt), - rotation(std::nullopt), - scale(std::nullopt), - from_parent(from_parent_) {} - - // - }; -#endif - - const TranslationRotationScale3D TranslationRotationScale3D::IDENTITY = - TranslationRotationScale3D(); - - } // namespace datatypes -} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/components/.gitattributes b/rerun_py/rerun_sdk/rerun/components/.gitattributes index 5240df29aa9e..3f8ea3345cff 100644 --- a/rerun_py/rerun_sdk/rerun/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/components/.gitattributes @@ -56,7 +56,6 @@ tensor_width_dimension.py linguist-generated=true texcoord2d.py linguist-generated=true text.py linguist-generated=true text_log_level.py linguist-generated=true -transform3d.py linguist-generated=true transform_mat3x3.py linguist-generated=true transform_relation.py linguist-generated=true translation3d.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/components/__init__.py b/rerun_py/rerun_sdk/rerun/components/__init__.py index 1f1a7da35b77..8be7f50f4330 100644 --- a/rerun_py/rerun_sdk/rerun/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/components/__init__.py @@ -84,7 +84,6 @@ from .texcoord2d import Texcoord2D, Texcoord2DBatch, Texcoord2DType from .text import Text, TextBatch, TextType from .text_log_level import TextLogLevel, TextLogLevelBatch, TextLogLevelType -from .transform3d import Transform3D, Transform3DBatch, Transform3DType from .transform_mat3x3 import TransformMat3x3, TransformMat3x3Batch, TransformMat3x3Type from .transform_relation import ( TransformRelation, @@ -282,9 +281,6 @@ "TextLogLevelBatch", "TextLogLevelType", "TextType", - "Transform3D", - "Transform3DBatch", - "Transform3DType", "TransformMat3x3", "TransformMat3x3Batch", "TransformMat3x3Type", diff --git a/rerun_py/rerun_sdk/rerun/components/transform3d.py b/rerun_py/rerun_sdk/rerun/components/transform3d.py deleted file mode 100644 index c89a94bbff5b..000000000000 --- a/rerun_py/rerun_sdk/rerun/components/transform3d.py +++ /dev/null @@ -1,36 +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/components/transform3d.fbs". - -# You can extend this class by creating a "Transform3DExt" class in "transform3d_ext.py". - -from __future__ import annotations - -from .. import datatypes -from .._baseclasses import ( - ComponentBatchMixin, - ComponentMixin, -) - -__all__ = ["Transform3D", "Transform3DBatch", "Transform3DType"] - - -class Transform3D(datatypes.Transform3D, ComponentMixin): - """**Component**: An affine transform between two 3D spaces, represented in a given direction.""" - - _BATCH_TYPE = None - # You can define your own __init__ function as a member of Transform3DExt in transform3d_ext.py - - # Note: there are no fields here because Transform3D delegates to datatypes.Transform3D - pass - - -class Transform3DType(datatypes.Transform3DType): - _TYPE_NAME: str = "rerun.components.Transform3D" - - -class Transform3DBatch(datatypes.Transform3DBatch, ComponentBatchMixin): - _ARROW_TYPE = Transform3DType() - - -# This is patched in late to avoid circular dependencies. -Transform3D._BATCH_TYPE = Transform3DBatch # type: ignore[assignment] diff --git a/rerun_py/rerun_sdk/rerun/datatypes/.gitattributes b/rerun_py/rerun_sdk/rerun/datatypes/.gitattributes index 72b435b565f7..bdd5988dc0b5 100644 --- a/rerun_py/rerun_sdk/rerun/datatypes/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/datatypes/.gitattributes @@ -22,7 +22,6 @@ range2d.py linguist-generated=true rgba32.py linguist-generated=true rotation3d.py linguist-generated=true rotation_axis_angle.py linguist-generated=true -scale3d.py linguist-generated=true tensor_buffer.py linguist-generated=true tensor_data.py linguist-generated=true tensor_dimension.py linguist-generated=true @@ -31,8 +30,6 @@ tensor_dimension_selection.py linguist-generated=true time_int.py linguist-generated=true time_range.py linguist-generated=true time_range_boundary.py linguist-generated=true -transform3d.py linguist-generated=true -translation_rotation_scale3d.py linguist-generated=true uint32.py linguist-generated=true uint64.py linguist-generated=true utf8.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/datatypes/__init__.py index cc68c54b0d66..7c06b956b601 100644 --- a/rerun_py/rerun_sdk/rerun/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/datatypes/__init__.py @@ -46,7 +46,6 @@ RotationAxisAngleLike, RotationAxisAngleType, ) -from .scale3d import Scale3D, Scale3DArrayLike, Scale3DBatch, Scale3DLike, Scale3DType from .tensor_buffer import TensorBuffer, TensorBufferArrayLike, TensorBufferBatch, TensorBufferLike, TensorBufferType from .tensor_data import TensorData, TensorDataArrayLike, TensorDataBatch, TensorDataLike, TensorDataType from .tensor_dimension import ( @@ -79,14 +78,6 @@ TimeRangeBoundaryLike, TimeRangeBoundaryType, ) -from .transform3d import Transform3D, Transform3DArrayLike, Transform3DBatch, Transform3DLike, Transform3DType -from .translation_rotation_scale3d import ( - TranslationRotationScale3D, - TranslationRotationScale3DArrayLike, - TranslationRotationScale3DBatch, - TranslationRotationScale3DLike, - TranslationRotationScale3DType, -) from .uint32 import UInt32, UInt32ArrayLike, UInt32Batch, UInt32Like, UInt32Type from .uint64 import UInt64, UInt64ArrayLike, UInt64Batch, UInt64Like, UInt64Type from .utf8 import Utf8, Utf8ArrayLike, Utf8Batch, Utf8Like, Utf8Type @@ -213,11 +204,6 @@ "RotationAxisAngleBatch", "RotationAxisAngleLike", "RotationAxisAngleType", - "Scale3D", - "Scale3DArrayLike", - "Scale3DBatch", - "Scale3DLike", - "Scale3DType", "TensorBuffer", "TensorBufferArrayLike", "TensorBufferBatch", @@ -258,16 +244,6 @@ "TimeRangeBoundaryType", "TimeRangeLike", "TimeRangeType", - "Transform3D", - "Transform3DArrayLike", - "Transform3DBatch", - "Transform3DLike", - "Transform3DType", - "TranslationRotationScale3D", - "TranslationRotationScale3DArrayLike", - "TranslationRotationScale3DBatch", - "TranslationRotationScale3DLike", - "TranslationRotationScale3DType", "UInt32", "UInt32ArrayLike", "UInt32Batch", diff --git a/rerun_py/rerun_sdk/rerun/datatypes/scale3d.py b/rerun_py/rerun_sdk/rerun/datatypes/scale3d.py deleted file mode 100644 index 66f6b177f119..000000000000 --- a/rerun_py/rerun_sdk/rerun/datatypes/scale3d.py +++ /dev/null @@ -1,145 +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/datatypes/scale3d.fbs". - -# You can extend this class by creating a "Scale3DExt" class in "scale3d_ext.py". - -from __future__ import annotations - -from typing import TYPE_CHECKING, Any, Sequence, Union - -import pyarrow as pa -from attrs import define, field - -from .. import datatypes -from .._baseclasses import ( - BaseBatch, - BaseExtensionType, -) -from .scale3d_ext import Scale3DExt - -__all__ = ["Scale3D", "Scale3DArrayLike", "Scale3DBatch", "Scale3DLike", "Scale3DType"] - - -@define -class Scale3D(Scale3DExt): - """ - **Datatype**: 3D scaling factor, part of a transform representation. - - Example - ------- - ```python - # uniform scaling - scale = rr.datatypes.Scale3D(3.) - - # non-uniform scaling - scale = rr.datatypes.Scale3D([1, 1, -1]) - scale = rr.datatypes.Scale3D(rr.datatypes.Vec3D([1, 1, -1])) - ``` - - """ - - # You can define your own __init__ function as a member of Scale3DExt in scale3d_ext.py - - inner: Union[datatypes.Vec3D, float] = field( - converter=Scale3DExt.inner__field_converter_override # type: ignore[misc] - ) - """ - Must be one of: - - * ThreeD (datatypes.Vec3D): - Individual scaling factors for each axis, distorting the original object. - - * Uniform (float): - Uniform scaling factor along all axis. - """ - - -if TYPE_CHECKING: - Scale3DLike = Union[Scale3D, datatypes.Vec3D, float, datatypes.Vec3DLike] - Scale3DArrayLike = Union[ - Scale3D, - datatypes.Vec3D, - float, - Sequence[Scale3DLike], - ] -else: - Scale3DLike = Any - Scale3DArrayLike = Any - - -class Scale3DType(BaseExtensionType): - _TYPE_NAME: str = "rerun.datatypes.Scale3D" - - def __init__(self) -> None: - pa.ExtensionType.__init__( - self, - pa.dense_union([ - pa.field("_null_markers", pa.null(), nullable=True, metadata={}), - pa.field( - "ThreeD", - pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 3), - nullable=False, - metadata={}, - ), - pa.field("Uniform", pa.float32(), nullable=False, metadata={}), - ]), - self._TYPE_NAME, - ) - - -class Scale3DBatch(BaseBatch[Scale3DArrayLike]): - _ARROW_TYPE = Scale3DType() - - @staticmethod - def _native_to_pa_array(data: Scale3DArrayLike, data_type: pa.DataType) -> pa.Array: - from typing import cast - - from rerun.datatypes import Vec3DBatch - - # TODO(#2623): There should be a separate overridable `coerce_to_array` method that can be overridden. - # If we can call iter, it may be that one of the variants implements __iter__. - if not hasattr(data, "__iter__") or isinstance(data, (Scale3D, datatypes.Vec3D, float)): # type: ignore[arg-type] - data = [data] # type: ignore[list-item] - data = cast(Sequence[Scale3DLike], data) # type: ignore[redundant-cast] - - types: list[int] = [] - value_offsets: list[int] = [] - - num_nulls = 0 - variant_three_d: list[datatypes.Vec3D] = [] - variant_uniform: list[float] = [] - - for value in data: - if value is None: - value_offsets.append(num_nulls) - num_nulls += 1 - types.append(0) - else: - if not isinstance(value, Scale3D): - value = Scale3D(value) - if isinstance(value.inner, datatypes.Vec3D): - value_offsets.append(len(variant_three_d)) - variant_three_d.append(value.inner) - types.append(1) - elif isinstance(value.inner, float): - value_offsets.append(len(variant_uniform)) - variant_uniform.append(value.inner) - types.append(2) - - buffers = [ - None, - pa.array(types, type=pa.int8()).buffers()[1], - pa.array(value_offsets, type=pa.int32()).buffers()[1], - ] - children = [ - pa.nulls(num_nulls), - Vec3DBatch(variant_three_d).as_arrow_array().storage, - pa.array(variant_uniform, type=pa.float32()), - ] - - return pa.UnionArray.from_buffers( - type=data_type, - length=len(data), - buffers=buffers, - children=children, - ) diff --git a/rerun_py/rerun_sdk/rerun/datatypes/scale3d_ext.py b/rerun_py/rerun_sdk/rerun/datatypes/scale3d_ext.py deleted file mode 100644 index 1245017ecf6f..000000000000 --- a/rerun_py/rerun_sdk/rerun/datatypes/scale3d_ext.py +++ /dev/null @@ -1,26 +0,0 @@ -from __future__ import annotations - -from fractions import Fraction -from typing import TYPE_CHECKING - -import numpy as np - -if TYPE_CHECKING: - from . import Scale3DLike, Vec3D - - -class Scale3DExt: - """Extension for [Scale3D][rerun.datatypes.Scale3D].""" - - @staticmethod - def inner__field_converter_override(data: Scale3DLike) -> Vec3D | float: - from . import Scale3D, Vec3D - - if isinstance(data, Vec3D): - return data - elif isinstance(data, Scale3D): - return data.inner - elif isinstance(data, (float, int, Fraction)): - return float(data) - else: - return Vec3D(np.array(data)) diff --git a/rerun_py/rerun_sdk/rerun/datatypes/transform3d.py b/rerun_py/rerun_sdk/rerun/datatypes/transform3d.py deleted file mode 100644 index a9ec65a80276..000000000000 --- a/rerun_py/rerun_sdk/rerun/datatypes/transform3d.py +++ /dev/null @@ -1,128 +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/datatypes/transform3d.fbs". - -# You can extend this class by creating a "Transform3DExt" class in "transform3d_ext.py". - -from __future__ import annotations - -from typing import TYPE_CHECKING, Any, Sequence, Union - -import pyarrow as pa -from attrs import define, field - -from .. import datatypes -from .._baseclasses import ( - BaseBatch, - BaseExtensionType, -) -from .transform3d_ext import Transform3DExt - -__all__ = ["Transform3D", "Transform3DArrayLike", "Transform3DBatch", "Transform3DLike", "Transform3DType"] - - -@define -class Transform3D(Transform3DExt): - """**Datatype**: Representation of a 3D affine transform.""" - - # You can define your own __init__ function as a member of Transform3DExt in transform3d_ext.py - - inner: datatypes.TranslationRotationScale3D = field() - """ - Must be one of: - - * TranslationRotationScale (datatypes.TranslationRotationScale3D): - Translation, rotation and scale, decomposed. - """ - - -if TYPE_CHECKING: - Transform3DLike = Union[ - Transform3D, - datatypes.TranslationRotationScale3D, - ] - Transform3DArrayLike = Union[ - Transform3D, - datatypes.TranslationRotationScale3D, - Sequence[Transform3DLike], - ] -else: - Transform3DLike = Any - Transform3DArrayLike = Any - - -class Transform3DType(BaseExtensionType): - _TYPE_NAME: str = "rerun.datatypes.Transform3D" - - def __init__(self) -> None: - pa.ExtensionType.__init__( - self, - pa.dense_union([ - pa.field("_null_markers", pa.null(), nullable=True, metadata={}), - pa.field( - "TranslationRotationScale", - pa.struct([ - pa.field( - "translation", - pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 3), - nullable=True, - metadata={}, - ), - pa.field( - "rotation", - pa.dense_union([ - pa.field("_null_markers", pa.null(), nullable=True, metadata={}), - pa.field( - "Quaternion", - pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 4), - nullable=False, - metadata={}, - ), - pa.field( - "AxisAngle", - pa.struct([ - pa.field( - "axis", - pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 3), - nullable=False, - metadata={}, - ), - pa.field("angle", pa.float32(), nullable=False, metadata={}), - ]), - nullable=False, - metadata={}, - ), - ]), - nullable=True, - metadata={}, - ), - pa.field( - "scale", - pa.dense_union([ - pa.field("_null_markers", pa.null(), nullable=True, metadata={}), - pa.field( - "ThreeD", - pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 3), - nullable=False, - metadata={}, - ), - pa.field("Uniform", pa.float32(), nullable=False, metadata={}), - ]), - nullable=True, - metadata={}, - ), - pa.field("from_parent", pa.bool_(), nullable=False, metadata={}), - ]), - nullable=False, - metadata={}, - ), - ]), - self._TYPE_NAME, - ) - - -class Transform3DBatch(BaseBatch[Transform3DArrayLike]): - _ARROW_TYPE = Transform3DType() - - @staticmethod - def _native_to_pa_array(data: Transform3DArrayLike, data_type: pa.DataType) -> pa.Array: - return Transform3DExt.native_to_pa_array_override(data, data_type) diff --git a/rerun_py/rerun_sdk/rerun/datatypes/transform3d_ext.py b/rerun_py/rerun_sdk/rerun/datatypes/transform3d_ext.py deleted file mode 100644 index 691e2f34e377..000000000000 --- a/rerun_py/rerun_sdk/rerun/datatypes/transform3d_ext.py +++ /dev/null @@ -1,135 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING, cast - -import numpy as np -import pyarrow as pa - -from .._unions import build_dense_union, union_discriminant_type - -if TYPE_CHECKING: - from . import ( - Mat3x3, - Rotation3D, - Scale3D, - Transform3DArrayLike, - TranslationRotationScale3D, - Vec3D, - ) - - -class Transform3DExt: - """Extension for [Transform3D][rerun.datatypes.Transform3D].""" - - @staticmethod - def native_to_pa_array_override(data: Transform3DArrayLike, data_type: pa.DataType) -> pa.Array: - from ..datatypes import Transform3DBatch - from . import Transform3D, TranslationRotationScale3D - - if isinstance(data, Transform3DBatch): - return data.pa_array.storage - - if isinstance(data, Transform3D): - data = data.inner - - if isinstance(data, TranslationRotationScale3D): - discriminant = "TranslationRotationScale" - repr_type = union_discriminant_type(data_type, discriminant) - transform_repr = _build_struct_array_from_translation_rotation_scale(data, cast(pa.StructType, repr_type)) - else: - raise ValueError( - f"unknown transform 3D value: {data} (expected `Transform3D` or " "`TranslationRotationScale3D`" - ) - - storage = build_dense_union(data_type, discriminant, transform_repr) - - # TODO(clement) enable extension type wrapper - # return cast(Transform3DArray, pa.ExtensionArray.from_storage(Transform3DType(), storage)) - return storage - - def num_instances(self) -> int: - # Always a mono-component - return 1 - - -# TODO(#2623): lots of boilerplate here that could be auto-generated -# To address that: -# 1) rewrite everything in the form of `xxx__native_to_pa_array_override()` -# 2) higher level `xxx__native_to_pa_array_override()` should call into lower level `xxx::__init__()` -# 3) identify regularities and auto-gen them - - -def _build_union_array_from_scale(scale: Scale3D | None, type_: pa.DenseUnionType) -> pa.Array: - from . import Vec3D - - if scale is None: - scale_discriminant = "_null_markers" - scale_pa_arr = pa.nulls(1, pa.null()) - return build_dense_union(type_, scale_discriminant, scale_pa_arr) - - scale_arm = scale.inner - - if np.isscalar(scale_arm): - scale_discriminant = "Uniform" - scale_pa_arr = pa.array([scale_arm], type=pa.float32()) - else: - scale_discriminant = "ThreeD" - scale_pa_arr = pa.FixedSizeListArray.from_arrays( - cast(Vec3D, scale_arm).xyz, type=union_discriminant_type(type_, scale_discriminant) - ) - - return build_dense_union(type_, scale_discriminant, scale_pa_arr) - - -def _optional_mat3x3_to_arrow(mat: Mat3x3 | None) -> pa.Array: - from . import Mat3x3Batch, Mat3x3Type - - if mat is None: - return pa.nulls(1, Mat3x3Type().storage_type) - else: - try: - return Mat3x3Batch(mat, strict=True).as_arrow_array().storage - except ValueError as err: - raise ValueError(f"mat3x3 must be compatible with Mat3x3: {err}") - - -def _optional_translation_to_arrow(translation: Vec3D | None) -> pa.array: - from . import Vec3DBatch, Vec3DType - - if translation is None: - return pa.nulls(1, Vec3DType().storage_type) - else: - try: - return Vec3DBatch(translation.xyz, strict=True).as_arrow_array().storage - except ValueError as err: - raise ValueError(f"translation must be compatible with Vec3D: {err}") - - -def _optional_rotation_to_arrow(rotation: Rotation3D | None, storage_type: pa.DataType) -> pa.Array: - from . import Rotation3DBatch - - if rotation is None: - return pa.nulls(1, storage_type) - else: - try: - return Rotation3DBatch(rotation, strict=True).as_arrow_array().storage - except ValueError as err: - raise ValueError(f"rotation must be compatible with Rotation3D: {err}") - - -def _build_struct_array_from_translation_rotation_scale( - transform: TranslationRotationScale3D, type_: pa.StructType -) -> pa.StructArray: - translation = _optional_translation_to_arrow(transform.translation) - rotation = _optional_rotation_to_arrow(transform.rotation, type_["rotation"].type) - scale = _build_union_array_from_scale(transform.scale, type_["scale"].type) - - return pa.StructArray.from_arrays( - [ - translation, - rotation, - scale, - pa.array([transform.from_parent], type=pa.bool_()), - ], - fields=list(type_), - ) diff --git a/rerun_py/rerun_sdk/rerun/datatypes/translation_rotation_scale3d.py b/rerun_py/rerun_sdk/rerun/datatypes/translation_rotation_scale3d.py deleted file mode 100644 index 6cad3d4baeb6..000000000000 --- a/rerun_py/rerun_sdk/rerun/datatypes/translation_rotation_scale3d.py +++ /dev/null @@ -1,176 +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/datatypes/translation_rotation_scale3d.fbs". - -# You can extend this class by creating a "TranslationRotationScale3DExt" class in "translation_rotation_scale3d_ext.py". - -from __future__ import annotations - -from typing import Sequence, Union - -import numpy as np -import pyarrow as pa -from attrs import define, field - -from .. import datatypes -from .._baseclasses import ( - BaseBatch, - BaseExtensionType, -) -from .translation_rotation_scale3d_ext import TranslationRotationScale3DExt - -__all__ = [ - "TranslationRotationScale3D", - "TranslationRotationScale3DArrayLike", - "TranslationRotationScale3DBatch", - "TranslationRotationScale3DLike", - "TranslationRotationScale3DType", -] - - -def _translation_rotation_scale3d__rotation__special_field_converter_override( - x: datatypes.Rotation3DLike | None, -) -> datatypes.Rotation3D | None: - if x is None: - return None - elif isinstance(x, datatypes.Rotation3D): - return x - else: - return datatypes.Rotation3D(x) - - -def _translation_rotation_scale3d__scale__special_field_converter_override( - x: datatypes.Scale3DLike | None, -) -> datatypes.Scale3D | None: - if x is None: - return None - elif isinstance(x, datatypes.Scale3D): - return x - else: - return datatypes.Scale3D(x) - - -@define(init=False) -class TranslationRotationScale3D(TranslationRotationScale3DExt): - """**Datatype**: Representation of an affine transform via separate translation, rotation & scale.""" - - # __init__ can be found in translation_rotation_scale3d_ext.py - - from_parent: bool = field(converter=bool) - # If true, this transform is from the parent space to the space where the transform was logged. - # - # If false (default), the transform maps from this space to its parent, - # i.e. the translation is the position in the parent space. - # - # (Docstring intentionally commented out to hide this field from the docs) - - translation: datatypes.Vec3D | None = field( - default=None, - converter=TranslationRotationScale3DExt.translation__field_converter_override, # type: ignore[misc] - ) - # 3D translation vector, applied last. - # - # (Docstring intentionally commented out to hide this field from the docs) - - rotation: datatypes.Rotation3D | None = field( - default=None, converter=_translation_rotation_scale3d__rotation__special_field_converter_override - ) - # 3D rotation, applied second. - # - # (Docstring intentionally commented out to hide this field from the docs) - - scale: datatypes.Scale3D | None = field( - default=None, converter=_translation_rotation_scale3d__scale__special_field_converter_override - ) - # 3D scale, applied first. - # - # (Docstring intentionally commented out to hide this field from the docs) - - -TranslationRotationScale3DLike = TranslationRotationScale3D -TranslationRotationScale3DArrayLike = Union[ - TranslationRotationScale3D, - Sequence[TranslationRotationScale3DLike], -] - - -class TranslationRotationScale3DType(BaseExtensionType): - _TYPE_NAME: str = "rerun.datatypes.TranslationRotationScale3D" - - def __init__(self) -> None: - pa.ExtensionType.__init__( - self, - pa.struct([ - pa.field( - "translation", - pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 3), - nullable=True, - metadata={}, - ), - pa.field( - "rotation", - pa.dense_union([ - pa.field("_null_markers", pa.null(), nullable=True, metadata={}), - pa.field( - "Quaternion", - pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 4), - nullable=False, - metadata={}, - ), - pa.field( - "AxisAngle", - pa.struct([ - pa.field( - "axis", - pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 3), - nullable=False, - metadata={}, - ), - pa.field("angle", pa.float32(), nullable=False, metadata={}), - ]), - nullable=False, - metadata={}, - ), - ]), - nullable=True, - metadata={}, - ), - pa.field( - "scale", - pa.dense_union([ - pa.field("_null_markers", pa.null(), nullable=True, metadata={}), - pa.field( - "ThreeD", - pa.list_(pa.field("item", pa.float32(), nullable=False, metadata={}), 3), - nullable=False, - metadata={}, - ), - pa.field("Uniform", pa.float32(), nullable=False, metadata={}), - ]), - nullable=True, - metadata={}, - ), - pa.field("from_parent", pa.bool_(), nullable=False, metadata={}), - ]), - self._TYPE_NAME, - ) - - -class TranslationRotationScale3DBatch(BaseBatch[TranslationRotationScale3DArrayLike]): - _ARROW_TYPE = TranslationRotationScale3DType() - - @staticmethod - def _native_to_pa_array(data: TranslationRotationScale3DArrayLike, data_type: pa.DataType) -> pa.Array: - from rerun.datatypes import Rotation3DBatch, Scale3DBatch, Vec3DBatch - - if isinstance(data, TranslationRotationScale3D): - data = [data] - - return pa.StructArray.from_arrays( - [ - Vec3DBatch([x.translation for x in data]).as_arrow_array().storage, # type: ignore[misc, arg-type] - Rotation3DBatch([x.rotation for x in data]).as_arrow_array().storage, # type: ignore[misc, arg-type] - Scale3DBatch([x.scale for x in data]).as_arrow_array().storage, # type: ignore[misc, arg-type] - pa.array(np.asarray([x.from_parent for x in data], dtype=np.bool_)), - ], - fields=list(data_type), - ) diff --git a/rerun_py/rerun_sdk/rerun/datatypes/translation_rotation_scale3d_ext.py b/rerun_py/rerun_sdk/rerun/datatypes/translation_rotation_scale3d_ext.py deleted file mode 100644 index a230a44302c6..000000000000 --- a/rerun_py/rerun_sdk/rerun/datatypes/translation_rotation_scale3d_ext.py +++ /dev/null @@ -1,32 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING, Any - -if TYPE_CHECKING: - from . import Rotation3DLike, Scale3DLike, Vec3D, Vec3DLike - - -class TranslationRotationScale3DExt: - """Extension for [TranslationRotationScale3D][rerun.datatypes.TranslationRotationScale3D].""" - - # TODO(#2641): this is needed until we support default value for params - def __init__( - self: Any, - translation: Vec3DLike | None = None, - rotation: Rotation3DLike | None = None, - scale: Scale3DLike | None = None, - *, - from_parent: bool = False, - ) -> None: - self.__attrs_init__( # pyright: ignore[reportGeneralTypeIssues] - translation=translation, rotation=rotation, scale=scale, from_parent=from_parent - ) - - @staticmethod - def translation__field_converter_override(data: Vec3DLike | None) -> Vec3D | None: - if data is None: - return None - else: - from . import Vec3D - - return Vec3D(data) diff --git a/rerun_py/tests/unit/test_transform3d.py b/rerun_py/tests/unit/test_transform3d.py index 2fcab0ab7668..f7f12a08d285 100644 --- a/rerun_py/tests/unit/test_transform3d.py +++ b/rerun_py/tests/unit/test_transform3d.py @@ -13,7 +13,6 @@ Quaternion, Rotation3D, RotationAxisAngle, - Scale3D, Vec3D, ) @@ -30,17 +29,6 @@ *VEC_3D_INPUT, ] - -def assert_correct_scale3d(scale: Scale3D | None) -> None: - assert scale is not None - if isinstance(scale.inner, float): - assert scale.inner == 4.0 - elif isinstance(scale.inner, Vec3D): - assert_correct_vec3d(scale.inner) - else: - assert False, "Unexpected inner type" - - ROTATION_3D_INPUT = [ # Quaternion [1, 2, 3, 4], From e1245bd168bfec29f59b47676880b4c038132333 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Fri, 26 Jul 2024 10:25:25 +0200 Subject: [PATCH 2/4] py-fmt --- rerun_py/tests/unit/test_transform3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rerun_py/tests/unit/test_transform3d.py b/rerun_py/tests/unit/test_transform3d.py index f7f12a08d285..8d82f4d0a3b9 100644 --- a/rerun_py/tests/unit/test_transform3d.py +++ b/rerun_py/tests/unit/test_transform3d.py @@ -18,7 +18,7 @@ from .common_arrays import none_empty_or_value from .test_matnxn import MAT_3X3_INPUT -from .test_vecnd import VEC_3D_INPUT, assert_correct_vec3d +from .test_vecnd import VEC_3D_INPUT SCALE_3D_INPUT = [ # Uniform From fa7bd29b3544b08450f01828f707f99e121c07d4 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Fri, 26 Jul 2024 10:39:49 +0200 Subject: [PATCH 3/4] fix python doc generation --- rerun_py/docs/gen_common_index.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rerun_py/docs/gen_common_index.py b/rerun_py/docs/gen_common_index.py index 73edd33519ca..427bbd2bfca7 100755 --- a/rerun_py/docs/gen_common_index.py +++ b/rerun_py/docs/gen_common_index.py @@ -211,10 +211,9 @@ class Section: "archetypes.Transform3D", "archetypes.LeafTransforms3D", "archetypes.ViewCoordinates", + "components.Scale3D", "datatypes.Quaternion", "datatypes.RotationAxisAngle", - "datatypes.Scale3D", - "datatypes.TranslationRotationScale3D", ], gen_page=False, ), From ab121bb6deb747dbe9919eef19e5a97ecc3afa9a Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Fri, 26 Jul 2024 10:40:48 +0200 Subject: [PATCH 4/4] rust doc fix --- crates/top/rerun/src/sdk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/top/rerun/src/sdk.rs b/crates/top/rerun/src/sdk.rs index 51ae286ce7f5..c783f866e879 100644 --- a/crates/top/rerun/src/sdk.rs +++ b/crates/top/rerun/src/sdk.rs @@ -1,7 +1,7 @@ // NOTE: Have a look at `re_sdk/src/lib.rs` for an accurate listing of all these symbols. pub use re_sdk::*; -/// Transform helpers, for use with [`components::Transform3D`]. +/// Transform helpers, for use with [`archetypes::Transform3D`]. pub mod transform { pub use re_types::datatypes::{Angle, Quaternion, Rotation3D, RotationAxisAngle}; }