diff options
| -rw-r--r-- | scene/2d/cpu_particles_2d.cpp | 3 | ||||
| -rw-r--r-- | scene/2d/particles_2d.cpp | 26 | ||||
| -rw-r--r-- | scene/3d/cpu_particles.cpp | 3 | ||||
| -rw-r--r-- | scene/3d/particles.cpp | 28 | 
4 files changed, 54 insertions, 6 deletions
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index a8d72bb774..55870d7912 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -530,7 +530,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 9701998f5d..4043b8d587 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) { @@ -313,6 +327,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() { diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index cff147ba74..6415b2d0a8 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -503,7 +503,8 @@ void CPUParticles::_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/3d/particles.cpp b/scene/3d/particles.cpp index 156560f802..7e1ae98e06 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -47,6 +47,12 @@ PoolVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const {  void Particles::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 Particles::set_amount(int p_amount) { @@ -66,8 +72,16 @@ void Particles::set_one_shot(bool p_one_shot) {  	one_shot = p_one_shot;  	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 Particles::set_pre_process_time(float p_time) { @@ -306,6 +320,16 @@ void Particles::_notification(int p_what) {  			VS::get_singleton()->particles_set_speed_scale(particles, 0);  		}  	} + +	// Use internal process when emitting and one_shot are on so that when +	// the shot ends the editor can properly update +	if (p_what == NOTIFICATION_INTERNAL_PROCESS) { + +		if (one_shot && !is_emitting()) { +			_change_notify(); +			set_process_internal(false); +		} +	}  }  void Particles::_bind_methods() {  |