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

[3.x] CPUParticles2D - Add ability to follow physics interpolated target #80931

Merged
merged 2 commits into from
Sep 18, 2023

Conversation

lawnjelly
Copy link
Member

@lawnjelly lawnjelly commented Aug 23, 2023

Allows a non-interpolated particle system to closely follow an interpolated target without tracking ahead of the target, by performing fixed timestep interpolation on the particle system global transform, and using this for emission.

Changes the default physics interpolation mode of CPUParticles2D to OFF, as in most cases this looks much better and mimics the behaviour of particles simulating every frame when physics interpolation is not in use.

Witness particles now look excellent even at low physics tick rates, here it is 3 physics ticks per second! 😮

2023-08-23.17-26-28.mp4

Notes

  • This mega PR first two commits are [3.x] CPUParticles2D - fix interpolated transforms and culling #80887 and [3.x] CPUParticles - fix non-interpolated NOTIFICATION_TRANSFORM #80827 . These should be reviewed / merged first then this PR can be rebased.
  • The third commit simply disables the define for the legacy particle mode. Now that culling code is working for true global space particles, this means we can now effectively mix and match interpolated 2d items with un-interpolated particles. This can possibly be a separate small PR.
  • While the third commit allows non-interpolated particles, they end up tracking AHEAD of their parent object if the parent is interpolated.
  • To correct for this, the fourth and final commit performs local interpolation of the global_transform, in order to decide where to emit particles between physics ticks. This includes the machinery for reset_physics_interpolation().

@lawnjelly lawnjelly added this to the 3.6 milestone Aug 23, 2023
@lawnjelly lawnjelly changed the title CPUParticles2D - Add ability to follow physics interpolated target [3.x] CPUParticles2D - Add ability to follow physics interpolated target Aug 23, 2023
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally in https://github.com/Calinou/platshoot/tree/physics-interpolation-test, it works as expected (as long as interpolation is disabled on the CPUParticles2D, which is the case by default). The player's jetpack particles are now smoothed out with no jittering when the player moves 🙂

Changes the implementation of non-interpolated global mode particles so that the vertices are specified in proper global space instead of local space (vertices were previously back transformed by the inverse of the parent transform).
Allows a non-interpolated particle system to closely follow an interpolated target without tracking ahead of the target, by performing fixed timestep interpolation on the particle system global transform, and using this for emission.
@lawnjelly lawnjelly marked this pull request as ready for review September 18, 2023 15:07
@lawnjelly lawnjelly requested review from a team as code owners September 18, 2023 15:07
@akien-mga akien-mga merged commit 501517a into godotengine:3.x Sep 18, 2023
13 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants