Skip to content

Commit

Permalink
Don't consider pinholes when in 2D views
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Oct 11, 2023
1 parent 94a0903 commit f5020bc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
25 changes: 20 additions & 5 deletions crates/re_space_view_spatial/src/parts/entity_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ use re_query::{query_archetype_with_history, ArchetypeView, QueryError};
use re_renderer::DepthOffset;
use re_types::Archetype;
use re_viewer_context::{
NamedViewSystem, SpaceViewSystemExecutionError, ViewContextCollection, ViewQuery, ViewerContext,
NamedViewSystem, SpaceViewClass, SpaceViewSystemExecutionError, ViewContextCollection,
ViewQuery, ViewerContext,
};

use crate::contexts::{
AnnotationSceneContext, EntityDepthOffsets, PrimitiveCounter, SharedRenderBuilders,
SpatialSceneEntityContext, TransformContext,
use crate::{
contexts::{
AnnotationSceneContext, EntityDepthOffsets, PrimitiveCounter, SharedRenderBuilders,
SpatialSceneEntityContext, TransformContext,
},
SpatialSpaceView3D,
};

/// Iterates through all entity views for a given archetype.
Expand Down Expand Up @@ -39,7 +43,18 @@ where
let counter = view_ctx.get::<PrimitiveCounter>()?;

for (ent_path, props) in query.iter_entities_for_system(System::name()) {
let Some(world_from_entity) = transforms.reference_from_entity(ent_path) else {
// The transform that considers pinholes only makes sense if this is a 3D space-view
let world_from_entity = if view_ctx.space_view_class_name() == SpatialSpaceView3D.name() {
transforms.reference_from_entity(ent_path)
} else {
transforms.reference_from_entity_ignoring_pinhole(
ent_path,
&ctx.store_db.entity_db.data_store,
&query.latest_at_query(),
)
};

let Some(world_from_entity) = world_from_entity else {
continue;
};
let entity_context = SpatialSceneEntityContext {
Expand Down
26 changes: 22 additions & 4 deletions crates/re_space_view_spatial/src/parts/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
parts::SIZE_BOOST_IN_POINTS_FOR_POINT_OUTLINES,
query_pinhole,
view_kind::SpatialSpaceViewKind,
SpatialSpaceView2D,
SpatialSpaceView2D, SpatialSpaceView3D,
};

use super::{entity_iterator::process_archetype_views, SpatialViewPartData};
Expand Down Expand Up @@ -214,7 +214,13 @@ impl ImagesPart {
) -> Result<(), QueryError> {
re_tracing::profile_function!();

let parent_pinhole_path = transforms.parent_pinhole(ent_path);
// Parent pinhole should only be relevant to 3D views
let parent_pinhole_path = if ent_context.space_view_class_name == SpatialSpaceView3D.name()
{
transforms.parent_pinhole(ent_path)
} else {
None
};

// If this isn't an image, return
// TODO(jleibs): The ArchetypeView should probably do this for us.
Expand Down Expand Up @@ -323,7 +329,13 @@ impl ImagesPart {
}
let meaning = TensorDataMeaning::Depth;

let parent_pinhole_path = transforms.parent_pinhole(ent_path);
// Parent pinhole should only be relevant to 3D views
let parent_pinhole_path = if ent_context.space_view_class_name == SpatialSpaceView3D.name()
{
transforms.parent_pinhole(ent_path)
} else {
None
};

// Instance ids of tensors refer to entries inside the tensor.
for (tensor, color, draw_order) in itertools::izip!(
Expand Down Expand Up @@ -439,7 +451,13 @@ impl ImagesPart {
) -> Result<(), QueryError> {
re_tracing::profile_function!();

let parent_pinhole_path = transforms.parent_pinhole(ent_path);
// Parent pinhole should only be relevant to 3D views
let parent_pinhole_path = if ent_context.space_view_class_name == SpatialSpaceView3D.name()
{
transforms.parent_pinhole(ent_path)
} else {
None
};

// If this isn't an image, return
// TODO(jleibs): The ArchetypeView should probably to this for us.
Expand Down

0 comments on commit f5020bc

Please sign in to comment.