Skip to content

Commit

Permalink
Add C++ point3d_ui_radius demo & C++ radius extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Jul 1, 2024
1 parent ce83e0f commit 21aa36f
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 10 deletions.
1 change: 1 addition & 0 deletions crates/re_types/definitions/rerun/archetypes/points3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace rerun.archetypes;
///
/// \example archetypes/point3d_simple !api title="Simple 3D points" image="https://static.rerun.io/point3d_simple/32fb3e9b65bea8bd7ffff95ad839f2f8a157a933/1200w.png"
/// \example archetypes/point3d_random title="Randomly distributed 3D points with varying color and radius" image="https://static.rerun.io/point3d_random/7e94e1806d2c381943748abbb3bedb68d564de24/1200w.png"
/// \example archetypes/point3d_ui_radius title="Log points with radii given in ui points" image="https://static.rerun.io/point3d_ui_radius/e051a65b4317438bcaea8d0eee016ac9460b5336/1200w.png"
table Points3D (
"attr.rust.derive": "PartialEq",
"attr.docs.category": "Spatial 3D",
Expand Down
43 changes: 42 additions & 1 deletion crates/re_types/src/archetypes/points3d.rs

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

12 changes: 12 additions & 0 deletions docs/content/reference/types/archetypes/points3d.md

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

27 changes: 23 additions & 4 deletions docs/snippets/all/archetypes/point3d_ui_radius.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
// Log some very simple points.
// Log some points with ui points & scene unit radii.

#include <rerun.hpp>

int main() {
const auto rec = rerun::RecordingStream("rerun_example_points3d_ui_radius");
rec.spawn().exit_on_failure();

rec.log("points", rerun::Points3D({{0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f}}));
}
// Two blue points with scene unit radii of 0.1 and 0.3.
rec.log(
"scene_unit_points",
rerun::Points3D({{0.0f, 1.0f, 0.0f}, {1.0f, 1.0f, 1.0f}})
// By default, radii are interpreted as world-space units.
.with_radii({0.1f, 0.3f})
.with_colors(rerun::Color(0, 0, 255))
);

// TODO: unfinished
// Two red points with ui point radii of 40 and 60.
// Ui points are independent of zooming in Views, but are sensitive to the application ui scaling.
// For 100% ui scaling, ui points are equal to pixels.
rec.log(
"ui_points_points",
rerun::Points3D({{0.0f, 0.0f, 0.0}, {1.0f, 0.0f, 1.0f}})
// rerun::Radius::ui_points produces radii that the viewer interprets as given in ui points.
.with_radii({
rerun::Radius::ui_points(40.0f),
rerun::Radius::ui_points(60.0f),
})
.with_colors(rerun::Color(255, 0, 0))
);
}
2 changes: 1 addition & 1 deletion docs/snippets/all/archetypes/point3d_ui_radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ui_points_points",
rr.Points3D(
[[0, 0, 0], [1, 0, 1]],
# rr.Radius.ui_points produces radii that the viewer interprets as given in ui units.
# rr.Radius.ui_points produces radii that the viewer interprets as given in ui points.
radii=rr.Radius.ui_points([40.0, 60.0]),
colors=[255, 0, 0],
),
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/archetypes/point3d_ui_radius.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rec.log(
"ui_points_points",
&rerun::Points3D::new([(0.0, 0.0, 0.0), (1.0, 0.0, 1.0)])
// rr.Radius.ui_points produces radii that the viewer interprets as given in ui units.
// rerun::Radius::new_ui_points produces a radius that the viewer interprets as given in ui points.
.with_radii([
rerun::Radius::new_ui_points(40.0),
rerun::Radius::new_ui_points(60.0),
Expand Down
37 changes: 36 additions & 1 deletion rerun_cpp/src/rerun/archetypes/points3d.hpp

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

17 changes: 17 additions & 0 deletions rerun_cpp/src/rerun/components/radius.hpp

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

30 changes: 30 additions & 0 deletions rerun_cpp/src/rerun/components/radius_ext.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//#define EDIT_EXTENSION
#if EDIT_EXTENSION

#include "radius.hpp"

// Uncomment for better auto-complete while editing the extension.

namespace rerun {
namespace components {
// <CODEGEN_COPY_TO_HEADER>

/// Creates a new radius in scene units.
///
/// Values passed must be finite positive.
static Radius scene_units(float radius_in_scene_units) {
return Radius(radius_in_scene_units);
}

/// Creates a new radius in ui points.
///
/// Values passed must be finite positive.
static Radius ui_points(float radius_in_ui_points) {
return Radius(-radius_in_ui_points);
}

// </CODEGEN_COPY_TO_HEADER>
} // namespace components
} // namespace rerun

#endif
44 changes: 42 additions & 2 deletions rerun_py/rerun_sdk/rerun/archetypes/points3d.py

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

0 comments on commit 21aa36f

Please sign in to comment.