-
-
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
Fix GPUParticles3D emitting finished
signal on ready
#101596
base: master
Are you sure you want to change the base?
Fix GPUParticles3D emitting finished
signal on ready
#101596
Conversation
I discovered the issue because I have a script that emits all child particles when the parent particle emits his finished signal. As a result, all child particles emit on scene load. @tool
extends Node3D
class_name GPUParticleSubeEmitterGroup3D
func _ready() -> void:
(get_parent() as GPUParticles3D).finished.connect(on_parent_finished);
func on_parent_finished() -> void:
for child in get_children():
child.restart()
if child is GPUParticles3D:
child.emitting = true @QbieShay realized the appropriate fix and I dug in to find the details as to why :) |
finished
signal on ready
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.
This is going to need to update the seed still otherwise the one shot particle will look the exact same every time which is a change in behaviour
Makes sense. I'll go update it to update the seed |
7af2536
to
d702e02
Compare
@clayjohn It has been done 😎 |
@clayjohn i'm not sure it's necessaary, this happens in the setter of oneshot and not on reset |
Whatever the Godot powers that be command of me, I shall do 😎 |
I do agree with @QbieShay though. I personally don't care that much about it one way or the other. Yes doing this introduces (imo) an unnecessary call to randomize the seed since this is just a setter. But I don't call set_one_shot often (never actually in my case) to care one way or the other. So I didn't bother bringing it up as I'd rather the PR just go through. But if I am to offer some input, I do agree with @QbieShay that randomizing the seed should be left to the restart method rather than this setter. In most cases, doing it here will be redundant. |
Fixes a bug introduced by PR: #92089
The bug being that all gpu_particle_3ds emit the
finished
signal onready
.Discussion in rocket chat can be found here: https://chat.godotengine.org/channel/vfx-tech-art/thread/WhhDnzLmTke5vYHF9
Details are as follows.
@QbieShay 's pr changes this method:
To
Specifically the part
RenderingServer::get_singleton()->particles_restart(particles);
being changed torestart();
is what introduces this bug. If we inspect therestart
method, we see that some fields get set:These fields are then evaluated in
void GPUParticles3D::_notification
here:But you still may be wondering, who calls the
set_one_shot
method? That gets called by the constructor as can be seen by my debugger:In summary, the issue is:
constructor calls
set_one_shot
-> callsrestart
-> sets fields incorrectly indicating particle system started ->GPUParticles3D::_notification
sees that the particle system isn't running but incorrectly thinks it was started so it incorrectly emits thefinished
signal.By reverting
void GPUParticles3D::set_one_shot
it goes back to behaving how it was before. To be thorough, I checked GPUParticles2D and can confirm this is how it is currently implemented over there so there is no bug with GPUParticle2D.Thank you for the help debugging this @QbieShay! ❤️