Skip to content

Commit

Permalink
Blueprint tree always starts at the origin now, "projected" paths are…
Browse files Browse the repository at this point in the history
… called out explicitely (#5342)

### What

* Direct follow up of #5326
* Fixes #4156 


https://github.com/rerun-io/rerun/assets/1220815/77ed6a42-50db-4ca3-b596-8dcf5bce9baf


Follows the design proposal from the ticket directly. Some detail
decisions on how things are exactly handled, but code should be a bit
more composable now (albeit admittedly still a bit messy)

### 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 newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5342/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5342/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5342/index.html?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)!

- [PR Build Summary](https://build.rerun.io/pr/5342)
- [Docs
preview](https://rerun.io/preview/6011f651a1ebd432d77d25d3edd7ea746053fd99/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/6011f651a1ebd432d77d25d3edd7ea746053fd99/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
Wumpf committed Feb 29, 2024
1 parent 20d498b commit c413bd5
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 141 deletions.
5 changes: 5 additions & 0 deletions crates/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ pub fn instance_hover_card_ui(
store: &re_data_store::DataStore,
instance_path: &InstancePath,
) {
if !ctx.entity_db.is_known_entity(&instance_path.entity_path) {
ui.label("Unknown entity.");
return;
}

let subtype_string = if instance_path.instance_key.is_splat() {
"Entity"
} else {
Expand Down
6 changes: 3 additions & 3 deletions crates/re_space_view/src/data_query_blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,13 @@ impl<'a> QueryExpressionEvaluator<'a> {
// Ignore empty nodes.
// Since we recurse downwards, this prunes any branches that don't have anything to contribute to the scene
// and aren't directly included.
let direct_included = self.entity_path_filter.is_exact_included(entity_path);
if direct_included || !children.is_empty() || !visualizers.is_empty() {
let exact_included = self.entity_path_filter.is_exact_included(entity_path);
if exact_included || !children.is_empty() || !visualizers.is_empty() {
Some(data_results.insert(DataResultNode {
data_result: DataResult {
entity_path: entity_path.clone(),
visualizers,
direct_included,
direct_included: self.entity_path_filter.is_included(entity_path),
property_overrides: None,
},
children,
Expand Down
15 changes: 7 additions & 8 deletions crates/re_space_view/src/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,14 @@ impl SpaceViewBlueprint {
{
re_tracing::profile_scope!("per_system_data_results");

query_result.tree.visit(&mut |handle| {
if let Some(result) = query_result.tree.lookup_result(handle) {
for system in &result.visualizers {
per_system_entities
.entry(*system)
.or_default()
.insert(result.entity_path.clone());
}
query_result.tree.visit(&mut |node| {
for system in &node.data_result.visualizers {
per_system_entities
.entry(*system)
.or_default()
.insert(node.data_result.entity_path.clone());
}
true
});
}

Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/space_view_space_origin_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn space_view_space_origin_widget_editing_ui(
selected_suggestion = selected_suggestion
.saturating_add(arrow_down)
.saturating_sub(arrow_up);
if !space_view_suggestions.is_empty() {
if !space_view_suggestions.is_empty() && !filtered_space_view_suggestions.is_empty() {
selected_suggestion =
selected_suggestion.at_most(filtered_space_view_suggestions.len() - 1);
}
Expand Down
30 changes: 22 additions & 8 deletions crates/re_viewer_context/src/query_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,42 @@ impl DataResultTree {
}

/// Depth-first traversal of the tree, calling `visitor` on each result.
pub fn visit(&self, visitor: &mut impl FnMut(DataResultHandle)) {
///
/// Stops traversing a branch if `visitor` returns `false`.
pub fn visit<'a>(&'a self, visitor: &mut impl FnMut(&'a DataResultNode) -> bool) {
if let Some(root_handle) = self.root_handle {
self.visit_recursive(root_handle, visitor);
}
}

/// Look up a [`DataResult`] in the tree based on its handle.
#[inline]
pub fn lookup_result(&self, handle: DataResultHandle) -> Option<&DataResult> {
self.data_results.get(handle).map(|node| &node.data_result)
}

/// Look up a [`DataResultNode`] in the tree based on its handle.
#[inline]
pub fn lookup_node(&self, handle: DataResultHandle) -> Option<&DataResultNode> {
self.data_results.get(handle)
}

/// Look up a [`DataResultNode`] in the tree based on its handle.
#[inline]
pub fn lookup_node_mut(&mut self, handle: DataResultHandle) -> Option<&mut DataResultNode> {
self.data_results.get_mut(handle)
}

/// Look up a [`DataResultNode`] in the tree based on an [`EntityPath`].
#[inline]
pub fn lookup_node_by_path(&self, path: &EntityPath) -> Option<&DataResultNode> {
self.data_results_by_path
.get(&path.hash())
.and_then(|handle| self.lookup_node(*handle))
}

/// Look up a [`DataResult`] in the tree based on an [`EntityPath`].
#[inline]
pub fn lookup_result_by_path(&self, path: &EntityPath) -> Option<&DataResult> {
self.data_results_by_path
.get(&path.hash())
Expand All @@ -146,16 +160,16 @@ impl DataResultTree {
self.data_results_by_path.is_empty()
}

fn visit_recursive(
&self,
fn visit_recursive<'a>(
&'a self,
handle: DataResultHandle,
visitor: &mut impl FnMut(DataResultHandle),
visitor: &mut impl FnMut(&'a DataResultNode) -> bool,
) {
if let Some(result) = self.data_results.get(handle) {
visitor(handle);

for child in &result.children {
self.visit_recursive(*child, visitor);
if visitor(result) {
for child in &result.children {
self.visit_recursive(*child, visitor);
}
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions crates/re_viewport/src/system_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,14 @@ pub fn execute_systems_for_space_view<'a>(
{
re_tracing::profile_scope!("per_system_data_results");

query_result.tree.visit(&mut |handle| {
if let Some(result) = query_result.tree.lookup_result(handle) {
for system in &result.visualizers {
per_system_data_results
.entry(*system)
.or_default()
.push(result);
}
query_result.tree.visit(&mut |node| {
for system in &node.data_result.visualizers {
per_system_data_results
.entry(*system)
.or_default()
.push(&node.data_result);
}
true
});
}

Expand Down

0 comments on commit c413bd5

Please sign in to comment.