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

Conversation

mo8it
Copy link
Contributor

@mo8it mo8it commented Mar 6, 2024

After enabling the new feature debug_glam_assert in Bevy (which is forwarded to glam), my program panics when I rotate with the trackball. I traced it back to the syncing with the Bevy transform.

@@ -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();

@n3vu0r
Copy link
Member

n3vu0r commented Mar 6, 2024

Good catch, thanks!

@mo8it
Copy link
Contributor Author

mo8it commented Mar 6, 2024

This would be definitely better. I will the PR then and let you implement your suggestion.
Thank you 🥰

@mo8it mo8it closed this Mar 6, 2024
@mo8it mo8it deleted the normal-rot branch March 14, 2024 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants