-
Notifications
You must be signed in to change notification settings - Fork 135
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
Fix world interpolation #191
base: master
Are you sure you want to change the base?
Conversation
Hey @Markonis, thanks for contributing! I am looking to probably add this logic to my own fork. Can you provide additional context around the scenarios the initial commit is addressing? I have had difficulty with "missed collisions" in the past that I addressed by reducing dt to 1 / 120 when calling World.fixedStep and was wondering if this makes improvement to that process. |
Hey @DakotaLarson sorry for the delayed reply... The issue that is being addressed is the following. Because the physics world has a fixed step, it can happen that the physics FPS is actually lower than the renderer FPS. In that case, for each renderer frame we need to interpolate between 2 frames of the physics step, to make the movement appear smooth. But here's the crux of the issue: for the interpolation to be correct, the current renderer frame needs to always be between a physics frame that was in the past and the one that's in the future.
So if you look at the last 2 R frames, they both fall between the last 2 P frames. But if we get the next R frame, like so:
We need to ensure that we compute the next P frame that's in the future beyond the last R. This wasn't happening previously... |
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.
We should enable branch protection
This PR simplifies the stepping logic, and fixes a bug with jerky interpolation.