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

New LeafTransform3D, replacing OutOfTreeTransform3D #7015

Merged
merged 31 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6a151d2
Introduce LeafTransform3D type + associated components
Wumpf Jul 26, 2024
189f26b
Rust extensions for leaf transform component types
Wumpf Jul 26, 2024
cbdb67d
Refactor transform context to work with leaf transforms
Wumpf Jul 26, 2024
570206e
fix broken camera transform handling
Wumpf Jul 25, 2024
90a64cf
improve 2D in 3D handling
Wumpf Jul 26, 2024
2e7b948
rerun-lint typo fixes
Wumpf Jul 29, 2024
0c54020
Remove OutOfTreeTransform3D
Wumpf Jul 29, 2024
692d72a
Always make use of leaf transforms now, use them to instantiate mesh/…
Wumpf Jul 29, 2024
4a38c07
improve leaf transform3d docs and make fields more consequently plural
Wumpf Jul 29, 2024
539529d
add missing python leafscale3d extension
Wumpf Jul 29, 2024
73d9a2a
add leat transform3d test
Wumpf Jul 29, 2024
a5bc96f
fix leaf transform query being broken
Wumpf Jul 29, 2024
6bebb13
Add missing extensions and example for leaf transforms
Wumpf Jul 29, 2024
2bc2a65
Merge remote-tracking branch 'origin/main' into andreas/introduce-lea…
Wumpf Jul 30, 2024
392ba3a
fix transform upward propagation
Wumpf Jul 30, 2024
dfefab8
fix num_instances on `UnitChunkShared`
Wumpf Jul 30, 2024
9167a31
fix transform_component_tracker query
Wumpf Jul 30, 2024
7f44b5a
Add new snippet for leaf transforms on mesh
Wumpf Jul 30, 2024
dd9d505
fix the the!
Wumpf Jul 30, 2024
ea1c85b
typo fix
Wumpf Jul 30, 2024
9864884
upgrade migration guide and python docs
Wumpf Jul 30, 2024
6e06051
snippet fixes
Wumpf Jul 30, 2024
02cd0bc
typo fix in python docgen
Wumpf Jul 30, 2024
5baf54a
C++ sample formatting and float shenanigans
Wumpf Jul 30, 2024
8ffab40
cargo fmt
Wumpf Jul 30, 2024
a7cf020
codegen
Wumpf Jul 30, 2024
2f63ba2
Merge remote-tracking branch 'origin/main' into andreas/introduce-lea…
Wumpf Jul 31, 2024
bff1eb0
don't run mesh3d_leaf_transforms3d
Wumpf Jul 31, 2024
d978da3
doc fixes fbs
Wumpf Jul 31, 2024
111d601
note on simpler transform hierarchy
Wumpf Jul 31, 2024
0e22047
better point out the nature of hybrid join
Wumpf Jul 31, 2024
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
4 changes: 4 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5012,6 +5012,7 @@ dependencies = [
"re_viewport_blueprint",
"serde",
"smallvec",
"vec1",
"web-time",
]

Expand Down Expand Up @@ -6975,6 +6976,9 @@ name = "vec1"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bda7c41ca331fe9a1c278a9e7ee055f4be7f5eb1c2b72f079b4ff8b5fce9d5c"
dependencies = [
"smallvec",
]

[[package]]
name = "version_check"
Expand Down
6 changes: 4 additions & 2 deletions crates/store/re_chunk/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,13 @@ impl UnitChunkShared {
/// The maximum value amongst all components is what's returned.
#[inline]
pub fn num_instances(&self) -> u64 {
debug_assert!(self.num_rows() == 1);
self.components
.values()
.map(|list_array| {
list_array.validity().map_or_else(
|| list_array.len(),
let array = list_array.value(0);
array.validity().map_or_else(
|| array.len(),
|validity| validity.len() - validity.unset_bits(),
)
})
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/archetypes.fbs

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

13 changes: 4 additions & 9 deletions crates/store/re_types/definitions/rerun/archetypes/asset3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ namespace rerun.archetypes;
///
/// See also [archetypes.Mesh3D].
///
/// If there are multiple [archetypes.LeafTransforms3D] instances logged to the same entity as a mesh,
/// an instance of the mesh will be drawn for each transform.
///
/// \example archetypes/asset3d_simple title="Simple 3D asset" image="https://static.rerun.io/asset3d_simple/af238578188d3fd0de3e330212120e2842a8ddb2/1200w.png"
/// \example archetypes/asset3d_out_of_tree !api title="3D asset with out-of-tree transform"
table Asset3D (
"attr.rust.derive": "PartialEq",
"attr.rust.derive": "PartialEq, Eq",
"attr.docs.category": "Spatial 3D",
"attr.docs.view_types": "Spatial3DView, Spatial2DView: if logged above active projection"
) {
Expand All @@ -31,11 +33,4 @@ table Asset3D (
/// If omitted, the viewer will try to guess from the data blob.
/// If it cannot guess, it won't be able to render the asset.
media_type: rerun.components.MediaType ("attr.rerun.component_recommended", nullable, order: 2000);

// --- Optional ---

/// An out-of-tree transform.
///
/// Applies a transformation to the asset itself without impacting its children.
transform: rerun.components.OutOfTreeTransform3D ("attr.rerun.component_optional", nullable, order: 3000);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace rerun.archetypes;


/// One or more transforms between the parent and the current entity which are *not* propagated in the transform hierarchy.
///
/// For transforms that are propagated in the transform hierarchy, see [archetypes.Transform3D].
///
/// 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.
/// 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,
/// all components are applied in the inverse order they are listed here.
/// E.g. if both a translation and a max3x3 transform are present,
/// the 3x3 matrix is applied first, followed by the translation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to see this one drawn out in a diagram some day.

///
/// \example archetypes/leaf_transforms3d_combined title="Regular & leaf transform in tandom" image="https://static.rerun.io/leaf_transform3d/41674f0082d6de489f8a1cd1583f60f6b5820ddf/1200w.png"
table LeafTransforms3D (
"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"
) {
/// Translation vectors.
translations: [rerun.components.LeafTranslation3D] ("attr.rerun.component_optional", nullable, order: 1100);

/// Rotations via axis + angle.
rotation_axis_angles: [rerun.components.LeafRotationAxisAngle] ("attr.rerun.component_optional", nullable, order: 1200);

/// Rotations via quaternion.
quaternions: [rerun.components.LeafRotationQuat] ("attr.rerun.component_optional", nullable, order: 1300);

/// Scaling factors.
scales: [rerun.components.LeafScale3D] ("attr.rerun.component_optional", nullable, order: 1400);

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

// TODO(andreas): Support TransformRelation?
// TODO(andreas): Support axis_length?
}
4 changes: 4 additions & 0 deletions crates/store/re_types/definitions/rerun/archetypes/mesh3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ namespace rerun.archetypes;
///
/// See also [archetypes.Asset3D].
///
/// If there are multiple [archetypes.LeafTransforms3D] instances logged to the same entity as a mesh,
/// an instance of the mesh will be drawn for each transform.
///
/// \example archetypes/mesh3d_indexed title="Simple indexed 3D mesh" image="https://static.rerun.io/mesh3d_simple/e1e5fd97265daf0d0bc7b782d862f19086fd6975/1200w.png"
/// \example archetypes/mesh3d_partial_updates !api title="3D mesh with partial updates" image="https://static.rerun.io/mesh3d_partial_updates/a11e4accb0257dcd9531867b7e1d6fd5e3bee5c3/1200w.png"
/// \example archetypes/mesh3d_leaf_transforms3d title="3D mesh with leaf transforms" image="https://static.rerun.io/mesh3d_leaf_transforms3d/c2d0ee033129da53168f5705625a9b033f3a3d61/1200w.png"
table Mesh3D (
"attr.rust.derive": "PartialEq",
"attr.docs.category": "Spatial 3D",
Expand Down
1 change: 0 additions & 1 deletion crates/store/re_types/definitions/rerun/components.fbs

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ table RotationAxisAngle (
) {
rotation: rerun.datatypes.RotationAxisAngle (order: 100);
}

/// 3D rotation represented by a rotation around a given axis that doesn't propagate in the transform hierarchy.
table LeafRotationAxisAngle (
"attr.docs.unreleased",
"attr.rust.derive": "Default, Copy, PartialEq",
"attr.rust.repr": "transparent"
) {
rotation: rerun.datatypes.RotationAxisAngle (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ namespace rerun.components;
/// A 3D rotation expressed as a quaternion.
///
/// Note: although the x,y,z,w components of the quaternion will be passed through to the
/// datastore as provided, when used in the Viewer Quaternions will always be normalized.
/// datastore as provided, when used in the Viewer, quaternions will always be normalized.
struct RotationQuat (
"attr.docs.unreleased",
"attr.rust.derive": "Default, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
quaternion: rerun.datatypes.Quaternion (order: 100);
}

/// A 3D rotation expressed as a quaternion that doesn't propagate in the transform hierarchy.
///
/// Note: although the x,y,z,w components of the quaternion will be passed through to the
/// datastore as provided, when used in the Viewer, quaternions will always be normalized.
struct LeafRotationQuat (
"attr.docs.unreleased",
"attr.rust.derive": "Default, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
quaternion: rerun.datatypes.Quaternion (order: 100);
}
13 changes: 13 additions & 0 deletions crates/store/re_types/definitions/rerun/components/scale3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@ struct Scale3D (
) {
scale: rerun.datatypes.Vec3D (order: 100);
}

/// A 3D scale factor that doesn't propagate in the transform hierarchy.
///
/// 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 LeafScale3D (
"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,3 +43,46 @@ struct TransformMat3x3 (
matrix: rerun.datatypes.Mat3x3 (order: 100);
}


/// A 3x3 transformation matrix Matrix that doesn't propagate in the transform hierarchy.
///
/// 3x3 matrixes are able to represent any affine transformation in 3D space,
/// i.e. rotation, scaling, shearing, reflection etc.
///
/// Matrices in Rerun are stored as flat list of coefficients in column-major order:
/// ```text
/// column 0 column 1 column 2
/// -------------------------------------------------
/// row 0 | flat_columns[0] flat_columns[3] flat_columns[6]
/// row 1 | flat_columns[1] flat_columns[4] flat_columns[7]
/// row 2 | flat_columns[2] flat_columns[5] flat_columns[8]
/// ```
///
/// \py However, construction is done from a list of rows, which follows NumPy's convention:
/// \py ```python
/// \py np.testing.assert_array_equal(
/// \py rr.components.LeafTransformMat3x3([1, 2, 3, 4, 5, 6, 7, 8, 9]).flat_columns, np.array([1, 4, 7, 2, 5, 8, 3, 6, 9], dtype=np.float32)
/// \py )
/// \py np.testing.assert_array_equal(
/// \py rr.components.LeafTransformMat3x3([[1, 2, 3], [4, 5, 6], [7, 8, 9]]).flat_columns,
/// \py np.array([1, 4, 7, 2, 5, 8, 3, 6, 9], dtype=np.float32),
/// \py )
/// \py ```
/// \py If you want to construct a matrix from a list of columns instead, use the named `columns` parameter:
/// \py ```python
/// \py np.testing.assert_array_equal(
/// \py rr.components.LeafTransformMat3x3(columns=[1, 2, 3, 4, 5, 6, 7, 8, 9]).flat_columns,
/// \py np.array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.float32),
/// \py )
/// \py np.testing.assert_array_equal(
/// \py rr.components.LeafTransformMat3x3(columns=[[1, 2, 3], [4, 5, 6], [7, 8, 9]]).flat_columns,
/// \py np.array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.float32),
/// \py )
/// \py ```
struct LeafTransformMat3x3 (
"attr.docs.unreleased",
"attr.rust.derive": "Default, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
matrix: rerun.datatypes.Mat3x3 (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ enum TransformRelation: byte (
) {
/// The transform describes how to transform into the parent entity's space.
///
/// E.g. a translation of (0, 1, 0) with this `TransformRelation` logged at `parent/child` means
/// E.g. a translation of (0, 1, 0) with this [components.TransformRelation] logged at `parent/child` means
/// that from the point of view of `parent`, `parent/child` is translated 1 unit along `parent`'s Y axis.
/// From perspective of `parent/child`, the `parent` entity is translated -1 unit along `parent/child`'s Y axis.
ParentFromChild(default),

/// The transform describes how to transform into the child entity's space.
///
/// E.g. a translation of (0, 1, 0) with this `TransformRelation` logged at `parent/child` means
/// E.g. a translation of (0, 1, 0) with this [components.TransformRelation] logged at `parent/child` means
/// that from the point of view of `parent`, `parent/child` is translated -1 unit along `parent`'s Y axis.
/// From perspective of `parent/child`, the `parent` entity is translated 1 unit along `parent/child`'s Y axis.
ChildFromParent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ struct Translation3D (
) {
vector: rerun.datatypes.Vec3D (order: 100);
}

/// A translation vector in 3D space that doesn't propagate in the transform hierarchy.
struct LeafTranslation3D (
"attr.docs.unreleased",
"attr.rust.derive": "Default, Copy, PartialEq, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
vector: rerun.datatypes.Vec3D (order: 100);
}
1 change: 1 addition & 0 deletions crates/store/re_types/src/archetypes/.gitattributes

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

Loading
Loading