-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Don't move the camera when window is refocused #4590
Conversation
engine/src/main/java/org/terasology/engine/input/lwjgl/LwjglMouseDevice.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explanation makes sense and this does look like the right place to do it.
I'm not familiar with the LWJGL API, but this is at least consistent with the way update
does it.
xpos = mouseX.get(0); | ||
ypos = mouseY.get(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be replaced with a Vector2d;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can. That does make it shorter, as long as we're fine with newPos.sub(pos, posDelta)
being somewhat harder to read than xposDelta = x - this.xpos
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also require corresponding changes to the update
method which uses those fields.
I know I've encouraged a bit of scope creep here by bringing up the code duplication in update
and the use of rewind
, but we should probably not stack all of the possible clean-ups we can think of in to this bugfix PR.
Contains
Fix the camera position resetting to look at the sky when the window is unfocused and then focused again. It just resets the mouse position whenever the window is focused, which also means that if you unfocus, move the mouse, and focus again, the camera doesn't move.
How to test
Start the game, move the camera, alt-tab to another window, then alt-tab back. The camera shouldn't move.