Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use LeafTranslation (centers), LeafRotationQuat and LeafRotationAxisAngle directly on Boxes3D/Ellipsoids3D #7029

Merged
merged 8 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions crates/store/re_types/definitions/rerun/archetypes/boxes3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace rerun.archetypes;

/// 3D boxes with half-extents and optional center, rotations, colors etc.
///
/// Note that orienting and placing the box is handled via `[archetypes.LeafTransforms3D]`.
/// Some of its component are repeated here for convenience.
///
/// \example archetypes/box3d_simple !api title="Simple 3D boxes" image="https://static.rerun.io/box3d_simple/d6a3f38d2e3360fbacac52bb43e44762635be9c8/1200w.png"
/// \example archetypes/box3d_batch title="Batch of 3D boxes" image="https://static.rerun.io/box3d_batch/6d3e453c3a0201ae42bbae9de941198513535f1d/1200w.png"
table Boxes3D (
Expand All @@ -21,13 +24,25 @@ table Boxes3D (
// --- Recommended ---

/// Optional center positions of the boxes.
centers: [rerun.components.Position3D] ("attr.rerun.component_recommended", nullable, order: 2000);
///
/// If not specified, the centers will be at (0, 0, 0).
/// Note that this uses a [components.LeafTranslation3D] which is also used by [archetypes.LeafTransforms3D].
centers: [rerun.components.LeafTranslation3D] ("attr.rerun.component_recommended", nullable, order: 2000);

/// Optional rotations of the boxes.
rotations: [rerun.components.Rotation3D] ("attr.rerun.component_recommended", nullable, order: 2100);
/// Rotations via axis + angle.
///
/// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
/// Note that this uses a [components.LeafRotationAxisAngle] which is also used by [archetypes.LeafTransforms3D].
rotation_axis_angles: [rerun.components.LeafRotationAxisAngle] ("attr.rerun.component_optional", nullable, order: 2100);

/// Rotations via quaternion.
///
/// If no rotation is specified, the axes of the boxes align with the axes of the local coordinate system.
/// Note that this uses a [components.LeafRotationQuat] which is also used by [archetypes.LeafTransforms3D].
quaternions: [rerun.components.LeafRotationQuat] ("attr.rerun.component_optional", nullable, order: 2200);

/// Optional colors for the boxes.
colors: [rerun.components.Color] ("attr.rerun.component_recommended", nullable, order: 2200);
colors: [rerun.components.Color] ("attr.rerun.component_recommended", nullable, order: 2300);

// --- Optional ---

Expand Down
22 changes: 15 additions & 7 deletions crates/store/re_types/definitions/rerun/archetypes/ellipsoids.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace rerun.archetypes;
/// (e.g. a bounding sphere).
/// For points whose radii are for the sake of visualization, use `Points3D` instead.
///
/// Currently, ellipsoids are always rendered as wireframes.
/// Opaque and transparent rendering will be supported later.
/// Note that orienting and placing the ellipsoids/spheres is handled via `[archetypes.LeafTransforms3D]`.
/// Some of its component are repeated here for convenience.
///
/// \example archetypes/ellipsoid_batch !api title="Batch of ellipsoids"
table Ellipsoids (
Expand All @@ -32,15 +32,23 @@ table Ellipsoids (
/// Optional center positions of the ellipsoids.
///
/// If not specified, the centers will be at (0, 0, 0).
centers: [rerun.components.Position3D] ("attr.rerun.component_recommended", nullable, order: 2000);
/// Note that this uses a [components.LeafTranslation3D] which is also used by [archetypes.LeafTransforms3D].
centers: [rerun.components.LeafTranslation3D] ("attr.rerun.component_recommended", nullable, order: 2000);

/// Optional rotations of the ellipsoids.
/// Rotations via axis + angle.
///
/// If not specified, the axes of the ellipsoid align with the axes of the coordinate system.
rotations: [rerun.components.Rotation3D] ("attr.rerun.component_recommended", nullable, order: 2100);
/// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
/// Note that this uses a [components.LeafRotationAxisAngle] which is also used by [archetypes.LeafTransforms3D].
rotation_axis_angles: [rerun.components.LeafRotationAxisAngle] ("attr.rerun.component_optional", nullable, order: 2100);

/// Rotations via quaternion.
///
/// If no rotation is specified, the axes of the ellipsoid align with the axes of the local coordinate system.
/// Note that this uses a [components.LeafRotationQuat] which is also used by [archetypes.LeafTransforms3D].
quaternions: [rerun.components.LeafRotationQuat] ("attr.rerun.component_optional", nullable, order: 2200);

/// Optional colors for the ellipsoids.
colors: [rerun.components.Color] ("attr.rerun.component_recommended", nullable, order: 2200);
colors: [rerun.components.Color] ("attr.rerun.component_recommended", nullable, order: 2300);

// --- Optional ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace rerun.archetypes;
/// If both [archetypes.LeafTransforms3D] and [archetypes.Transform3D] are present,
/// first the tree propagating [archetypes.Transform3D] is applied, then [archetypes.LeafTransforms3D].
///
/// Currently, most visualizers support only a single leaf transform per entity.
/// Currently, many visualizers support only a single leaf transform per entity.
/// Check archetype documentations for details - if not otherwise specified, only the first leaf transform is applied.
///
/// From the point of view of the entity's coordinate system,
Expand Down
142 changes: 101 additions & 41 deletions crates/store/re_types/src/archetypes/boxes3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions crates/store/re_types/src/archetypes/boxes3d_ext.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
components::{HalfSize3D, Position3D},
components::{HalfSize3D, LeafTranslation3D},
datatypes::Vec3D,
};

Expand All @@ -15,7 +15,7 @@ impl Boxes3D {
/// Creates new [`Boxes3D`] with [`Self::centers`] and [`Self::half_sizes`].
#[inline]
pub fn from_centers_and_half_sizes(
centers: impl IntoIterator<Item = impl Into<Position3D>>,
centers: impl IntoIterator<Item = impl Into<LeafTranslation3D>>,
half_sizes: impl IntoIterator<Item = impl Into<HalfSize3D>>,
) -> Self {
Self::new(half_sizes).with_centers(centers)
Expand All @@ -37,7 +37,7 @@ impl Boxes3D {
/// TODO(#3285): Does *not* preserve data as-is and instead creates half-sizes from the input data.
#[inline]
pub fn from_centers_and_sizes(
centers: impl IntoIterator<Item = impl Into<Position3D>>,
centers: impl IntoIterator<Item = impl Into<LeafTranslation3D>>,
sizes: impl IntoIterator<Item = impl Into<Vec3D>>,
) -> Self {
Self::from_sizes(sizes).with_centers(centers)
Expand All @@ -56,7 +56,7 @@ impl Boxes3D {
.zip(boxes.half_sizes.iter())
.map(|(min, half_size)| {
let min = min.into();
Position3D::new(
LeafTranslation3D::new(
min.x() + half_size.x(),
min.y() + half_size.y(),
min.z() + half_size.z(),
Expand Down
Loading
Loading