From 392d78cbcda97fa04ca5d2b48dd3f70d601bcb39 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Fri, 10 Jan 2025 10:57:58 +0100 Subject: [PATCH] implement legacy and next-gen partial updates snippets for all, ready or not --- docs/snippets/INDEX.md | 10 ++++ .../archetypes/points3d_partial_updates.cpp | 58 +++++++++++++++++++ .../archetypes/points3d_partial_updates.py | 30 ++++++++++ .../archetypes/points3d_partial_updates.rs | 40 +++++++++++++ .../points3d_partial_updates_legacy.cpp | 52 +++++++++++++++++ .../points3d_partial_updates_legacy.py | 24 ++++++++ .../points3d_partial_updates_legacy.rs | 49 ++++++++++++++++ .../descriptors/descr_builtin_component.rs | 4 +- .../all/descriptors/descr_custom_component.rs | 4 +- docs/snippets/all/tutorials/custom_data.rs | 24 ++++---- docs/snippets/snippets.toml | 4 ++ lychee.toml | 10 +++- 12 files changed, 290 insertions(+), 19 deletions(-) create mode 100644 docs/snippets/all/archetypes/points3d_partial_updates.cpp create mode 100644 docs/snippets/all/archetypes/points3d_partial_updates.py create mode 100644 docs/snippets/all/archetypes/points3d_partial_updates.rs create mode 100644 docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp create mode 100644 docs/snippets/all/archetypes/points3d_partial_updates_legacy.py create mode 100644 docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs diff --git a/docs/snippets/INDEX.md b/docs/snippets/INDEX.md index 7ae27d8bee17f..26ab29d14dcfa 100644 --- a/docs/snippets/INDEX.md +++ b/docs/snippets/INDEX.md @@ -71,6 +71,8 @@ _All snippets, organized by the [`Archetype`](https://rerun.io/docs/reference/ty | **[`Capsules3D`](https://rerun.io/docs/reference/types/archetypes/capsules3d)** | `archetypes/capsules3d_batch` | Log a batch of capsules | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/capsules3d_batch.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/capsules3d_batch.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/capsules3d_batch.cpp) | | **[`Clear`](https://rerun.io/docs/reference/types/archetypes/clear)** | `archetypes/clear_simple` | Log and then clear data | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/clear_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/clear_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/clear_simple.cpp) | | **[`Clear`](https://rerun.io/docs/reference/types/archetypes/clear)** | `archetypes/clear_recursive` | Log and then clear data recursively | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/clear_recursive.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/clear_recursive.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/clear_recursive.cpp) | +| **[`Clear`](https://rerun.io/docs/reference/types/archetypes/clear)** | `archetypes/points3d_partial_updates` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.cpp) | +| **[`Clear`](https://rerun.io/docs/reference/types/archetypes/clear)** | `archetypes/points3d_partial_updates_legacy` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp) | | **[`Clear`](https://rerun.io/docs/reference/types/archetypes/clear)** | `concepts/different_data_per_timeline` | Log different data on different timelines | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/different_data_per_timeline.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/different_data_per_timeline.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/different_data_per_timeline.cpp) | | **[`DepthImage`](https://rerun.io/docs/reference/types/archetypes/depth_image)** | `archetypes/depth_image_simple` | Create and log a depth image | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/depth_image_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/depth_image_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/depth_image_simple.cpp) | | **[`DepthImage`](https://rerun.io/docs/reference/types/archetypes/depth_image)** | `archetypes/depth_image_3d` | Create and log a depth image and pinhole camera | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/depth_image_3d.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/depth_image_3d.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/depth_image_3d.cpp) | @@ -128,6 +130,8 @@ _All snippets, organized by the [`Archetype`](https://rerun.io/docs/reference/ty | **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `archetypes/points3d_simple` | Log some very simple points | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_simple.cpp) | | **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `archetypes/points3d_send_columns` | Use the `send_columns` API to send several point clouds over time in a single call | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_send_columns.py) | | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_send_columns.cpp) | | **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `archetypes/points3d_random` | Log some random points with color and radii | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_random.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_random.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_random.cpp) | +| **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `archetypes/points3d_partial_updates_legacy` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp) | +| **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `archetypes/points3d_partial_updates` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.cpp) | | **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `archetypes/annotation_context_connections` | Log annotation context with connections between keypoints | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/annotation_context_connections.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/annotation_context_connections.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/annotation_context_connections.cpp) | | **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `archetypes/ellipsoids3d_simple` | Log random points and the corresponding covariance ellipsoid | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/ellipsoids3d_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/ellipsoids3d_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/ellipsoids3d_simple.cpp) | | **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `archetypes/instance_poses3d_combined` | Log a simple 3D box with a regular & instance pose transform | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/instance_poses3d_combined.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/instance_poses3d_combined.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/instance_poses3d_combined.cpp) | @@ -196,6 +200,8 @@ _All snippets, organized by the [`Component`](https://rerun.io/docs/reference/ty | **[`AnnotationContext`](https://rerun.io/docs/reference/types/components/annotation_context)** | `archetypes/annotation_context_connections` | Log annotation context with connections between keypoints | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/annotation_context_connections.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/annotation_context_connections.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/annotation_context_connections.cpp) | | **[`AnnotationContext`](https://rerun.io/docs/reference/types/components/annotation_context)** | `archetypes/segmentation_image_simple` | Create and log a segmentation image | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/segmentation_image_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/segmentation_image_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/segmentation_image_simple.cpp) | | **[`AnnotationContext`](https://rerun.io/docs/reference/types/components/annotation_context)** | `tutorials/annotation-context` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/tutorials/annotation-context.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/tutorials/annotation-context.rs) | | +| **[`Color`](https://rerun.io/docs/reference/types/components/color)** | `archetypes/points3d_partial_updates` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.cpp) | +| **[`Color`](https://rerun.io/docs/reference/types/components/color)** | `archetypes/points3d_partial_updates_legacy` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp) | | **[`Color`](https://rerun.io/docs/reference/types/components/color)** | `archetypes/points3d_send_columns` | Use the `send_columns` API to send several point clouds over time in a single call | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_send_columns.py) | | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_send_columns.cpp) | | **[`Color`](https://rerun.io/docs/reference/types/components/color)** | `concepts/different_data_per_timeline` | Log different data on different timelines | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/different_data_per_timeline.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/different_data_per_timeline.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/different_data_per_timeline.cpp) | | **[`Color`](https://rerun.io/docs/reference/types/components/color)** | `concepts/viscomp-component-default` | Add a component default | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/viscomp-component-default.py) | | | @@ -216,6 +222,8 @@ _All snippets, organized by the [`Component`](https://rerun.io/docs/reference/ty | **[`MediaType`](https://rerun.io/docs/reference/types/components/media_type)** | `views/text_document` | Use a blueprint to show a text document | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/views/text_document.py) | | | | **[`Plane3D`](https://rerun.io/docs/reference/types/components/plane3d)** | `views/spatial3d` | Use a blueprint to customize a Spatial3DView | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/views/spatial3d.py) | | | | **[`Position3D`](https://rerun.io/docs/reference/types/components/position3d)** | `archetypes/mesh3d_partial_updates` | Log a simple colored triangle, then update its vertices' positions each frame | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/mesh3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/mesh3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/mesh3d_partial_updates.cpp) | +| **[`Position3D`](https://rerun.io/docs/reference/types/components/position3d)** | `archetypes/points3d_partial_updates` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.cpp) | +| **[`Position3D`](https://rerun.io/docs/reference/types/components/position3d)** | `archetypes/points3d_partial_updates_legacy` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp) | | **[`Position3D`](https://rerun.io/docs/reference/types/components/position3d)** | `archetypes/points3d_send_columns` | Use the `send_columns` API to send several point clouds over time in a single call | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_send_columns.py) | | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_send_columns.cpp) | | **[`Position3D`](https://rerun.io/docs/reference/types/components/position3d)** | `descriptors/descr_builtin_component` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/descriptors/descr_builtin_component.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/descriptors/descr_builtin_component.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/descriptors/descr_builtin_component.cpp) | | **[`Position3D`](https://rerun.io/docs/reference/types/components/position3d)** | `descriptors/descr_custom_archetype` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/descriptors/descr_custom_archetype.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/descriptors/descr_custom_archetype.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/descriptors/descr_custom_archetype.cpp) | @@ -226,6 +234,8 @@ _All snippets, organized by the [`Component`](https://rerun.io/docs/reference/ty | **[`Radius`](https://rerun.io/docs/reference/types/components/radius)** | `archetypes/line_strips2d_ui_radius` | Log lines with ui points & scene unit radii | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/line_strips2d_ui_radius.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/line_strips2d_ui_radius.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/line_strips2d_ui_radius.cpp) | | **[`Radius`](https://rerun.io/docs/reference/types/components/radius)** | `archetypes/geo_line_strings_simple` | Log a simple geospatial line string | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/geo_line_strings_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/geo_line_strings_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/geo_line_strings_simple.cpp) | | **[`Radius`](https://rerun.io/docs/reference/types/components/radius)** | `archetypes/geo_points_simple` | Log some very simple geospatial point | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/geo_points_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/geo_points_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/geo_points_simple.cpp) | +| **[`Radius`](https://rerun.io/docs/reference/types/components/radius)** | `archetypes/points3d_partial_updates` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.cpp) | +| **[`Radius`](https://rerun.io/docs/reference/types/components/radius)** | `archetypes/points3d_partial_updates_legacy` | Demonstrates usage of the new partial updates APIs | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp) | | **[`Radius`](https://rerun.io/docs/reference/types/components/radius)** | `concepts/different_data_per_timeline` | Log different data on different timelines | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/different_data_per_timeline.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/different_data_per_timeline.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/concepts/different_data_per_timeline.cpp) | | **[`Radius`](https://rerun.io/docs/reference/types/components/radius)** | `views/map` | Use a blueprint to customize a map view | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/views/map.py) | | | | **[`RotationAxisAngle`](https://rerun.io/docs/reference/types/components/rotation_axis_angle)** | `archetypes/capsules3d_batch` | Log a batch of capsules | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/capsules3d_batch.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/capsules3d_batch.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/capsules3d_batch.cpp) | diff --git a/docs/snippets/all/archetypes/points3d_partial_updates.cpp b/docs/snippets/all/archetypes/points3d_partial_updates.cpp new file mode 100644 index 0000000000000..ca78984793102 --- /dev/null +++ b/docs/snippets/all/archetypes/points3d_partial_updates.cpp @@ -0,0 +1,58 @@ +//! Demonstrates usage of the new partial updates APIs. + +#include + +#include +#include + +int main() { + const auto rec = rerun::RecordingStream("rerun_example_points3d_partial_updates"); + rec.spawn().exit_on_failure(); + + std::vector positions; + for (int i = 0; i < 10; ++i) { + positions.emplace_back(static_cast(i), 0.0f, 0.0f); + } + + rec.set_time_sequence("frame", 0); + rec.log("points", rerun::Points3D(positions)); + + for (int i = 0; i < 10; ++i) { + std::vector colors; + for (int n = 0; n < 10; ++n) { + if (n < i) { + colors.emplace_back(rerun::Color(20, 200, 20)); + } else { + colors.emplace_back(rerun::Color(200, 20, 20)); + } + } + + std::vector radii; + for (int n = 0; n < 10; ++n) { + if (n < i) { + radii.emplace_back(rerun::Radius(0.6f)); + } else { + radii.emplace_back(rerun::Radius(0.2f)); + } + } + + rec.set_time_sequence("frame", i); + rec.log("points", colors, radii); + // TODO(cmc): implement new APIs and use them! + // rec.log("points", rerun::Points3D::update_fields().with_radii(radii).with_colors(colors)); + } + + // TODO(cmc): remove this! + // We cannot replicate the clear_fields() logic! + rec.set_time_sequence("frame", 20); + rec.log("points", rerun::Clear::FLAT); + + std::vector radii; + radii.emplace_back(rerun::Radius(0.3)); + + rec.set_time_sequence("frame", 20); + rec.log("points", positions, radii); + + // TODO(cmc): implement new APIs and use them! + // rec.log("points", rerun::Points3D::clear_fields().with_radii(radii).with_colors(colors)); +} diff --git a/docs/snippets/all/archetypes/points3d_partial_updates.py b/docs/snippets/all/archetypes/points3d_partial_updates.py new file mode 100644 index 0000000000000..065d64b71abdd --- /dev/null +++ b/docs/snippets/all/archetypes/points3d_partial_updates.py @@ -0,0 +1,30 @@ +"""Demonstrates usage of the new partial updates APIs.""" + +import rerun as rr + +rr.init("rerun_example_points3d_partial_updates", spawn=True) + +positions = [[i, 0, 0] for i in range(0, 10)] + +rr.set_time_sequence("frame", 0) +rr.log("points", rr.Points3D(positions)) + +for i in range(0, 10): + colors = [[20, 200, 20] if n < i else [200, 20, 20] for n in range(0, 10)] + radii = [0.6 if n < i else 0.2 for n in range(0, 10)] + + rr.set_time_sequence("frame", i) + rr.log("points", [rr.components.ColorBatch(colors), rr.components.RadiusBatch(radii)]) + # TODO(cmc): implement new APIs and use them! + # rr.log("points", rr.Points3D.update_fields(radii=radii, colors=colors)) + +# TODO(cmc): remove this! +# We cannot replicate the clear_fields() logic! +rr.set_time_sequence("frame", 20) +rr.log("points", rr.Clear(recursive=False)) + +rr.set_time_sequence("frame", 20) +rr.log("points", [rr.components.Position3DBatch(positions), rr.components.RadiusBatch(0.3)]) + +# TODO(cmc): implement new APIs and use them! +# rr.log("points", rr.Points3D.clear_fields().update_fields(positions=positions, radii=0.3)) diff --git a/docs/snippets/all/archetypes/points3d_partial_updates.rs b/docs/snippets/all/archetypes/points3d_partial_updates.rs new file mode 100644 index 0000000000000..03a36d28b1c72 --- /dev/null +++ b/docs/snippets/all/archetypes/points3d_partial_updates.rs @@ -0,0 +1,40 @@ +//! Demonstrates usage of the new partial updates APIs. + +fn main() -> Result<(), Box> { + let rec = + rerun::RecordingStreamBuilder::new("rerun_example_points3d_partial_updates").spawn()?; + + let positions = (0..10).map(|i| (i as f32, 0.0, 0.0)).collect::>(); + + rec.set_time_sequence("frame", 0); + rec.log("points", &rerun::Points3D::new(&positions))?; + + for i in 0..10 { + let colors = (0..10).map(|n| { + if n < i { + rerun::Color::from_rgb(20, 200, 20) + } else { + rerun::Color::from_rgb(200, 20, 20) + } + }); + let radii = (0..10).map(|n| if n < i { 0.6 } else { 0.2 }); + + rec.set_time_sequence("frame", i); + rec.log( + "points", + &rerun::Points3D::update_fields() + .with_radii(radii) + .with_colors(colors), + )?; + } + + rec.set_time_sequence("frame", 20); + rec.log( + "points", + &rerun::Points3D::clear_fields() + .with_positions(positions) + .with_radii([0.3]), + )?; + + Ok(()) +} diff --git a/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp b/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp new file mode 100644 index 0000000000000..9bb1ee0083b31 --- /dev/null +++ b/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp @@ -0,0 +1,52 @@ +// Demonstrates usage of the legacy partial updates APIs. + +#include + +#include +#include + +int main() { + const auto rec = rerun::RecordingStream("rerun_example_points3d_partial_updates_legacy"); + rec.spawn().exit_on_failure(); + + std::vector positions; + for (int i = 0; i < 10; ++i) { + positions.emplace_back(static_cast(i), 0.0f, 0.0f); + } + + rec.set_time_sequence("frame", 0); + rec.log("points", rerun::Points3D(positions)); + + for (int i = 0; i < 10; ++i) { + std::vector colors; + for (int n = 0; n < 10; ++n) { + if (n < i) { + colors.emplace_back(rerun::Color(20, 200, 20)); + } else { + colors.emplace_back(rerun::Color(200, 20, 20)); + } + } + + std::vector radii; + for (int n = 0; n < 10; ++n) { + if (n < i) { + radii.emplace_back(rerun::Radius(0.6f)); + } else { + radii.emplace_back(rerun::Radius(0.2f)); + } + } + + rec.set_time_sequence("frame", i); + rec.log("points", colors, radii); + } + + // We cannot replicate the clear_fields() logic! + rec.set_time_sequence("frame", 20); + rec.log("points", rerun::Clear::FLAT); + + std::vector radii; + radii.emplace_back(rerun::Radius(0.3)); + + rec.set_time_sequence("frame", 20); + rec.log("points", positions, radii); +} diff --git a/docs/snippets/all/archetypes/points3d_partial_updates_legacy.py b/docs/snippets/all/archetypes/points3d_partial_updates_legacy.py new file mode 100644 index 0000000000000..c95c2632ba091 --- /dev/null +++ b/docs/snippets/all/archetypes/points3d_partial_updates_legacy.py @@ -0,0 +1,24 @@ +"""Demonstrates usage of the new partial updates APIs.""" + +import rerun as rr + +rr.init("rerun_example_points3d_partial_updates_legacy", spawn=True) + +positions = [[i, 0, 0] for i in range(0, 10)] + +rr.set_time_sequence("frame", 0) +rr.log("points", rr.Points3D(positions)) + +for i in range(0, 10): + colors = [[20, 200, 20] if n < i else [200, 20, 20] for n in range(0, 10)] + radii = [0.6 if n < i else 0.2 for n in range(0, 10)] + + rr.set_time_sequence("frame", i) + rr.log("points", [rr.components.ColorBatch(colors), rr.components.RadiusBatch(radii)]) + +# We cannot replicate the clear_fields() logic! +rr.set_time_sequence("frame", 20) +rr.log("points", rr.Clear(recursive=False)) + +rr.set_time_sequence("frame", 20) +rr.log("points", [rr.components.Position3DBatch(positions), rr.components.RadiusBatch(0.3)]) diff --git a/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs b/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs new file mode 100644 index 0000000000000..25321a4df9030 --- /dev/null +++ b/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs @@ -0,0 +1,49 @@ +//! Demonstrates usage of the legacy partial updates APIs. + +fn main() -> Result<(), Box> { + let rec = rerun::RecordingStreamBuilder::new("rerun_example_points3d_partial_updates_legacy") + .spawn()?; + + let positions = (0..10).map(|i| (i as f32, 0.0, 0.0)).collect::>(); + + rec.set_time_sequence("frame", 0); + rec.log("points", &rerun::Points3D::new(positions.clone()))?; + + for i in 0..10 { + let colors: Vec = (0..10) + .map(|n| { + if n < i { + rerun::Color::from_rgb(20, 200, 20) + } else { + rerun::Color::from_rgb(200, 20, 20) + } + }) + .collect(); + let radii: Vec = (0..10) + .map(|n| if n < i { 0.6 } else { 0.2 }) + .map(Into::into) + .collect(); + + rec.set_time_sequence("frame", i); + rec.log("points", &[&colors as &dyn rerun::ComponentBatch, &radii])?; + } + + // We cannot replicate the clear_fields() logic! + rec.set_time_sequence("frame", 20); + rec.log("points", &rerun::Clear::flat())?; + + rec.set_time_sequence("frame", 20); + let positions: Vec = (0..10) + .map(|i| (i as f32, 0.0, 0.0)) + .map(Into::into) + .collect(); + rec.log( + "points", + &[ + &positions as &dyn rerun::ComponentBatch, + &rerun::components::Radius(0.3.into()), + ], + )?; + + Ok(()) +} diff --git a/docs/snippets/all/descriptors/descr_builtin_component.rs b/docs/snippets/all/descriptors/descr_builtin_component.rs index 7b1881b8a20a0..dfb391127036a 100644 --- a/docs/snippets/all/descriptors/descr_builtin_component.rs +++ b/docs/snippets/all/descriptors/descr_builtin_component.rs @@ -2,10 +2,10 @@ use rerun::{ChunkStore, ChunkStoreConfig, Component as _, ComponentDescriptor, V fn example(rec: &rerun::RecordingStream) -> Result<(), Box> { use rerun::ComponentBatch as _; - rec.log_component_batches_v2( + rec.log_serialized_batches( "data", true, - [rerun::components::Position3D::new(1.0, 2.0, 3.0).serialized()], + [rerun::components::Position3D::new(1.0, 2.0, 3.0).try_serialized()?], )?; Ok(()) diff --git a/docs/snippets/all/descriptors/descr_custom_component.rs b/docs/snippets/all/descriptors/descr_custom_component.rs index a3cbc1cccad5a..a8bb1d0f9ee2d 100644 --- a/docs/snippets/all/descriptors/descr_custom_component.rs +++ b/docs/snippets/all/descriptors/descr_custom_component.rs @@ -2,13 +2,13 @@ use rerun::{ChunkStore, ChunkStoreConfig, ComponentBatch, ComponentDescriptor, V fn example(rec: &rerun::RecordingStream) -> Result<(), Box> { let positions = rerun::components::Position3D::new(1.0, 2.0, 3.0) - .serialized() + .try_serialized()? .with_descriptor_override(ComponentDescriptor { archetype_name: Some("user.CustomArchetype".into()), archetype_field_name: Some("custom_positions".into()), component_name: "user.CustomPosition3D".into(), }); - rec.log_component_batches_v2("data", true, [positions])?; + rec.log_serialized_batches("data", true, [positions])?; Ok(()) } diff --git a/docs/snippets/all/tutorials/custom_data.rs b/docs/snippets/all/tutorials/custom_data.rs index fc76466d79dd0..2857159a2729f 100644 --- a/docs/snippets/all/tutorials/custom_data.rs +++ b/docs/snippets/all/tutorials/custom_data.rs @@ -18,26 +18,22 @@ struct CustomPoints3D { } impl rerun::AsComponents for CustomPoints3D { - fn as_component_batches_v2(&self) -> Vec { + fn as_serialized_batches(&self) -> Vec { let indicator = rerun::NamedIndicatorComponent("user.CustomPoints3DIndicator".into()); self.points3d - .as_component_batches_v2() + .as_serialized_batches() .into_iter() .chain( [ - Some(indicator.serialized()), - self.confidences.as_ref().map(|batch| { - batch - .serialized() + indicator.serialized(), + self.confidences + .as_ref() + .and_then(|batch| batch.serialized()) + .map(|batch| // Optionally override the descriptor with extra information. - .with_descriptor_override( - batch - .descriptor() - .into_owned() - .or_with_archetype_name(|| "user.CustomPoints3D".into()) - .or_with_archetype_field_name(|| "confidences".into()), - ) - }), + batch + .or_with_archetype_name(|| "user.CustomPoints3D".into()) + .or_with_archetype_field_name(|| "confidences".into())), ] .into_iter() .flatten(), diff --git a/docs/snippets/snippets.toml b/docs/snippets/snippets.toml index d911b5f21f6c2..fd2cc9c2058ec 100644 --- a/docs/snippets/snippets.toml +++ b/docs/snippets/snippets.toml @@ -235,6 +235,10 @@ quick_start = [ # These examples don't have exactly the same implementation. "py", "rust", ] +"archetypes/points3d_partial_updates" = [ # TODO(cmc): not supported yet + "py", + "cpp", +] "archetypes/points3d_random" = [ # TODO(#3206): examples use different RNGs "cpp", "py", diff --git a/lychee.toml b/lychee.toml index bb97b38fa5ab8..7342caee577e7 100644 --- a/lychee.toml +++ b/lychee.toml @@ -151,5 +151,13 @@ exclude = [ 'https://openaccess.thecvf.com/content/CVPR2023/html/Du_Learning_To_Render_Novel_Views_From_Wide-Baseline_Stereo_Pairs_CVPR_2023_paper.html', 'https://anaconda.org/conda-forge/arrow-cpp', - #'^file:///', # Ignore local file links. They need to be tested, but it's useful for external links we have to ping. + # '^file:///', # Ignore local file links. They need to be tested, but it's useful for external links we have to ping. + + # Snippets that haven't been released yet. + 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.py', + 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.py', + 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.cpp', + 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.cpp', + 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates.rs', + 'https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/points3d_partial_updates_legacy.rs', ]