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

Normalize the rotation before syncing #7

Closed
wants to merge 1 commit into from
Closed
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ serialize = ["bevy/serialize", "trackball/serde"]
c11-orbit = ["trackball/cc"]

[dependencies]
bevy = { version = "0.13.0", default-features = false, features = ["bevy_render"] }
bevy = { version = "0.13.0", default-features = false, features = ["bevy_render", "debug_glam_assert"] }
bevy_egui = { version = "0.25.0", default-features = false, features = ["render"], optional = true }
trackball = { version = "0.12.0", features = ["glam"] }

Expand Down
2 changes: 1 addition & 1 deletion src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub fn trackball_camera(
.unwrap_or(trackball.frame);
let view = trackball.old_frame.view();
transform.translation = view.translation.into();
transform.rotation = view.rotation.into();
transform.rotation = view.rotation.normalize().into();
Copy link
Member

Choose a reason for hiding this comment

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

I would instead normalize the trackball.old_frame after line 135 by appending:

.map(|mut frame| {
	frame.renormalize();
	frame
})

In this way, the de-normalization doesn't add-up in the first place as part of the smoothing.

The final snap-in assignment in line 138 shouldn't cause any trouble as trackball.frame is already re-normalized in:

trackball.frame.renormalize();

}
let new_scope = trackball.scope != trackball.old_scope;
let new_max = max != trackball.old_max;
Expand Down