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

Use yaw/pitch from Camera's rotation. #21

Merged
merged 2 commits into from Apr 3, 2023

Conversation

Neopallium
Copy link
Contributor

Fixes issue with first mouse movement resetting the camera rotation. Query the yaw and pitch from the camera before updating the rotation.

This helps with issue #17.

@BlackPhlox BlackPhlox linked an issue Aug 30, 2022 that may be closed by this pull request
@gilescope
Copy link

gilescope commented Sep 4, 2022

Nice. I noticed this too. Very annoying as it just happens that first time every time you move the mouse.

I found that another way it could be fixed is copying the same code that the keys use:

                let yaw = Quat::from_rotation_y(-(settings.sensitivity * ev.delta.x * window_scale).to_radians());
                let pitch = Quat::from_rotation_x(-(settings.sensitivity * ev.delta.y * window_scale).to_radians());
                transform.rotation = yaw * transform.rotation; // rotate around global y axis
                transform.rotation = transform.rotation * pitch; // rotate around local x axis

(actually on closer inspection this looks pretty much the same as what you've done.)

On the hole I think I prefer that as I think it's a bit sketchy setting the rotation explicitly in one and doing relative transforms in the other ( the original mouse code does not use transform.rotation where as the key side does.... we should do one or the other)

@BlackPhlox BlackPhlox self-assigned this Apr 2, 2023
@BlackPhlox BlackPhlox merged commit da69191 into sburris0:master Apr 3, 2023
2 of 5 checks passed
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.

intentional position and orientation
4 participants