summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-06-27 17:29:40 +0200
committerGitHub <noreply@github.com>2019-06-27 17:29:40 +0200
commit0636f709af58adfb04d9326192ae915f389c59f7 (patch)
tree251181b9f8526b5bc7b38d7a3b66263cac1248f4 /scene/2d
parentfca9f0bb7f5a378c2270449a0f830d6ad82f3885 (diff)
parentd59dbda24f780b1e52681b604ead650acd065a22 (diff)
Merge pull request #29937 from clayjohn/particles-one-shot-bug
Update emitting status on one-shot particles
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/cpu_particles_2d.cpp3
-rw-r--r--scene/2d/particles_2d.cpp26
2 files changed, 26 insertions, 3 deletions
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index fba1c26d1c..faa0a08d10 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -532,7 +532,8 @@ void CPUParticles2D::_particles_process(float p_delta) {
time = Math::fmod(time, lifetime);
cycle++;
if (one_shot && cycle > 0) {
- emitting = false;
+ set_emitting(false);
+ _change_notify();
}
}
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index 823794c3ba..7759897420 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -41,6 +41,12 @@
void Particles2D::set_emitting(bool p_emitting) {
VS::get_singleton()->particles_set_emitting(particles, p_emitting);
+
+ if (p_emitting && one_shot) {
+ set_process_internal(true);
+ } else if (!p_emitting) {
+ set_process_internal(false);
+ }
}
void Particles2D::set_amount(int p_amount) {
@@ -60,8 +66,16 @@ void Particles2D::set_one_shot(bool p_enable) {
one_shot = p_enable;
VS::get_singleton()->particles_set_one_shot(particles, one_shot);
- if (!one_shot && is_emitting())
- VisualServer::get_singleton()->particles_restart(particles);
+
+ if (is_emitting()) {
+
+ set_process_internal(true);
+ if (!one_shot)
+ VisualServer::get_singleton()->particles_restart(particles);
+ }
+
+ if (!one_shot)
+ set_process_internal(false);
}
void Particles2D::set_pre_process_time(float p_time) {
@@ -314,6 +328,14 @@ void Particles2D::_notification(int p_what) {
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
_update_particle_emission_transform();
}
+
+ if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
+
+ if (one_shot && !is_emitting()) {
+ _change_notify();
+ set_process_internal(false);
+ }
+ }
}
void Particles2D::_bind_methods() {