Skip to content

Commit

Permalink
Implement roundtrip-ready DisconnectedSpace archetype (#2833)
Browse files Browse the repository at this point in the history
What the title says.

This does **not** migrate off of the legacy `DisconnectedSpace`, that's
for a future PR.

Part of #2791

### What

### Checklist
* [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 [demo.rerun.io](https://demo.rerun.io/pr/2833) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2833)
- [Docs
preview](https://rerun.io/preview/pr%3Acmc%2Froundtrippable_disconnected_transform/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Acmc%2Froundtrippable_disconnected_transform/examples)
  • Loading branch information
teh-cmc authored Jul 28, 2023
1 parent 4debe3f commit 469046a
Show file tree
Hide file tree
Showing 56 changed files with 931 additions and 84 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions crates/re_space_view_spatial/src/parts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub fn picking_id_from_instance_key(

/// Process [`Color`] components using annotations and default colors.
#[allow(dead_code)]
pub fn process_colors_arch<'a, A: Archetype>(
pub fn process_colors<'a, A: Archetype>(
arch_view: &'a re_query::ArchetypeView<A>,
ent_path: &'a EntityPath,
annotation_infos: &'a [ResolvedAnnotationInfo],
Expand All @@ -122,7 +122,7 @@ pub fn process_colors_arch<'a, A: Archetype>(

/// Process [`re_types::components::Radius`] components to [`re_renderer::Size`] using auto size
/// where no radius is specified.
pub fn process_radii_arch<'a, A: Archetype>(
pub fn process_radii<'a, A: Archetype>(
arch_view: &'a re_query::ArchetypeView<A>,
ent_path: &EntityPath,
) -> Result<impl Iterator<Item = re_renderer::Size> + 'a, re_query::QueryError> {
Expand Down
8 changes: 4 additions & 4 deletions crates/re_space_view_spatial/src/parts/points2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
contexts::{EntityDepthOffsets, SpatialSceneEntityContext},
parts::{
entity_iterator::process_archetype_views, load_keypoint_connections,
process_annotations_and_keypoints_arch, process_colors_arch, process_radii_arch, UiLabel,
process_annotations_and_keypoints_arch, process_colors, process_radii, UiLabel,
UiLabelTarget,
},
view_kind::SpatialSpaceViewKind,
Expand Down Expand Up @@ -82,13 +82,13 @@ impl Points2DPart {
Points2D,
>(query, arch_view, &ent_context.annotations)?;

let colors = process_colors_arch(arch_view, ent_path, &annotation_infos)?;
let radii = process_radii_arch(arch_view, ent_path)?;
let colors = process_colors(arch_view, ent_path, &annotation_infos)?;
let radii = process_radii(arch_view, ent_path)?;

if arch_view.num_instances() <= self.max_labels {
// Max labels is small enough that we can afford iterating on the colors again.
let colors =
process_colors_arch(arch_view, ent_path, &annotation_infos)?.collect::<Vec<_>>();
process_colors(arch_view, ent_path, &annotation_infos)?.collect::<Vec<_>>();

let instance_path_hashes_for_picking = {
re_tracing::profile_scope!("instance_hashes");
Expand Down
8 changes: 4 additions & 4 deletions crates/re_space_view_spatial/src/parts/points3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
contexts::{EntityDepthOffsets, SpatialSceneEntityContext},
parts::{
entity_iterator::process_archetype_views, load_keypoint_connections,
process_annotations_and_keypoints_arch, process_colors_arch, process_radii_arch, UiLabel,
process_annotations_and_keypoints_arch, process_colors, process_radii, UiLabel,
UiLabelTarget,
},
view_kind::SpatialSpaceViewKind,
Expand Down Expand Up @@ -85,13 +85,13 @@ impl Points3DPart {
Points3D,
>(query, arch_view, &ent_context.annotations)?;

let colors = process_colors_arch(arch_view, ent_path, &annotation_infos)?;
let radii = process_radii_arch(arch_view, ent_path)?;
let colors = process_colors(arch_view, ent_path, &annotation_infos)?;
let radii = process_radii(arch_view, ent_path)?;

if arch_view.num_instances() <= self.max_labels {
// Max labels is small enough that we can afford iterating on the colors again.
let colors =
process_colors_arch(arch_view, ent_path, &annotation_infos)?.collect::<Vec<_>>();
process_colors(arch_view, ent_path, &annotation_infos)?.collect::<Vec<_>>();

let instance_path_hashes_for_picking = {
re_tracing::profile_scope!("instance_hashes");
Expand Down
2 changes: 2 additions & 0 deletions crates/re_types/.gitattributes

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

1 change: 1 addition & 0 deletions crates/re_types/definitions/rerun/archetypes.fbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include "./archetypes/disconnected_space.fbs";
include "./archetypes/points2d.fbs";
include "./archetypes/points3d.fbs";
include "./archetypes/transform3d.fbs";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
include "fbs/attributes.fbs";

include "rerun/datatypes.fbs";
include "rerun/components.fbs";

namespace rerun.archetypes;

/// Specifies that the entity path at which this is logged is disconnected from its parent.
///
/// This is useful for specifying that a subgraph is independent of the rest of the scene.
///
/// If a transform or pinhole is logged on the same path, this archetype's components
/// will be ignored.
///
/// \py Example
/// \py -------
/// \py
/// \py ```python
/// \py \include:../../../../../docs/code-examples/disconnected_space_v2.py
/// \py ```
///
/// \rs ## Example
/// \rs
/// \rs ```ignore
/// \rs \include:../../../../../docs/code-examples/disconnected_space_v2.rs
/// \rs ```
table DisconnectedSpace (
"attr.rust.derive": "Copy, PartialEq, Eq",
order: 100
) {
disconnected_space: rerun.components.DisconnectedSpace ("attr.rerun.component_required", required, order: 1000);
}
1 change: 1 addition & 0 deletions crates/re_types/definitions/rerun/components.fbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include "./components/class_id.fbs";
include "./components/color.fbs";
include "./components/disconnected_space.fbs";
include "./components/draw_order.fbs";
include "./components/instance_key.fbs";
include "./components/keypoint_id.fbs";
Expand Down
6 changes: 3 additions & 3 deletions crates/re_types/definitions/rerun/components/class_id.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ namespace rerun.components;

// ---

// TODO(#2801): serde should be cfg_attr gated here

/// A 16-bit ID representing a type of semantic class.
///
/// \rs Used to look up a `crate::components::ClassDescription` within the `crate::components::AnnotationContext`.
struct ClassId (
"attr.python.aliases": "int",
"attr.python.array_aliases": "int, npt.NDArray[np.uint8], npt.NDArray[np.uint16], npt.NDArray[np.uint32], npt.NDArray[np.uint64]",
"attr.rerun.legacy_fqname": "rerun.class_id",
"attr.rust.derive": "Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, ::serde::Serialize, ::serde::Deserialize",
"attr.rust.derive": "Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash",
"attr.rust.custom_clause":
'cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))',
order: 100
) {
id: ushort (order: 100);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include "arrow/attributes.fbs";
include "python/attributes.fbs";
include "rust/attributes.fbs";

include "rerun/datatypes.fbs";
include "rerun/attributes.fbs";

namespace rerun.components;

// ---

/// Specifies that the entity path at which this is logged is disconnected from its parent.
///
/// This is useful for specifying that a subgraph is independent of the rest of the scene.
///
/// If a transform or pinhole is logged on the same path, this component will be ignored.
struct DisconnectedSpace (
"attr.python.aliases": "bool",
"attr.python.array_aliases": "bool, npt.NDArray[np.bool_]",
"attr.rerun.legacy_fqname": "rerun.disconnected_space",
"attr.rust.derive": "Copy, PartialEq, Eq",
order: 100
) {
is_disconnected: bool (order: 100);
}
6 changes: 3 additions & 3 deletions crates/re_types/definitions/rerun/components/keypoint_id.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace rerun.components;

// ---

// TODO(#2801): serde should be cfg_attr gated here

/// A 16-bit ID representing a type of semantic keypoint within a class.
///
/// \py `KeypointId`s are only meaningful within the context of a [`rerun.components.ClassDescription`][].
Expand All @@ -24,7 +22,9 @@ struct KeypointId (
"attr.python.aliases": "float",
"attr.python.array_aliases": "float, npt.NDArray[np.uint8], npt.NDArray[np.uint16], npt.NDArray[np.uint32]",
"attr.rerun.legacy_fqname": "rerun.keypoint_id",
"attr.rust.derive": "Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, ::serde::Serialize, ::serde::Deserialize",
"attr.rust.derive": "Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash",
"attr.rust.custom_clause":
'cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))',
order: 200
) {
id: ushort (order: 100);
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/source_hash.txt

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

177 changes: 177 additions & 0 deletions crates/re_types/src/archetypes/disconnected_space.rs

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

Loading

0 comments on commit 469046a

Please sign in to comment.