Skip to content

Commit

Permalink
Fix camera tracking delay/flicker (#2667)
Browse files Browse the repository at this point in the history
Fixes #2201 
* #2201
 
The issue is about the lines flickering in and out and the proposed
solution was to not render the lines. But turns out the image itself was
also flickering when I tested with structure_from_motion sample. Turned
out we didn't accurately track the camera, doing so works perfectly fine
and doesn't need special handling on the frustum lines.

Fixes #2660 
* #2660 

I thought this was related (because I thought above would be about
hiding lines), but now this is a regression fix that is just piggy
backing here. PR description is about the thing that was actually broken
in a release (but presumably worked before)

Test it yourself:
* got to https://demo.rerun.io/pr/2667
* click camera - observe the frustum lines are correct now
* double click the camera to focus on it and play - no flickering should
occur
* try the same while the camera is already moving


### What

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2667) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2667)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-frustum-line-issues/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Ffix-frustum-line-issues/examples)
  • Loading branch information
Wumpf committed Jul 13, 2023
1 parent 76a5eda commit 95e9756
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/parts/cameras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ impl CamerasPart {
let corners = [
pinhole.unproject(vec3(0.0, 0.0, z)),
pinhole.unproject(vec3(0.0, h, z)),
pinhole.unproject(vec3(w, 0.0, z)),
pinhole.unproject(vec3(w, h, z)),
pinhole.unproject(vec3(w, 0.0, z)),
];

let up_triangle = [
Expand Down
20 changes: 10 additions & 10 deletions crates/re_space_view_spatial/src/ui_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,28 @@ impl View3DState {
space_cameras: &[SpaceCamera3D],
view_coordinates: Option<ViewCoordinates>,
) -> &mut OrbitEye {
let tracking_camera = self
let orbit_camera = self
.orbit_eye
.get_or_insert_with(|| default_eye(scene_bbox_accum, &view_coordinates));

// Follow tracked camera if any.
if let Some(tracking_camera) = self
.tracked_camera
.as_ref()
.and_then(|c| find_camera(space_cameras, c));

if let Some(tracking_camera) = tracking_camera {
.and_then(|c| find_camera(space_cameras, c))
{
// While we're still interpolating towards it, we need to continuously update the interpolation target.
if let Some(cam_interpolation) = &mut self.eye_interpolation {
// Update interpolation target:
cam_interpolation.target_orbit = None;
if cam_interpolation.target_eye != Some(tracking_camera) {
cam_interpolation.target_eye = Some(tracking_camera);
response.ctx.request_repaint();
}
} else {
self.interpolate_to_eye(tracking_camera);
orbit_camera.copy_from_eye(&tracking_camera);
}
}

let orbit_camera = self
.orbit_eye
.get_or_insert_with(|| default_eye(scene_bbox_accum, &view_coordinates));

if self.spin {
orbit_camera.rotate(egui::vec2(
-response.ctx.input(|i| i.stable_dt).at_most(0.1) * 150.0,
Expand Down

1 comment on commit 95e9756

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.25.

Benchmark suite Current: 95e9756 Previous: 76a5eda Ratio
batch_points_arrow/encode_log_msg 89081 ns/iter (± 1648) 48670 ns/iter (± 91) 1.83

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.