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

Rename ScenePart -> ViewPartSystem + related renamings #2674

Merged
merged 10 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 2 additions & 2 deletions crates/re_data_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ pub fn annotations(
let mut annotation_map = re_viewer_context::AnnotationMap::default();
let entity_paths: nohash_hasher::IntSet<_> = std::iter::once(entity_path.clone()).collect();
let entity_props_map = re_data_store::EntityPropertyMap::default();
let scene_query = re_viewer_context::SceneQuery::new(
let query = re_viewer_context::ViewQuery::new(
entity_path,
&entity_paths,
query.timeline,
query.at,
&entity_props_map,
);
annotation_map.load(ctx, &scene_query);
annotation_map.load(ctx, &query);
annotation_map.find(entity_path)
}
2 changes: 1 addition & 1 deletion crates/re_space_view_bar_chart/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! A Space View that shows a single bar chart.

mod scene_part;
mod space_view_class;
mod view_part_system;

pub use space_view_class::BarChartSpaceView;
6 changes: 3 additions & 3 deletions crates/re_space_view_bar_chart/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ use re_viewer_context::{
auto_color, SpaceViewClass, SpaceViewClassName, SpaceViewId, TypedScene, ViewerContext,
};

use super::scene_part::SceneBarChart;
use super::view_part_system::BarChartViewPartSystem;

#[derive(Default)]
pub struct BarChartSpaceView;

impl SpaceViewClass for BarChartSpaceView {
type State = ();
type Context = ();
type SceneParts = SceneBarChart;
type ScenePartData = ();
type ViewPartSystems = BarChartViewPartSystem;
type ViewPartSystemData = ();

fn name(&self) -> SpaceViewClassName {
"Bar Chart".into()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@ use re_components::Tensor;
use re_data_store::EntityPath;
use re_log_types::Component as _;
use re_viewer_context::{
ArchetypeDefinition, ScenePart, SceneQuery, SpaceViewClass, SpaceViewHighlights, ViewerContext,
ArchetypeDefinition, SpaceViewClass, SpaceViewHighlights, ViewPartSystem, ViewQuery,
ViewerContext,
};

use crate::BarChartSpaceView;

/// A bar chart scene, with everything needed to render it.
/// A bar chart system, with everything needed to render it.
#[derive(Default)]
pub struct SceneBarChart {
pub struct BarChartViewPartSystem {
pub charts: BTreeMap<EntityPath, Tensor>,
}

impl ScenePart<BarChartSpaceView> for SceneBarChart {
impl ViewPartSystem<BarChartSpaceView> for BarChartViewPartSystem {
fn archetype(&self) -> ArchetypeDefinition {
vec1::vec1![Tensor::name()]
}

fn populate(
&mut self,
ctx: &mut ViewerContext<'_>,
query: &SceneQuery<'_>,
query: &ViewQuery<'_>,
_state: &<BarChartSpaceView as SpaceViewClass>::State,
_scene_context: &<BarChartSpaceView as SpaceViewClass>::Context,
_context: &<BarChartSpaceView as SpaceViewClass>::Context,
_highlights: &SpaceViewHighlights,
) -> Vec<re_renderer::QueueableDrawData> {
re_tracing::profile_function!();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use re_components::AnnotationContext;
use re_log_types::Component;
use re_viewer_context::{AnnotationMap, ArchetypeDefinition, SceneContextPart};
use re_viewer_context::{AnnotationMap, ArchetypeDefinition, ViewContextSystem};

#[derive(Default)]
pub struct AnnotationSceneContext(pub AnnotationMap);

impl SceneContextPart for AnnotationSceneContext {
impl ViewContextSystem for AnnotationSceneContext {
fn archetypes(&self) -> Vec<ArchetypeDefinition> {
vec![vec1::vec1![AnnotationContext::name()]]
}

fn populate(
&mut self,
ctx: &mut re_viewer_context::ViewerContext<'_>,
query: &re_viewer_context::SceneQuery<'_>,
query: &re_viewer_context::ViewQuery<'_>,
_space_view_state: &dyn re_viewer_context::SpaceViewState,
) {
self.0.load(ctx, query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::{BTreeMap, BTreeSet};
use nohash_hasher::IntMap;
use re_components::DrawOrder;
use re_log_types::{Component, EntityPath, EntityPathHash};
use re_viewer_context::{ArchetypeDefinition, SceneContextPart};
use re_viewer_context::{ArchetypeDefinition, ViewContextSystem};

/// Context for creating a mapping from [`DrawOrder`] to [`re_renderer::DepthOffset`].
#[derive(Default)]
Expand All @@ -18,15 +18,15 @@ pub struct EntityDepthOffsets {
pub points: re_renderer::DepthOffset,
}

impl SceneContextPart for EntityDepthOffsets {
impl ViewContextSystem for EntityDepthOffsets {
fn archetypes(&self) -> Vec<ArchetypeDefinition> {
vec![vec1::vec1![DrawOrder::name()]]
}

fn populate(
&mut self,
ctx: &mut re_viewer_context::ViewerContext<'_>,
query: &re_viewer_context::SceneQuery<'_>,
query: &re_viewer_context::ViewQuery<'_>,
_space_view_state: &dyn re_viewer_context::SpaceViewState,
) {
re_tracing::profile_function!();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ pub use transform_context::{pinhole_camera_view_coordinates, TransformContext};

use re_log_types::EntityPath;
use re_renderer::DepthOffset;
use re_viewer_context::{Annotations, SceneContext};
use re_viewer_context::{Annotations, ViewContext};

use self::non_interactive_entities::NonInteractiveEntities;

#[derive(Default)]
pub struct SpatialSceneContext {
pub struct SpatialViewContext {
pub transforms: TransformContext,
pub depth_offsets: EntityDepthOffsets,
pub annotations: AnnotationSceneContext,
Expand All @@ -31,8 +31,8 @@ pub struct SpatialSceneContext {
pub num_3d_primitives: AtomicUsize,
}

impl SceneContext for SpatialSceneContext {
fn vec_mut(&mut self) -> Vec<&mut dyn re_viewer_context::SceneContextPart> {
impl ViewContext for SpatialViewContext {
fn vec_mut(&mut self) -> Vec<&mut dyn re_viewer_context::ViewContextSystem> {
let Self {
transforms,
depth_offsets,
Expand Down Expand Up @@ -60,7 +60,7 @@ impl SceneContext for SpatialSceneContext {
}
}

impl SpatialSceneContext {
impl SpatialViewContext {
pub fn lookup_entity_context<'a>(
&'a self,
ent_path: &EntityPath,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
use nohash_hasher::IntSet;
use re_log_types::EntityPathHash;
use re_viewer_context::SceneContextPart;
use re_viewer_context::ViewContextSystem;

/// List of all non-interactive entities for lookup during picking evaluation.
///
/// TODO(wumpf/jleibs): This is a temporary solution until the picking code can query propagated blueprint properties directly.
#[derive(Default)]
pub struct NonInteractiveEntities(pub IntSet<EntityPathHash>);

impl SceneContextPart for NonInteractiveEntities {
impl ViewContextSystem for NonInteractiveEntities {
fn archetypes(&self) -> Vec<re_viewer_context::ArchetypeDefinition> {
Vec::new()
}

fn populate(
&mut self,
_ctx: &mut re_viewer_context::ViewerContext<'_>,
query: &re_viewer_context::SceneQuery<'_>,
query: &re_viewer_context::ViewQuery<'_>,
_space_view_state: &dyn re_viewer_context::SpaceViewState,
) {
re_tracing::profile_function!();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use parking_lot::{Mutex, MutexGuard};
use re_renderer::{LineStripSeriesBuilder, PointCloudBuilder, RenderContext};
use re_viewer_context::{ArchetypeDefinition, SceneContextPart};
use re_viewer_context::{ArchetypeDefinition, ViewContextSystem};

use crate::scene::{
use crate::parts::{
SIZE_BOOST_IN_POINTS_FOR_LINE_OUTLINES, SIZE_BOOST_IN_POINTS_FOR_POINT_OUTLINES,
};

Expand Down Expand Up @@ -46,15 +46,15 @@ impl SharedRenderBuilders {
}
}

impl SceneContextPart for SharedRenderBuilders {
impl ViewContextSystem for SharedRenderBuilders {
fn archetypes(&self) -> Vec<ArchetypeDefinition> {
Vec::new()
}

fn populate(
&mut self,
ctx: &mut re_viewer_context::ViewerContext<'_>,
_query: &re_viewer_context::SceneQuery<'_>,
_query: &re_viewer_context::ViewQuery<'_>,
_space_view_state: &dyn re_viewer_context::SpaceViewState,
) {
self.lines = Some(Mutex::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use re_components::{DisconnectedSpace, Pinhole, Transform3D, ViewCoordinates};
use re_data_store::{EntityPath, EntityPropertyMap, EntityTree};
use re_log_types::Component;
use re_space_view::UnreachableTransformReason;
use re_viewer_context::{ArchetypeDefinition, SceneContextPart};
use re_viewer_context::{ArchetypeDefinition, ViewContextSystem};

use crate::scene::image_view_coordinates;
use crate::parts::image_view_coordinates;

#[derive(Clone)]
struct TransformInfo {
Expand Down Expand Up @@ -54,7 +54,7 @@ impl Default for TransformContext {
}
}

impl SceneContextPart for TransformContext {
impl ViewContextSystem for TransformContext {
fn archetypes(&self) -> Vec<ArchetypeDefinition> {
vec![
vec1::vec1![Transform3D::name()],
Expand All @@ -71,32 +71,32 @@ impl SceneContextPart for TransformContext {
fn populate(
&mut self,
ctx: &mut re_viewer_context::ViewerContext<'_>,
scene_query: &re_viewer_context::SceneQuery<'_>,
query: &re_viewer_context::ViewQuery<'_>,
_space_view_state: &dyn re_viewer_context::SpaceViewState,
) {
re_tracing::profile_function!();

let entity_db = &ctx.store_db.entity_db;
let time_ctrl = &ctx.rec_cfg.time_ctrl;
let entity_prop_map = scene_query.entity_props_map;
let entity_prop_map = query.entity_props_map;

self.space_origin = scene_query.space_origin.clone();
self.space_origin = query.space_origin.clone();

// Find the entity path tree for the root.
let Some(mut current_tree) = &entity_db.tree.subtree(scene_query.space_origin) else {
let Some(mut current_tree) = &entity_db.tree.subtree(query.space_origin) else {
// It seems the space path is not part of the object tree!
// This happens frequently when the viewer remembers space views from a previous run that weren't shown yet.
// Naturally, in this case we don't have any transforms yet.
return;
};

let query = time_ctrl.current_query();
let latest_at_query = time_ctrl.current_query();
Wumpf marked this conversation as resolved.
Show resolved Hide resolved

// Child transforms of this space
self.gather_descendants_transforms(
current_tree,
&entity_db.data_store,
&query,
&latest_at_query,
entity_prop_map,
glam::Affine3A::IDENTITY,
&None, // Ignore potential pinhole camera at the root of the space view, since it regarded as being "above" this root.
Expand All @@ -110,7 +110,7 @@ impl SceneContextPart for TransformContext {
// Unlike not having the space path in the hierarchy, this should be impossible.
re_log::error_once!(
"Path {} is not part of the global Entity tree whereas its child {} is",
parent_path, scene_query.space_origin
parent_path, query.space_origin
);
return;
};
Expand All @@ -120,7 +120,7 @@ impl SceneContextPart for TransformContext {
match transform_at(
&current_tree.path,
&entity_db.data_store,
&query,
&latest_at_query,
// TODO(#1988): See comment in transform_at. This is a workaround for precision issues
// and the fact that there is no meaningful image plane distance for 3D->2D views.
|_| 500.0,
Expand All @@ -141,7 +141,7 @@ impl SceneContextPart for TransformContext {
self.gather_descendants_transforms(
parent_tree,
&entity_db.data_store,
&query,
&latest_at_query,
entity_prop_map,
reference_from_ancestor,
&encountered_pinhole,
Expand Down
6 changes: 4 additions & 2 deletions crates/re_space_view_spatial/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
//! Rerun Spatial Scene Views
//! Rerun Spatial Space Views
//!
//! Space Views that show entities in a 2D or 3D spatial relationship.

mod axis_lines;
mod contexts;
mod eye;
mod instance_hash_conversions;
mod mesh_cache;
mod mesh_loader;
mod scene;
mod parts;
mod picking;
mod space_camera_3d;
mod space_view_class;
mod ui;
Expand Down
Loading