Skip to content

Commit

Permalink
Starting to tear out SpaceViewContents
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Nov 23, 2023
1 parent c944cc0 commit 67f996e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
7 changes: 7 additions & 0 deletions crates/re_space_view/src/data_query_blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ pub struct DataQueryBlueprint {
pub expressions: QueryExpressions,
}

impl DataQueryBlueprint {
pub fn is_equivalent(&self, other: &DataQueryBlueprint) -> bool {
self.space_view_class_name.eq(&other.space_view_class_name)
&& self.expressions.eq(&other.expressions)
}
}

impl DataQueryBlueprint {
pub const INDIVIDUAL_OVERRIDES_PREFIX: &str = "individual_overrides";
pub const RECURSIVE_OVERRIDES_PREFIX: &str = "recursive_overrides";
Expand Down
53 changes: 23 additions & 30 deletions crates/re_viewport/src/space_view.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use ahash::HashSet;
use nohash_hasher::IntMap;
use re_data_store::{EntityPath, EntityProperties, EntityTree, StoreDb, TimeInt, VisibleHistory};
use re_data_store::{EntityPropertiesComponent, EntityPropertyMap};
use re_renderer::ScreenshotProcessor;
Expand All @@ -10,16 +9,13 @@ use re_space_view_time_series::TimeSeriesSpaceView;
use re_types::blueprint::SpaceViewComponent;
use re_viewer_context::{
DataQueryId, DataResult, DynSpaceViewClass, EntitiesPerSystem, PerSystemDataResults,
SpaceViewClassName, SpaceViewHighlights, SpaceViewId, SpaceViewState, SpaceViewSystemRegistry,
StoreContext, ViewerContext,
PerSystemEntities, SpaceViewClassName, SpaceViewHighlights, SpaceViewId, SpaceViewState,
SpaceViewSystemRegistry, StoreContext, ViewerContext,
};

use crate::{
space_info::SpaceInfoCollection,
space_view_heuristics::{
compute_heuristic_context_for_entities, is_entity_processed_by_class,
reachable_entities_from_root,
},
space_view_heuristics::{compute_heuristic_context_for_entities, is_entity_processed_by_class},
};

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -169,30 +165,8 @@ impl SpaceViewBlueprint {
pub fn on_frame_start(
&mut self,
ctx: &mut ViewerContext<'_>,
spaces_info: &SpaceInfoCollection,
view_state: &mut dyn SpaceViewState,
) {
let empty_map = IntMap::default();

let entities_per_system_for_class = ctx
.entities_per_system_per_class
.get(self.class_name())
.unwrap_or(&empty_map);

if !self.entities_determined_by_user {
// Add entities that have been logged since we were created.
let reachable_entities = reachable_entities_from_root(&self.space_origin, spaces_info);
let queries_entities = reachable_entities.iter().filter(|ent_path| {
entities_per_system_for_class
.iter()
.any(|(_, ents)| ents.contains(ent_path))
});
self.contents
.insert_entities_according_to_hierarchy(queries_entities, &self.space_origin);
}

self.reset_systems_per_entity_path(entities_per_system_for_class);

while ScreenshotProcessor::next_readback_result(
ctx.render_ctx,
self.id.gpu_readback_id(),
Expand All @@ -201,10 +175,29 @@ impl SpaceViewBlueprint {
.is_some()
{}

let query_result = ctx.lookup_query_result(self.query_id()).clone();

// TODO(jleibs): Use PerSystemDataResults?
let mut per_system_entities = PerSystemEntities::default();
{
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.view_parts {
per_system_entities
.entry(*system)
.or_default()
.insert(result.entity_path.clone());
}
}
});
}

self.class(ctx.space_view_class_registry).on_frame_start(
ctx,
view_state,
self.contents.per_system_entities(),
&per_system_entities,
&mut self.auto_properties,
);
}
Expand Down
8 changes: 5 additions & 3 deletions crates/re_viewport/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<'a, 'b> Viewport<'a, 'b> {
space_view.class_name(),
);

space_view.on_frame_start(ctx, spaces_info, space_view_state);
space_view.on_frame_start(ctx, space_view_state);
}

if self.blueprint.auto_space_views {
Expand All @@ -208,8 +208,10 @@ impl<'a, 'b> Viewport<'a, 'b> {
return false;
}
if existing_view
.contents
.contains_all_entities_from(&space_view_candidate.contents)
.queries
.iter()
.zip(space_view_candidate.queries.iter())
.all(|(q1, q2)| q1.is_equivalent(q2))
{
// This space view wouldn't add anything we haven't already
return false;
Expand Down

0 comments on commit 67f996e

Please sign in to comment.