Possibly hacky fix for the zoom to nowhere bug. #4887
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4855
I haven't updated CHANGES.md or even thought about writing a test for this yet, because I'm not confident in it. It'd be good if @bagnell could take a quick look first.
The story is, there's a (slow) system in a demo lab here that I can reproduce #4855 on every single time. I just pan over to Australia and zoom in to Cradle Mountain in Tasmania using right-click drag. Before I manage to zoom in close, I'll suddenly end up somewhere in the Atlantic.
@duvifn noted that on his system, this happens when the
target
position that we're zooming toward is behind the camera. Same thing on my system (thanks for that @duvifn, saved me a lot of time!). Thattarget
comes from_zoomWorldPosition
, and in the frame where this happens,_zoomWorldPosition
is not updated because the mouse hasn't moved.So I think what is happening is this:
handleZoom
doesn't think it needs to update_zoomWorldPosition
, but actually it does because the target point last frame was somewhere much different because the camera moved so much.So my solution in this PR is to recompute
_zoomWorldPosition
even if the mouse didn't move. Fixes it on my slow system.