Skip to content

Commit

Permalink
Use log_static() for constant data in DNA example. (#7701)
Browse files Browse the repository at this point in the history
### What

Just a tiny little thing that was bugging me: the DNA example now uses
`log_static()` for all the non-animated data logged at the beginning.
This gives better results when viewing with a time range query
— otherwise the `left`, `right`, and `scaffolding` always disappear if
the time range doesn’t include the beginning of the recording.

Here is the new appearance with a 0.5 second time range; previously,
only the gray points would be visible:


![Screenshot](https://github.com/user-attachments/assets/9880584d-94a7-43eb-acd6-d4e517a45625)

### 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/7701?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/7701?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/7701)
- [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 Nov 15, 2024
1 parent 9e46657 commit bb092e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions examples/cpp/dna/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ int main() {

rec.set_time("stable_time", 0s);

rec.log(
rec.log_static(
"dna/structure/left",
rerun::Points3D(points1).with_colors(colors1).with_radii({0.08f})
);
rec.log(
rec.log_static(
"dna/structure/right",
rerun::Points3D(points2).with_colors(colors2).with_radii({0.08f})
);
Expand All @@ -35,7 +35,7 @@ int main() {
lines.emplace_back(rerun::LineStrip3D({points1[i].xyz, points2[i].xyz}));
}

rec.log(
rec.log_static(
"dna/structure/scaffolding",
rerun::LineStrips3D(lines).with_colors(rerun::Color(128, 128, 128))
);
Expand Down
12 changes: 8 additions & 4 deletions examples/python/dna/dna.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ def log_data() -> None:
# points and colors are both np.array((NUM_POINTS, 3))
points1, colors1 = build_color_spiral(NUM_POINTS)
points2, colors2 = build_color_spiral(NUM_POINTS, angular_offset=tau * 0.5)
rr.log("helix/structure/left", rr.Points3D(points1, colors=colors1, radii=0.08))
rr.log("helix/structure/right", rr.Points3D(points2, colors=colors2, radii=0.08))

rr.log("helix/structure/scaffolding", rr.LineStrips3D(np.stack((points1, points2), axis=1), colors=[128, 128, 128]))
rr.log("helix/structure/left", rr.Points3D(points1, colors=colors1, radii=0.08), static=True)
rr.log("helix/structure/right", rr.Points3D(points2, colors=colors2, radii=0.08), static=True)

rr.log(
"helix/structure/scaffolding",
rr.LineStrips3D(np.stack((points1, points2), axis=1), colors=[128, 128, 128]),
static=True,
)

time_offsets = np.random.rand(NUM_POINTS)
for i in range(400):
Expand Down
6 changes: 3 additions & 3 deletions examples/rust/dna/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

rec.set_time_seconds("stable_time", 0f64);

rec.log(
rec.log_static(
"dna/structure/left",
&rerun::Points3D::new(points1.iter().copied())
.with_colors(colors1)
.with_radii([0.08]),
)?;
rec.log(
rec.log_static(
"dna/structure/right",
&rerun::Points3D::new(points2.iter().copied())
.with_colors(colors2)
Expand All @@ -40,7 +40,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.map(|chunk| chunk.into_iter().collect_vec().try_into().unwrap())
.collect_vec();

rec.log(
rec.log_static(
"dna/structure/scaffolding",
&rerun::LineStrips3D::new(points_interleaved.iter().cloned())
.with_colors([rerun::Color::from([128, 128, 128, 255])]),
Expand Down

0 comments on commit bb092e5

Please sign in to comment.