Skip to content

Commit 82a47b9

Browse files
kpreidemilk
andauthored
Add Ellipsoids archetype. (#6853)
### What Implement an `Ellipsoids` archetype and visualizer. This may be used to render ellipsoids, or spheres where `Points3D` is unsuitable because the actual boundary in space is significant. It is intended as a first step towards completing #1361, by adding ellipsoids and by sketching out a general mechanism for rendering procedurally-generated shapes, which will be reusable for cylinders and anything which needs many vertices to render. The archetype, extensions, etc. are largely forked off of `Boxes3d`. Unfinished parts / future work: * Currently, the spheres are always drawn as wireframes (with an automatically chosen mesh subdivision level). We will want to also support solid rendering (i.e. triangles in place of lines), but many use cases for spheres might want them to be transparent, which isn't yet properly supported in 3D space views (#702), so I chose wireframe as the first version. * Currently, all of the wireframe lines are piped through the `LineDrawableBuilder` every frame. Instead, they should be drawn as instanced meshes; that will require implementing a new renderer that invokes the existing line shader with the different data layout. However, this current implementation should not be worse than if the user were to create a similar number of lines directly. * The sphere mesh needs a choice of subdivision level. Currently, it is automatically derived from the size of the sphere in the scene, which may be inappropriate depending on the scale of scene units or the specific application. I'd like feedback on the best way to handle this. Just add another component, perhaps kind of like the `Radius` component? * I‘m not sure what the best way to handle the (future) errors in generating meshes is. Should it return a `SpaceViewSystemExecutionError` (which hides unrelated data), just draw nothing and continue (which could lead to silent missing data), or something else? ![rerun_example_ellipsoid_batch](https://github.com/rerun-io/rerun/assets/779501/5ad90a6e-720d-44b0-883d-e3213777345e) ### 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) * [ ] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6853?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/6853?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/6853) - [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`. --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
1 parent 7bde9b3 commit 82a47b9

40 files changed

+1694
-2
lines changed

Cargo.lock

+28-2
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,21 @@ dependencies = [
11771177
"wasm-bindgen",
11781178
]
11791179

1180+
[[package]]
1181+
name = "const_soft_float"
1182+
version = "0.1.4"
1183+
source = "registry+https://github.com/rust-lang/crates.io-index"
1184+
checksum = "87ca1caa64ef4ed453e68bb3db612e51cf1b2f5b871337f0fcab1c8f87cc3dff"
1185+
1186+
[[package]]
1187+
name = "constgebra"
1188+
version = "0.1.4"
1189+
source = "registry+https://github.com/rust-lang/crates.io-index"
1190+
checksum = "e1aaf9b65849a68662ac6c0810c8893a765c960b907dd7cfab9c4a50bf764fbc"
1191+
dependencies = [
1192+
"const_soft_float",
1193+
]
1194+
11801195
[[package]]
11811196
name = "convert_case"
11821197
version = "0.6.0"
@@ -2488,6 +2503,16 @@ version = "0.4.3"
24882503
source = "registry+https://github.com/rust-lang/crates.io-index"
24892504
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
24902505

2506+
[[package]]
2507+
name = "hexasphere"
2508+
version = "14.0.0"
2509+
source = "registry+https://github.com/rust-lang/crates.io-index"
2510+
checksum = "6c64d70ed6295005e2bc5a6f624300cfd6d49908da76b3654c4cbdb1d4222705"
2511+
dependencies = [
2512+
"constgebra",
2513+
"glam",
2514+
]
2515+
24912516
[[package]]
24922517
name = "hexf-parse"
24932518
version = "0.2.1"
@@ -4919,6 +4944,7 @@ dependencies = [
49194944
"criterion",
49204945
"egui",
49214946
"glam",
4947+
"hexasphere",
49224948
"itertools 0.13.0",
49234949
"mimalloc",
49244950
"nohash-hasher",
@@ -6411,9 +6437,9 @@ dependencies = [
64116437

64126438
[[package]]
64136439
name = "target-lexicon"
6414-
version = "0.12.15"
6440+
version = "0.12.14"
64156441
source = "registry+https://github.com/rust-lang/crates.io-index"
6416-
checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2"
6442+
checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
64176443

64186444
[[package]]
64196445
name = "tempfile"

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ glam = "0.28"
172172
glob = "0.3"
173173
gltf = "1.1"
174174
half = "2.3.1"
175+
hexasphere = "14.0.0"
175176
image = { version = "0.25", default-features = false }
176177
indent = "0.1"
177178
indexmap = "2.1" # Version chosen to align with other dependencies

crates/store/re_types/definitions/rerun/archetypes.fbs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include "./archetypes/boxes3d.fbs";
88
include "./archetypes/clear.fbs";
99
include "./archetypes/depth_image.fbs";
1010
include "./archetypes/disconnected_space.fbs";
11+
include "./archetypes/ellipsoids.fbs";
1112
include "./archetypes/image.fbs";
1213
include "./archetypes/line_strips2d.fbs";
1314
include "./archetypes/line_strips3d.fbs";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
include "fbs/attributes.fbs";
2+
include "rust/attributes.fbs";
3+
include "cpp/attributes.fbs";
4+
5+
include "rerun/datatypes.fbs";
6+
include "rerun/components.fbs";
7+
8+
namespace rerun.archetypes;
9+
10+
// ---
11+
12+
/// 3D ellipsoids or spheres.
13+
///
14+
/// This archetype is for ellipsoids or spheres whose size is a key part of the data
15+
/// (e.g. a bounding sphere).
16+
/// For points whose radii are for the sake of visualization, use `Points3D` instead.
17+
///
18+
/// Currently, ellipsoids are always rendered as wireframes.
19+
/// Opaque and transparent rendering will be supported later.
20+
///
21+
/// \example archetypes/ellipsoid_batch !api title="Batch of ellipsoids"
22+
table Ellipsoids (
23+
"attr.rust.derive": "PartialEq",
24+
"attr.rust.new_pub_crate",
25+
"attr.cpp.no_field_ctors",
26+
"attr.docs.category": "Spatial 3D",
27+
"attr.docs.view_types": "Spatial3DView, Spatial2DView: if logged above active projection"
28+
) {
29+
// --- Required ---
30+
31+
/// For each ellipsoid, half of its size on its three axes.
32+
///
33+
/// If all components are equal, then it is a sphere with that radius.
34+
half_sizes: [rerun.components.HalfSize3D] ("attr.rerun.component_required", order: 1000);
35+
36+
// --- Recommended ---
37+
38+
/// Optional center positions of the ellipsoids.
39+
///
40+
/// If not specified, the centers will be at (0, 0, 0).
41+
centers: [rerun.components.Position3D] ("attr.rerun.component_recommended", nullable, order: 2000);
42+
43+
/// Optional rotations of the ellipsoids.
44+
///
45+
/// If not specified, the axes of the ellipsoid align with the axes of the coordinate system.
46+
rotations: [rerun.components.Rotation3D] ("attr.rerun.component_recommended", nullable, order: 2100);
47+
48+
/// Optional colors for the ellipsoids.
49+
colors: [rerun.components.Color] ("attr.rerun.component_recommended", nullable, order: 2200);
50+
51+
// --- Optional ---
52+
53+
/// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
54+
line_radii: [rerun.components.Radius] ("attr.rerun.component_optional", nullable, order: 3000);
55+
56+
/// Optional text labels for the ellipsoids.
57+
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3100);
58+
59+
/// Optional `ClassId`s for the ellipsoids.
60+
///
61+
/// The class ID provides colors and labels if not specified explicitly.
62+
class_ids: [rerun.components.ClassId] ("attr.rerun.component_optional", nullable, order: 3200);
63+
}

crates/store/re_types/src/archetypes/.gitattributes

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)