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

Focus on current bounding-box when resetting camera-eye on a 3D space view (double click it) #5209

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl SpatialSpaceViewState {
.clicked()
{
self.bounding_boxes.accumulated = self.bounding_boxes.current;
self.state_3d.reset_camera(&self.bounding_boxes.accumulated, scene_view_coordinates);
self.state_3d.reset_camera(&self.bounding_boxes, scene_view_coordinates);
}
let mut spin = self.state_3d.spin();
if re_ui.checkbox(ui, &mut spin, "Spin")
Expand Down
9 changes: 6 additions & 3 deletions crates/re_space_view_spatial/src/ui_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ fn ease_out(t: f32) -> f32 {
impl View3DState {
pub fn reset_camera(
&mut self,
scene_bbox_accum: &BoundingBox,
scene_bbox: &SceneBoundingBoxes,
scene_view_coordinates: Option<ViewCoordinates>,
) {
self.interpolate_to_orbit_eye(default_eye(scene_bbox_accum, scene_view_coordinates));
// Mark as interaction since we want to stop doing any automatic interpolations,
// even if this is caused by a full reset.
self.last_eye_interaction = Some(Instant::now());
Comment on lines +98 to +100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When tracking an entity (camera), reset_camera is called each frame, I believe.

Won't resetting last_eye_interaction each frame cause the center of the orbit camera to show up each frame?

Also, what does this have to do with the PR description?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, tracking works differently, there's a tracked_entity for which there's special code how to handle that, in fact reset_camera sets tracked_entity to None. The last eye interaction is set here to stop this snippet from operating https://github.com/rerun-io/rerun/blob/main/crates/re_space_view_spatial/src/ui_3d.rs#L113

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally I also wanted that thing

        if self.last_eye_interaction.is_none() {
            self.interpolate_to_orbit_eye(default_eye(
                &bounding_boxes.accumulated,
                scene_view_coordinates,
            ));
        }

to use the current bounding box, but in many example scenes this looks too jerky

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accumulated bounding box is pretty bad generally. If you spawned your objects at the origin and then transformed them where they should go, you always have the origin in your bounding box despite it being far off. There's no way for us to tell whether it's part of the scene or not

self.interpolate_to_orbit_eye(default_eye(&scene_bbox.current, scene_view_coordinates));
self.tracked_entity = None;
self.camera_before_tracked_entity = None;
}
Expand Down Expand Up @@ -546,7 +549,7 @@ pub fn view_3d(
if space_view_id == &query.space_view_id {
state
.state_3d
.reset_camera(&state.bounding_boxes.accumulated, scene_view_coordinates);
.reset_camera(&state.bounding_boxes, scene_view_coordinates);
}
None
}
Expand Down
Loading