Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rerun 0.21 #5

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
732 changes: 658 additions & 74 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]


[dependencies]
rerun = { version = "0.20", default-features = false, features = [
rerun = { version = "0.21.0", default-features = false, features = [
"sdk",
"image",
"glam",
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ https://github.com/rerun-io/revy/assets/2910679/cd096cbe-5e68-4acf-8010-e6c32c55

## Examples

|[Breakout](https://github.com/rerun-io/revy/blob/0.20.0/examples/breakout.rs#L69-L82)|[3D shapes](https://github.com/rerun-io/revy/blob/0.20.0/examples/3d_shapes.rs#L41-L54)|[Alien Cake Addict](https://github.com/rerun-io/revy/blob/0.20.0/examples/alien_cake_addict.rs#L39-L52)|
|[Breakout](https://github.com/rerun-io/revy/blob/0.21.0/examples/breakout.rs#L69-L82)|[3D shapes](https://github.com/rerun-io/revy/blob/0.21.0/examples/3d_shapes.rs#L41-L54)|[Alien Cake Addict](https://github.com/rerun-io/revy/blob/0.21.0/examples/alien_cake_addict.rs#L39-L52)|
| :----------------------------------------------------------------: | :-------------------------------------------------------------: | :--------------------------------------------------------------: |
| [*Live demo*](https://rerun.io/viewer/version/0.20.0/?url=https://static.rerun.io/rrd/0.20.0/revy_breakout_3572dc5d61f77dc4fc9675a85c74035a6ee4b020.rrd) | [*Live demo*](https://rerun.io/viewer/version/0.20.0/?url=https://static.rerun.io/rrd/0.20.0/revy_3d_shapes_146ceeb1ab6e9bb69df6e3a39df6243579ed4f1d.rrd) | [*Live demo*](https://rerun.io/viewer/version/0.20.0/?url=https://static.rerun.io/rrd/0.20.0/revy_alien_cake_addict_cadb9e027130bade64c9d9352073fc7240dfc238.rrd) |
| [*Live demo*](https://rerun.io/viewer/version/0.21.0/?url=https://static.rerun.io/rrd/0.20.0/revy_breakout_3572dc5d61f77dc4fc9675a85c74035a6ee4b020.rrd) | [*Live demo*](https://rerun.io/viewer/version/0.21.0/?url=https://static.rerun.io/rrd/0.20.0/revy_3d_shapes_146ceeb1ab6e9bb69df6e3a39df6243579ed4f1d.rrd) | [*Live demo*](https://rerun.io/viewer/version/0.21.0/?url=https://static.rerun.io/rrd/0.20.0/revy_alien_cake_addict_cadb9e027130bade64c9d9352073fc7240dfc238.rrd) |
| <picture><img src="https://static.rerun.io/revy_breakout/de578dd0aee06c6ac2260da302b5e02ee4fdcdad/full.png" alt=""><source media="(max-width: 480px)" srcset="https://static.rerun.io/revy_breakout/de578dd0aee06c6ac2260da302b5e02ee4fdcdad/480w.png"><source media="(max-width: 768px)" srcset="https://static.rerun.io/revy_breakout/de578dd0aee06c6ac2260da302b5e02ee4fdcdad/768w.png"><source media="(max-width: 1024px)" srcset="https://static.rerun.io/revy_breakout/de578dd0aee06c6ac2260da302b5e02ee4fdcdad/1024w.png"><source media="(max-width: 1200px)" srcset="https://static.rerun.io/revy_breakout/de578dd0aee06c6ac2260da302b5e02ee4fdcdad/1200w.png"></picture> | <picture><img src="https://static.rerun.io/revy_3d_shapes/28870c94c4ffec871916890d8eaa8661da1b364e/full.png" alt=""><source media="(max-width: 480px)" srcset="https://static.rerun.io/revy_3d_shapes/28870c94c4ffec871916890d8eaa8661da1b364e/480w.png"><source media="(max-width: 768px)" srcset="https://static.rerun.io/revy_3d_shapes/28870c94c4ffec871916890d8eaa8661da1b364e/768w.png"><source media="(max-width: 1024px)" srcset="https://static.rerun.io/revy_3d_shapes/28870c94c4ffec871916890d8eaa8661da1b364e/1024w.png"><source media="(max-width: 1200px)" srcset="https://static.rerun.io/revy_3d_shapes/28870c94c4ffec871916890d8eaa8661da1b364e/1200w.png"></picture> |<picture><img src="https://static.rerun.io/revy_alien_cake_addict/8c6f1828dec207f86a887d1b180e9d92b38b4523/full.png" alt=""><source media="(max-width: 480px)" srcset="https://static.rerun.io/revy_alien_cake_addict/8c6f1828dec207f86a887d1b180e9d92b38b4523/480w.png"><source media="(max-width: 768px)" srcset="https://static.rerun.io/revy_alien_cake_addict/8c6f1828dec207f86a887d1b180e9d92b38b4523/768w.png"><source media="(max-width: 1024px)" srcset="https://static.rerun.io/revy_alien_cake_addict/8c6f1828dec207f86a887d1b180e9d92b38b4523/1024w.png"><source media="(max-width: 1200px)" srcset="https://static.rerun.io/revy_alien_cake_addict/8c6f1828dec207f86a887d1b180e9d92b38b4523/1200w.png"></picture> |

---
Expand All @@ -36,11 +36,11 @@ https://github.com/rerun-io/revy/assets/2910679/cd096cbe-5e68-4acf-8010-e6c32c55

## Usage

1. [Install the Rerun Viewer](https://www.rerun.io/docs/getting-started/installing-viewer) (`0.20`).
1. [Install the Rerun Viewer](https://www.rerun.io/docs/getting-started/installing-viewer) (`0.21`).

2. Add `revy` to your dependencies:
```toml
revy = "0.20" # always matches the rerun version
revy = "0.21" # always matches the rerun version
```

3. Initialize the `rerun` plugin:
Expand Down Expand Up @@ -105,3 +105,4 @@ You can also register your own custom loggers by inserting a `RerunComponentLogg
| [0.13](https://github.com/bevyengine/bevy/releases/tag/v0.13.0) | [0.16](https://github.com/rerun-io/revy/releases/tag/0.16.0) | [0.16](https://github.com/rerun-io/rerun/releases/tag/0.16.0) |
| [0.14](https://github.com/bevyengine/bevy/releases/tag/v0.14.0) | [0.17](https://github.com/rerun-io/revy/releases/tag/0.17.0) | [0.17](https://github.com/rerun-io/rerun/releases/tag/0.17.0) |
| [0.15](https://github.com/bevyengine/bevy/releases/tag/v0.15.0) | [0.20](https://github.com/rerun-io/revy/releases/tag/0.20.0) | [0.20](https://github.com/rerun-io/rerun/releases/tag/0.20.0) |
| [0.15](https://github.com/bevyengine/bevy/releases/tag/v0.15.0) | [0.21](https://github.com/rerun-io/revy/releases/tag/0.21.0) | [0.21](https://github.com/rerun-io/rerun/releases/tag/0.21.0) |
4 changes: 3 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ skip-tree = [
"event-listener",
"fixedbitset", # Bevy has internally several versions
"glam", # Rerun is behind versus Bevy
"indexmap",
"itertools",
"libloading",
"nix",
Expand All @@ -56,9 +57,10 @@ skip-tree = [
"regex-automata",
"regex-syntax",
"sysinfo", # rerun depends on 0.30, bevy on 0.32
"tower",
"ttf-parser", # cosmic-text 0.12.1 depends on one version directly and on another one via fontdb 0.16.2
"windows-sys",
"windows",
"windows-sys",
]


Expand Down
8 changes: 4 additions & 4 deletions src/default_loggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy::{
utils::HashMap,
};

use crate::{compute_entity_path, rerun_logger::ManyAsComponents, Aliased, RerunLogger, ToRerun};
use crate::{compute_entity_path, Aliased, RerunLogger, ToRerun};

// ---

Expand Down Expand Up @@ -108,11 +108,11 @@ fn bevy_global_transform<'w>(
// TODO(cmc): once again the DataUi does the wrong thing... we really need to
// go typeless.
let data = entity.get::<GlobalTransform>().map(|transform| {
Box::new(ManyAsComponents(vec![
Box::new(vec![
Box::new(Aliased::<rerun::datatypes::Vec3D>::new(
"GlobalTransform3D.translation",
transform.translation().to_rerun(),
)),
)) as Box<dyn rerun::AsComponents>,
Box::new(Aliased::<rerun::datatypes::Quaternion>::new(
"GlobalTransform3D.rotation",
transform.rotation().to_rerun(),
Expand All @@ -121,7 +121,7 @@ fn bevy_global_transform<'w>(
"GlobalTransform3D.scale",
transform.scale().to_rerun(),
)),
])) as _
]) as _
});

(suffix, data)
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(rustdoc::bare_urls)]
#![allow(clippy::doc_markdown)]
#![doc = include_str!("../README.md")]

use bevy::prelude::*;
Expand Down
40 changes: 11 additions & 29 deletions src/rerun_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,56 +191,38 @@ use rerun::external::{arrow2, re_types_core};
/// Helper to log any [`rerun::LoggableBatch`] as a [`rerun::Component`] with the specified name.
#[derive(Debug)]
pub struct Aliased<C: rerun::LoggableBatch> {
name: rerun::ComponentName,
descriptor: rerun::ComponentDescriptor,
data: C,
}

impl<C: rerun::LoggableBatch> Aliased<C> {
pub fn new(name: impl Into<rerun::ComponentName>, data: impl Into<C>) -> Self {
Self {
name: name.into(),
descriptor: rerun::ComponentDescriptor::new(name.into()),
data: data.into(),
}
}
}

impl<C: rerun::LoggableBatch> rerun::AsComponents for Aliased<C> {
#[inline]
fn as_component_batches(&self) -> Vec<rerun::MaybeOwnedComponentBatch<'_>> {
vec![rerun::MaybeOwnedComponentBatch::Ref(self)]
fn as_component_batches(&self) -> Vec<rerun::ComponentBatchCowWithDescriptor<'_>> {
vec![rerun::ComponentBatchCowWithDescriptor::new(
self as &dyn rerun::ComponentBatch,
)]
}
}

impl<C: rerun::LoggableBatch> rerun::LoggableBatch for Aliased<C> {
type Name = rerun::ComponentName;

#[inline]
fn name(&self) -> Self::Name {
self.name
}

#[inline]
fn to_arrow(&self) -> re_types_core::SerializationResult<Box<dyn arrow2::array::Array>> {
self.data.to_arrow()
fn to_arrow2(&self) -> re_types_core::SerializationResult<Box<dyn arrow2::array::Array>> {
self.data.to_arrow2()
}
}

impl<C: rerun::LoggableBatch> rerun::ComponentBatch for Aliased<C> {}

// ---

// TODO(cmc): Rerun should provide tools for this.

/// Helper to merge any number of [`rerun::AsComponents`].
#[allow(dead_code)]
pub struct ManyAsComponents(pub Vec<Box<dyn rerun::AsComponents>>);

impl rerun::AsComponents for ManyAsComponents {
impl<C: rerun::LoggableBatch> rerun::ComponentBatch for Aliased<C> {
#[inline]
fn as_component_batches(&self) -> Vec<rerun::MaybeOwnedComponentBatch<'_>> {
self.0
.iter()
.flat_map(|data| data.as_component_batches())
.collect()
fn descriptor(&self) -> std::borrow::Cow<'_, rerun::ComponentDescriptor> {
std::borrow::Cow::Borrowed(&self.descriptor)
}
}
13 changes: 8 additions & 5 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ fn sync_components(

for batches in &component_batches {
for batch in batches {
current_components.insert(batch.name(), entity_path.clone());
current_components.insert(
rerun::ComponentBatch::descriptor(batch).into_owned(),
entity_path.clone(),
);
}
}

Expand All @@ -235,7 +238,7 @@ fn sync_components(
component_batches
.iter()
.flatten()
.map(|batch| batch.as_ref()),
.map(|batch| batch as &dyn rerun::ComponentBatch),
)
.ok_or_log_error();
}
Expand All @@ -245,8 +248,8 @@ fn sync_components(
.get::<CurrentComponents>()
.unwrap_or(&empty_components);

for (component_name, entity_path) in last_components.iter() {
if !current_components.contains_key(component_name) {
for (component_desc, entity_path) in last_components.iter() {
if !current_components.contains_key(component_desc) {
rec.log(entity_path.clone(), &rerun::Clear::flat())
.ok_or_log_error();
}
Expand Down Expand Up @@ -323,4 +326,4 @@ struct CurrentHashes(HashMap<ComponentId, u64>);

/// Keeps track of all components on an entity in order to `Clear` removed ones.
#[derive(Component, Debug, Clone, Default, Deref, DerefMut)]
struct CurrentComponents(HashMap<rerun::ComponentName, rerun::EntityPath>);
struct CurrentComponents(HashMap<rerun::ComponentDescriptor, rerun::EntityPath>);
Loading