Skip to content

Commit

Permalink
Add optional solid/filled (triangle mesh) rendering to Boxes3D and …
Browse files Browse the repository at this point in the history
…`Ellipsoids`. (#6953)

### What

With these changes, `Boxes3D` and `Ellipsoids` can now be viewed as
solid objects. This is part of the work on #1361 and the mechanisms
added here will generalize to other shapes.

* Add new component type `SolidColor`. This is identical to `Color`
except that, on shapes where it applies, it sets the color of surfaces
instead of lines. Whether its color is transparent controls whether the
surfaces are drawn at all.
* Add `SolidColor` to the `Boxes3D` and `Ellipsoids` archetypes.
* Add support for solid colors to those archetypes’ visualizers.
* Add `proc_mesh::SolidCache` to cache the calculation of triangle
meshes.
* Add `proc_mesh::ProcMeshKey::Cube` to allow the cached mech mechanism
to generate solid cubes.

![Screenshot 2024-07-20 at 17 36
01](https://github.com/user-attachments/assets/ab6b2d1b-20d0-471c-ba49-25d4e10638ea)
![Screenshot 2024-07-20 at 17 35
12](https://github.com/user-attachments/assets/2d6ce740-5bd5-4475-a018-4d286adf2c5b)

Future work (things this PR *doesn't* do):

* Viewer UI needs a version of the color picker that lets you pick
"fully transparent".
* The line renderer does not play well with adjacent faces, causing line
width to be halved some of the time. This could be fixed with something
like #6508, simple depth offsets, or something else.
* Getting naming and semantics right:
* Should the `colors` of `Boxes3D` be renamed `line_colors`, or
something like that? I think so, but that would be a breaking change, so
I didn't in this PR.
    * Should `Color` be renamed?
* Should there be all 3 of `SolidColor`, LineColor`, and `Color` with
some override policy between them?
    * Should `SolidColor` be called `SurfaceColor` instead?
    * How should `SolidColor` interact with annotation contexts?
* Figure out whether instanced meshes are the right choice for
performance.

### 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 the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6953?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/6953?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
* The `Ellipsoids` archetype has a renamed field but that isn't released
yet, so doesn't need noting.

- [PR Build Summary](https://build.rerun.io/pr/6953)
- [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: Andreas Reich <[email protected]>
  • Loading branch information
kpreid and Wumpf authored Jul 24, 2024
1 parent 03b854d commit 44dc619
Show file tree
Hide file tree
Showing 44 changed files with 1,084 additions and 104 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/contrib_rerun_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ jobs:
pixi-version: v0.25.0
environments: wheel-test-min

- name: Run Python unit-tests
run: pixi run -e wheel-test-min py-test

- name: Run e2e test
run: pixi run -e wheel-test-min RUST_LOG=debug scripts/run_python_e2e_test.py --no-build # rerun-sdk is already built and installed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ table Boxes3D (
/// Optional radii for the lines that make up the boxes.
radii: [rerun.components.Radius] ("attr.rerun.component_optional", nullable, order: 3000);

/// Optionally choose whether the boxes are drawn with lines or solid.
fill_mode: rerun.components.FillMode ("attr.rerun.component_optional", nullable, order: 3100);

/// Optional text labels for the boxes.
///
/// If there's a single label present, it will be placed at the center of the entity.
/// Otherwise, each instance will have its own label.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3100);
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3200);

/// Optional [components.ClassId]s for the boxes.
///
/// The [components.ClassId] provides colors and labels if not specified explicitly.
class_ids: [rerun.components.ClassId] ("attr.rerun.component_optional", nullable, order: 3200);
class_ids: [rerun.components.ClassId] ("attr.rerun.component_optional", nullable, order: 3300);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ table Ellipsoids (
/// 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);

/// Optionally choose whether the ellipsoids are drawn with lines or solid.
fill_mode: rerun.components.FillMode ("attr.rerun.component_optional", nullable, order: 3100);

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

/// 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);
class_ids: [rerun.components.ClassId] ("attr.rerun.component_optional", nullable, order: 3300);
}
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/components.fbs

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

16 changes: 16 additions & 0 deletions crates/store/re_types/definitions/rerun/components/fill_mode.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace rerun.components;

/// How a geometric shape is drawn and colored.
enum FillMode: byte(
"attr.docs.unreleased"
) {
/// Lines are drawn around the edges of the shape.
///
/// The interior (2D) or surface (3D) are not drawn.
Wireframe (default),

/// The interior (2D) or surface (3D) is filled with a single color.
///
/// Lines are not drawn.
Solid,
}
37 changes: 33 additions & 4 deletions crates/store/re_types/src/archetypes/boxes3d.rs

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

36 changes: 32 additions & 4 deletions crates/store/re_types/src/archetypes/ellipsoids.rs

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

1 change: 1 addition & 0 deletions crates/store/re_types/src/components/.gitattributes

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

Loading

0 comments on commit 44dc619

Please sign in to comment.