-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
CPUParticles2D
- Add ability to follow physics interpolated target
#101911
CPUParticles2D
- Add ability to follow physics interpolated target
#101911
Conversation
From memory, it could well be, as the particle transforms should now be in true global space and therefore have to be recalculated each frame anyway from the The old particles were in some hacked global space by applying the inverse of the node transform both client and GPU side, for no sensible reason (as far as I can see, it was probably to avoid doing the changes to properly support global space, which we have since done). That hacked global space made interpolation nigh on impossible, hence the reason for introducing true global space capability for canvas items. This may be depending on the changes to support |
Seems to work great, I tested:
I've also tested children of the It is a while since I wrote this though (year and a bit) so it's not super fresh in mind, so the more testing it can get (particularly in real projects, which I don't have for 4.x) the better. Probably a good idea to try in all the relevant 2D demo projects. |
// This is used to avoid passing the camera transform down the rendering | ||
// function calls, as it won't be used in 99% of cases, because the camera | ||
// transform is normally concatenated with the item global transform. | ||
_current_camera_transform = p_transform; |
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.
Note: This is assuming single threaded pattern for doing the 2D render, that there's no multithreaded rendering and contention for this variable going on. It's safe in 3.x, and I assume in 4.x, but worth mentioning.
(If it was, it would be solvable with something uglier).
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.
Looks fine as far as I can see but could do with a secondary review if any of 4.x team is up to check it.
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.
Tested locally, it works as expected. Code looks good to me.
I've tested the MRP from OP as well as the 2D particles demo with particles converted to CPUParticles2D.
With 10 physics ticks per second and interpolation enabled, this is how it looks with GPUParticles2D (which this PR doesn't fix):
gpu_particles_2d_interpolation.mp4
And with CPUParticles2D:
cpu_particles_2d_interpolation.mp4
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. Co-authored-by: lawnjelly <lawnjelly@gmail.com>
5fd108d
to
56fc0fd
Compare
Thanks! |
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.
Ports relevant parts from 3e19cf8 and 723632a and a117a33 by @lawnjelly
Test project from #92006 (comment): particles_2d_example.zip (CPU particles are red).
@lawnjelly Is removing the old
NOTIFICATION_TRANSFORM_CHANGED
really correct?