Skip to content

Commit 0c4c5df

Browse files
WumpfCopilot
andauthored
Move transform processing modules into new, viewer-independent re_tf crate (#11409)
Co-authored-by: Copilot <[email protected]>
1 parent 38023e9 commit 0c4c5df

File tree

18 files changed

+700
-624
lines changed

18 files changed

+700
-624
lines changed

ARCHITECTURE.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ Of course, this will only take us so far. In the future we plan on caching queri
9898
Here is an overview of the crates included in the project:
9999

100100
<picture>
101-
<img src="https://static.rerun.io/crates/bfe6853639d2427dd424e529b5d70950e2f61840/full.png" alt="">
102-
<source media="(max-width: 480px)" srcset="https://static.rerun.io/crates/bfe6853639d2427dd424e529b5d70950e2f61840/480w.png">
103-
<source media="(max-width: 768px)" srcset="https://static.rerun.io/crates/bfe6853639d2427dd424e529b5d70950e2f61840/768w.png">
104-
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/crates/bfe6853639d2427dd424e529b5d70950e2f61840/1024w.png">
105-
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/crates/bfe6853639d2427dd424e529b5d70950e2f61840/1200w.png">
101+
<img src="https://static.rerun.io/crates/c4945bdef6cdcf99bf37a05480d19be23bfd2b7f/full.png" alt="">
102+
<source media="(max-width: 480px)" srcset="https://static.rerun.io/crates/c4945bdef6cdcf99bf37a05480d19be23bfd2b7f/480w.png">
103+
<source media="(max-width: 768px)" srcset="https://static.rerun.io/crates/c4945bdef6cdcf99bf37a05480d19be23bfd2b7f/768w.png">
104+
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/crates/c4945bdef6cdcf99bf37a05480d19be23bfd2b7f/1024w.png">
105+
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/crates/c4945bdef6cdcf99bf37a05480d19be23bfd2b7f/1200w.png">
106106
</picture>
107107

108108
<!-- !!! IMPORTANT!!!
@@ -180,6 +180,7 @@ Update instructions:
180180
| re_protos | Rerun remote store gRPC API types |
181181
| re_query | Querying data in the re_chunk_store |
182182
| re_server | In-memory data server |
183+
| re_tf | Dealing with spatial transforms & transform frames |
183184
| re_types | The built-in Rerun data types, component types, and archetypes. |
184185

185186
### Low-level store

Cargo.lock

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9500,6 +9500,24 @@ dependencies = [
95009500
"re_viewport_blueprint",
95019501
]
95029502

9503+
[[package]]
9504+
name = "re_tf"
9505+
version = "0.26.0-alpha.1+dev"
9506+
dependencies = [
9507+
"ahash",
9508+
"bitflags 2.9.1",
9509+
"glam",
9510+
"itertools 0.14.0",
9511+
"nohash-hasher",
9512+
"re_chunk_store",
9513+
"re_entity_db",
9514+
"re_log",
9515+
"re_log_types",
9516+
"re_tracing",
9517+
"re_types",
9518+
"vec1",
9519+
]
9520+
95039521
[[package]]
95049522
name = "re_time_panel"
95059523
version = "0.26.0-alpha.1+dev"
@@ -9897,6 +9915,7 @@ dependencies = [
98979915
"re_renderer",
98989916
"re_test_context",
98999917
"re_test_viewport",
9918+
"re_tf",
99009919
"re_tracing",
99019920
"re_types",
99029921
"re_ui",
@@ -9907,7 +9926,6 @@ dependencies = [
99079926
"serde",
99089927
"smallvec",
99099928
"thiserror 1.0.69",
9910-
"vec1",
99119929
"web-time",
99129930
]
99139931

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ re_dataframe = { path = "crates/store/re_dataframe", version = "=0.26.0-alpha.1"
7272
re_datafusion = { path = "crates/store/re_datafusion", version = "=0.26.0-alpha.1", default-features = false }
7373
re_entity_db = { path = "crates/store/re_entity_db", version = "=0.26.0-alpha.1", default-features = false }
7474
re_format_arrow = { path = "crates/store/re_format_arrow", version = "=0.26.0-alpha.1", default-features = false }
75-
re_redap_client = { path = "crates/store/re_redap_client", version = "=0.26.0-alpha.1", default-features = false }
7675
re_grpc_client = { path = "crates/store/re_grpc_client", version = "=0.26.0-alpha.1", default-features = false }
7776
re_grpc_server = { path = "crates/store/re_grpc_server", version = "=0.26.0-alpha.1", default-features = false }
78-
re_protos = { path = "crates/store/re_protos", version = "=0.26.0-alpha.1", default-features = false }
7977
re_log_encoding = { path = "crates/store/re_log_encoding", version = "=0.26.0-alpha.1", default-features = false }
8078
re_log_types = { path = "crates/store/re_log_types", version = "=0.26.0-alpha.1", default-features = false }
79+
re_protos = { path = "crates/store/re_protos", version = "=0.26.0-alpha.1", default-features = false }
8180
re_query = { path = "crates/store/re_query", version = "=0.26.0-alpha.1", default-features = false }
81+
re_redap_client = { path = "crates/store/re_redap_client", version = "=0.26.0-alpha.1", default-features = false }
8282
re_server = { path = "crates/store/re_server", version = "=0.26.0-alpha.1", default-features = false }
8383
re_sorbet = { path = "crates/store/re_sorbet", version = "=0.26.0-alpha.1", default-features = false }
84+
re_tf = { path = "crates/store/re_tf", version = "=0.26.0-alpha.1", default-features = false }
8485
re_types = { path = "crates/store/re_types", version = "=0.26.0-alpha.1", default-features = false }
8586
re_types_core = { path = "crates/store/re_types_core", version = "=0.26.0-alpha.1", default-features = false }
8687

crates/store/re_tf/Cargo.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[package]
2+
name = "re_tf"
3+
authors.workspace = true
4+
description = "Rerun spatial transform processing"
5+
edition.workspace = true
6+
homepage.workspace = true
7+
include.workspace = true
8+
license.workspace = true
9+
publish = true
10+
readme = "README.md"
11+
repository.workspace = true
12+
rust-version.workspace = true
13+
version.workspace = true
14+
15+
[lints]
16+
workspace = true
17+
18+
[package.metadata.docs.rs]
19+
all-features = true
20+
21+
22+
[dependencies]
23+
re_chunk_store.workspace = true
24+
re_entity_db.workspace = true # It would be nice not to depend on this, but we need this in order to do queries right now.
25+
re_log_types.workspace = true
26+
re_log.workspace = true
27+
re_tracing.workspace = true
28+
re_types = { workspace = true, features = ["glam"] }
29+
30+
ahash.workspace = true
31+
bitflags.workspace = true
32+
glam.workspace = true
33+
itertools.workspace = true
34+
nohash-hasher.workspace = true
35+
vec1 = { workspace = true, features = ["smallvec-v1"] }

crates/store/re_tf/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# re_tf
2+
3+
Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates.
4+
5+
[![Latest version](https://img.shields.io/crates/v/re_tf.svg#speculative-link)](https://crates.io/crates/store/re_tf#speculative-link)
6+
[![Documentation](https://docs.rs/re_tf/badge.svg#speculative-link)](https://docs.rs/re_tf#speculative-link)
7+
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
8+
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)
9+
10+
Rerun's spatial transform processing.
11+
12+
Responsible for collecting Rerun compliant spatial transform data & processing them for higher level transform related queries.
13+
This crate encapsulates a lot of the rules underpinning transform related datastructures defined in `re_types`.
14+
15+
Maintains time dependent topological data structures that allow resolving affine transformations between different transform frames (points of reference).
16+
17+
The name is borrowed from ROS's popular [`tf`](https://wiki.ros.org/tf) package as it plays a similar role.

crates/store/re_tf/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Rerun spatial transform processing
2+
3+
mod transform_cache;
4+
mod transform_tree;
5+
6+
pub use transform_cache::{
7+
CachedTransformsForTimeline, PoseTransformArchetypeMap, ResolvedPinholeProjection,
8+
TransformCacheStoreSubscriber, query_view_coordinates,
9+
query_view_coordinates_at_closest_ancestor,
10+
};
11+
pub use transform_tree::{TransformInfo, TransformTree, TwoDInThreeDTransformInfo};
12+
13+
/// Returns the view coordinates used for 2D (image) views.
14+
///
15+
/// TODO(#1387): Image coordinate space should be configurable.
16+
pub fn image_view_coordinates() -> re_types::components::ViewCoordinates {
17+
re_types::archetypes::Pinhole::DEFAULT_CAMERA_XYZ
18+
}

crates/viewer/re_view_spatial/src/transform_cache.rs renamed to crates/store/re_tf/src/transform_cache.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ use vec1::smallvec_v1::SmallVec1;
2323
/// Store subscriber that resolves all transform components at a given entity to an affine transform.
2424
///
2525
/// It only handles resulting transforms individually to each entity, not how these transforms propagate in the tree.
26-
/// For transform tree propagation see [`crate::contexts::TransformTreeContext`].
26+
/// For transform tree propagation see [`crate::TransformTree`].
2727
///
2828
/// There are different kinds of transforms handled here:
2929
/// * [`archetypes::Transform3D`]
30-
/// Tree transforms that should propagate in the tree (via [`crate::contexts::TransformTreeContext`]).
30+
/// Tree transforms that should propagate in the tree (via [`crate::TransformTree`]).
3131
/// * [`archetypes::InstancePoses3D`]
32-
/// Instance poses that should be applied to the tree transforms (via [`crate::contexts::TransformTreeContext`]) but not propagate.
32+
/// Instance poses that should be applied to the tree transforms (via [`crate::TransformTree`]) but not propagate.
3333
/// * [`components::PinholeProjection`] and [`components::ViewCoordinates`]
3434
/// Pinhole projections & associated view coordinates used for visualizing cameras in 3D and embedding 2D in 3D
3535
///
@@ -412,7 +412,7 @@ impl TransformCacheStoreSubscriber {
412412
/// Makes sure the transform cache is up to date with the latest data.
413413
///
414414
/// This needs to be called once per frame prior to any transform propagation.
415-
/// (which is done by [`crate::contexts::TransformTreeContext`])
415+
/// (which is done by [`crate::TransformTree`])
416416
// TODO(andreas): easy optimization: apply only updates for a single timeline at a time.
417417
pub fn apply_all_updates(&mut self, entity_db: &EntityDb) {
418418
re_tracing::profile_function!();

0 commit comments

Comments
 (0)