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

Fix world interpolation #191

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Fix world interpolation #191

wants to merge 3 commits into from

Conversation

Markonis
Copy link

@Markonis Markonis commented Oct 23, 2023

This PR simplifies the stepping logic, and fixes a bug with jerky interpolation.

@DakotaLarson
Copy link

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.

@Markonis
Copy link
Author

Markonis commented Apr 5, 2024

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.

Renderer frames: R---R---R---R---
Physics frames:  P------P------P---

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:

Renderer frames: R---R---R---R---R
Physics frames:  P------P------P----

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...

aziyatali

This comment was marked as off-topic.

Copy link

@aziyatali aziyatali left a 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

aziyatali

This comment was marked as off-topic.

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.

3 participants