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

Blueprint tree always starts at the origin now, "projected" paths are called out explicitly #5342

Merged
merged 7 commits into from
Feb 29, 2024
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;
}
Wumpf marked this conversation as resolved.
Show resolved Hide resolved

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
2 changes: 1 addition & 1 deletion crates/re_viewport/src/space_view_entity_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn add_entities_line_ui(

let add_info = entities_add_info.get(entity_path).unwrap();

let is_explicitly_excluded = entity_path_filter.is_explicitly_excluded(entity_path);
let is_explicitly_excluded = entity_path_filter.is_included(entity_path);
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
let is_explicitly_included = entity_path_filter.is_explicitly_included(entity_path);
let is_included = entity_path_filter.is_included(entity_path);

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