Properly set emitting when particles restart #29974
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #27146
Partially addresses: #26042
For GPU particles, an issue was that when
restart()
was called, the code waited until the next frame to restart the particles (and setemitting
) to true. This resulted in a situation where emitting could be set to false and then the driver would set it back to true. When that issue was fixed, the fix causedrestart()
to no longer set emitting to true. Now, emitting is set to true at the same timerestart()
is called, so the previous bug should not arise, andrestart()
will properly restart the particle system.The reason #26042 is only partially addressed, is that in that issue, the user wants the particle system to restart when
emitting
is set to true. However, there are valid use cases where one may want to setemitting
on and off without it restarting. So a proper fix should not restart whenemitting
is set to true (as I suggested in the thread). Instead, in the AnimationPlayer, the user should setemitting
to false when they want it to stop, and then callrestart()
when they want to restart the system. However, the AnimationPlayer won't call methods when running in editor. So the workflow is still not ideal. To partially address that, I added arestart
button to the particle editor.Code graciously donated by Gamblify.
CC @jesperkondrup, @akien-mga