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

Don't move the camera when window is refocused #4590

Merged
merged 5 commits into from
Mar 26, 2021

Conversation

naalit
Copy link
Contributor

@naalit naalit commented Mar 20, 2021

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.

Copy link
Member

@keturn keturn left a 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.

Comment on lines +130 to +131
xpos = mouseX.get(0);
ypos = mouseY.get(0);
Copy link
Member

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;

Copy link
Contributor Author

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.

Copy link
Member

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.

@keturn keturn added the Type: Bug Issues reporting and PRs fixing problems label Mar 24, 2021
@keturn keturn added this to the v4.4.0 milestone Mar 24, 2021
@pollend pollend merged commit a75c7d1 into MovingBlocks:develop Mar 26, 2021
@naalit naalit deleted the camera_window_focus branch March 27, 2021 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issues reporting and PRs fixing problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants