Skip to content

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

Merged
akien-mga merged 2 commits intogodotengine:3.xfrom
lawnjelly:cpuparticles2d_mega_pr
Sep 18, 2023
Merged

[3.x] CPUParticles2D - Add ability to follow physics interpolated target#80931
akien-mga merged 2 commits intogodotengine:3.xfrom
lawnjelly:cpuparticles2d_mega_pr

Conversation

@lawnjelly
Copy link
Copy Markdown
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
Copy Markdown
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 🙂

@lawnjelly lawnjelly force-pushed the cpuparticles2d_mega_pr branch from b3237c7 to 1075f17 Compare September 18, 2023 07:48
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 force-pushed the cpuparticles2d_mega_pr branch from 1075f17 to 3e19cf8 Compare September 18, 2023 15:06
@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
@akien-mga
Copy link
Copy Markdown
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