Skip to content

Commit

Permalink
Add Scale3D component (#6892)
Browse files Browse the repository at this point in the history
### What

* Part of #6831
* Based on #6866

Introduces a new `Scale3D` component that lives directly on the
`Transform3D` archetype.
The `Scale3D` _datatype_ which is part of `TranslationRotationScale3D`
is still around, but will be removed in a subsequent PR.

Additionally, reversed order of how transform components. Rationale:
"translation, rotation, scale" is a common way of expressing a simple
transform. What is meant is that we first scale an object, then rotate
it and _then_ translate it.

Commit by commit review possible.

### Checklist
* [x] pass `main` ci
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6892?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6892?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/6892)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
Wumpf authored Jul 16, 2024
1 parent 7b57919 commit 369f97c
Show file tree
Hide file tree
Showing 49 changed files with 1,168 additions and 537 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ function(rerun_strict_warning_settings target)
# CMAKE_COMPILE_WARNING_AS_ERROR is only directly supported starting in CMake `3.24`
# https://cmake.org/cmake/help/latest/prop_tgt/COMPILE_WARNING_AS_ERROR.html
if(CMAKE_COMPILE_WARNING_AS_ERROR)
target_compile_options(${target} PRIVATE /WX)
target_compile_options(${target} PRIVATE /WX
/w15038 # Initialization order. https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038
)
endif()

if(RERUN_USE_ASAN)
Expand Down
16 changes: 10 additions & 6 deletions crates/store/re_types/definitions/rerun/archetypes/transform3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace rerun.archetypes;

/// A transform between two 3D spaces, i.e. a pose.
///
/// All components are applied in the order they are listed here.
/// All components are applied in the inverse order they are listed here.
/// E.g. if both a 4x4 matrix with a translation and a translation vector are present,
/// the matrix is applied first, then the translation vector on top.
/// the translation is applied first, followed by the matrix.
///
/// Each transform component can be listed multiple times, but transform tree propagation is only possible
/// if there's only one instance for each transform component.
Expand All @@ -21,18 +21,22 @@ namespace rerun.archetypes;
// TODO(#6831): provide example with out of tree transform.
table Transform3D (
"attr.rust.derive": "Default, PartialEq",
"attr.rust.generate_field_info",
"attr.docs.category": "Spatial 3D",
"attr.docs.view_types": "Spatial3DView, Spatial2DView: if logged above active projection"
) {
/// The transform
// TODO(#6831): remove.
transform: rerun.components.Transform3D ("attr.rerun.component_optional", order: 1000);

/// 3x3 transformation matrices.
mat3x3: [rerun.components.TransformMat3x3] ("attr.rerun.component_optional", nullable, order: 1100);

/// Translation vectors.
translation: [rerun.components.Translation3D] ("attr.rerun.component_optional", nullable, order: 1200);
translation: [rerun.components.Translation3D] ("attr.rerun.component_optional", nullable, order: 1100);

/// Scaling factor.
scale: [rerun.components.Scale3D] ("attr.rerun.component_optional", nullable, order: 1200);

/// 3x3 transformation matrices.
mat3x3: [rerun.components.TransformMat3x3] ("attr.rerun.component_optional", nullable, order: 1300);

// --- visual representation

Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/components.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ include "./components/range1d.fbs";
include "./components/resolution.fbs";
include "./components/rotation3d.fbs";
include "./components/scalar.fbs";
include "./components/scale3d.fbs";
include "./components/stroke_width.fbs";
include "./components/tensor_data.fbs";
include "./components/tensor_dimension_selection.fbs";
Expand Down
14 changes: 14 additions & 0 deletions crates/store/re_types/definitions/rerun/components/scale3d.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace rerun.components;

/// A 3D scale factor.
///
/// A scale of 1.0 means no scaling.
/// A scale of 2.0 means doubling the size.
/// Each component scales along the corresponding axis.
struct Scale3D (
"attr.docs.unreleased",
"attr.rust.derive": "Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
scale: rerun.datatypes.Vec3D (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace rerun.datatypes;
struct Mat3x3 (
"attr.arrow.transparent",
"attr.python.aliases": "npt.ArrayLike",
"attr.python.array_aliases": "npt.ArrayLike",
"attr.rust.derive": "Copy, PartialEq, PartialOrd, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct"
Expand Down
104 changes: 70 additions & 34 deletions crates/store/re_types/src/archetypes/transform3d.rs

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

14 changes: 8 additions & 6 deletions crates/store/re_types/src/archetypes/transform3d_ext.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
components::{TransformMat3x3, Translation3D},
datatypes::{Rotation3D, Scale3D, TranslationRotationScale3D},
components::{Scale3D, TransformMat3x3, Translation3D},
datatypes::{Rotation3D, TranslationRotationScale3D},
};

use super::Transform3D;
Expand Down Expand Up @@ -37,7 +37,7 @@ impl Transform3D {
#[inline]
pub fn from_scale(scale: impl Into<Scale3D>) -> Self {
Self {
transform: TranslationRotationScale3D::from_scale(scale).into(),
scale: Some(vec![scale.into()]),
..Self::default()
}
}
Expand Down Expand Up @@ -75,7 +75,7 @@ impl Transform3D {
scale: impl Into<Scale3D>,
) -> Self {
Self {
transform: TranslationRotationScale3D::from_scale(scale).into(),
scale: Some(vec![scale.into()]),
translation: Some(vec![translation.into()]),
..Self::default()
}
Expand All @@ -89,7 +89,8 @@ impl Transform3D {
scale: impl Into<Scale3D>,
) -> Self {
Self {
transform: TranslationRotationScale3D::from_rotation_scale(rotation, scale).into(),
transform: TranslationRotationScale3D::from_rotation(rotation).into(),
scale: Some(vec![scale.into()]),
translation: Some(vec![translation.into()]),
..Self::default()
}
Expand All @@ -99,7 +100,8 @@ impl Transform3D {
#[inline]
pub fn from_rotation_scale(rotation: impl Into<Rotation3D>, scale: impl Into<Scale3D>) -> Self {
Self {
transform: TranslationRotationScale3D::from_rotation_scale(rotation, scale).into(),
transform: TranslationRotationScale3D::from_rotation(rotation).into(),
scale: Some(vec![scale.into()]),
..Self::default()
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/src/components/.gitattributes

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

3 changes: 3 additions & 0 deletions crates/store/re_types/src/components/mod.rs

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

Loading

0 comments on commit 369f97c

Please sign in to comment.