Skip to content

Commit

Permalink
Add Ellipsoids archetype. (#6853)
Browse files Browse the repository at this point in the history
### 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 <[email protected]>
  • Loading branch information
kpreid and emilk authored Jul 15, 2024
1 parent 7bde9b3 commit 82a47b9
Show file tree
Hide file tree
Showing 40 changed files with 1,694 additions and 2 deletions.
30 changes: 28 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,21 @@ dependencies = [
"wasm-bindgen",
]

[[package]]
name = "const_soft_float"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87ca1caa64ef4ed453e68bb3db612e51cf1b2f5b871337f0fcab1c8f87cc3dff"

[[package]]
name = "constgebra"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1aaf9b65849a68662ac6c0810c8893a765c960b907dd7cfab9c4a50bf764fbc"
dependencies = [
"const_soft_float",
]

[[package]]
name = "convert_case"
version = "0.6.0"
Expand Down Expand Up @@ -2488,6 +2503,16 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"

[[package]]
name = "hexasphere"
version = "14.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c64d70ed6295005e2bc5a6f624300cfd6d49908da76b3654c4cbdb1d4222705"
dependencies = [
"constgebra",
"glam",
]

[[package]]
name = "hexf-parse"
version = "0.2.1"
Expand Down Expand Up @@ -4919,6 +4944,7 @@ dependencies = [
"criterion",
"egui",
"glam",
"hexasphere",
"itertools 0.13.0",
"mimalloc",
"nohash-hasher",
Expand Down Expand Up @@ -6411,9 +6437,9 @@ dependencies = [

[[package]]
name = "target-lexicon"
version = "0.12.15"
version = "0.12.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2"
checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"

[[package]]
name = "tempfile"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ glam = "0.28"
glob = "0.3"
gltf = "1.1"
half = "2.3.1"
hexasphere = "14.0.0"
image = { version = "0.25", default-features = false }
indent = "0.1"
indexmap = "2.1" # Version chosen to align with other dependencies
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/archetypes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include "./archetypes/boxes3d.fbs";
include "./archetypes/clear.fbs";
include "./archetypes/depth_image.fbs";
include "./archetypes/disconnected_space.fbs";
include "./archetypes/ellipsoids.fbs";
include "./archetypes/image.fbs";
include "./archetypes/line_strips2d.fbs";
include "./archetypes/line_strips3d.fbs";
Expand Down
63 changes: 63 additions & 0 deletions crates/store/re_types/definitions/rerun/archetypes/ellipsoids.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
include "fbs/attributes.fbs";
include "rust/attributes.fbs";
include "cpp/attributes.fbs";

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

namespace rerun.archetypes;

// ---

/// 3D ellipsoids or spheres.
///
/// This archetype is for ellipsoids or spheres whose size is a key part of the data
/// (e.g. a bounding sphere).
/// For points whose radii are for the sake of visualization, use `Points3D` instead.
///
/// Currently, ellipsoids are always rendered as wireframes.
/// Opaque and transparent rendering will be supported later.
///
/// \example archetypes/ellipsoid_batch !api title="Batch of ellipsoids"
table Ellipsoids (
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.cpp.no_field_ctors",
"attr.docs.category": "Spatial 3D",
"attr.docs.view_types": "Spatial3DView, Spatial2DView: if logged above active projection"
) {
// --- Required ---

/// For each ellipsoid, half of its size on its three axes.
///
/// If all components are equal, then it is a sphere with that radius.
half_sizes: [rerun.components.HalfSize3D] ("attr.rerun.component_required", order: 1000);

// --- Recommended ---

/// Optional center positions of the ellipsoids.
///
/// If not specified, the centers will be at (0, 0, 0).
centers: [rerun.components.Position3D] ("attr.rerun.component_recommended", nullable, order: 2000);

/// Optional rotations of the ellipsoids.
///
/// If not specified, the axes of the ellipsoid align with the axes of the coordinate system.
rotations: [rerun.components.Rotation3D] ("attr.rerun.component_recommended", nullable, order: 2100);

/// Optional colors for the ellipsoids.
colors: [rerun.components.Color] ("attr.rerun.component_recommended", nullable, order: 2200);

// --- Optional ---

/// Optional radii for the lines used when the ellipsoid is rendered as a wireframe.
line_radii: [rerun.components.Radius] ("attr.rerun.component_optional", nullable, order: 3000);

/// Optional text labels for the ellipsoids.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3100);

/// Optional `ClassId`s for the ellipsoids.
///
/// The class ID provides colors and labels if not specified explicitly.
class_ids: [rerun.components.ClassId] ("attr.rerun.component_optional", nullable, order: 3200);
}
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

0 comments on commit 82a47b9

Please sign in to comment.