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

Fix 2D objects in 3D affecting bounding box and thus causing flickering of automatic pinhole plane distance #7176

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 18 additions & 2 deletions crates/viewer/re_space_view_spatial/src/scene_bounding_boxes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use nohash_hasher::IntMap;
use re_log_types::EntityPathHash;
use re_viewer_context::VisualizerCollection;

use crate::visualizers::SpatialViewVisualizerData;
use crate::{view_kind::SpatialSpaceViewKind, visualizers::SpatialViewVisualizerData};

#[derive(Clone)]
pub struct SceneBoundingBoxes {
Expand All @@ -30,7 +30,12 @@ impl Default for SceneBoundingBoxes {
}

impl SceneBoundingBoxes {
pub fn update(&mut self, ui: &egui::Ui, visualizers: &VisualizerCollection) {
pub fn update(
&mut self,
ui: &egui::Ui,
visualizers: &VisualizerCollection,
space_kind: SpatialSpaceViewKind,
) {
re_tracing::profile_function!();

let previous = self.current;
Expand All @@ -42,6 +47,17 @@ impl SceneBoundingBoxes {
.data()
.and_then(|d| d.downcast_ref::<SpatialViewVisualizerData>())
{
// If we're in a 3D space, but the visualizer is distintivly 2D, don't count it towards the bounding box.
// These visualizers show up when we're on a pinhole camera plane which itself is heuristically fed by the
// bounding box, creating a feedback loop if we were to add it here.
if space_kind == SpatialSpaceViewKind::ThreeD
&& data
.preferred_view_kind
.map_or(true, |kind| kind != space_kind)
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
{
continue;
}

for (entity, bbox) in &data.bounding_boxes {
self.per_entity
.entry(*entity)
Expand Down
4 changes: 3 additions & 1 deletion crates/viewer/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ impl SpatialSpaceViewState {
&mut self,
ui: &egui::Ui,
system_output: &re_viewer_context::SystemExecutionOutput,
space_kind: SpatialSpaceViewKind,
) -> Result<(), SpaceViewSystemExecutionError> {
re_tracing::profile_function!();

self.bounding_boxes.update(ui, &system_output.view_systems);
self.bounding_boxes
.update(ui, &system_output.view_systems, space_kind);

let view_systems = &system_output.view_systems;

Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_space_view_spatial/src/view_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl SpaceViewClass for SpatialSpaceView2D {
re_tracing::profile_function!();

let state = state.downcast_mut::<SpatialSpaceViewState>()?;
state.update_frame_statistics(ui, &system_output)?;
state.update_frame_statistics(ui, &system_output, SpatialSpaceViewKind::TwoD)?;

self.view_2d(ctx, ui, state, query, system_output)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_space_view_spatial/src/view_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl SpaceViewClass for SpatialSpaceView3D {
re_tracing::profile_function!();

let state = state.downcast_mut::<SpatialSpaceViewState>()?;
state.update_frame_statistics(ui, &system_output)?;
state.update_frame_statistics(ui, &system_output, SpatialSpaceViewKind::ThreeD)?;

self.view_3d(ctx, ui, state, query, system_output)
}
Expand Down
Loading