Fix CPUParticles emission updating using physics interpolation
When switching emission on and off, processing was always being switched on and off using internal_process, which was incorrect for using physics interpolation (where physics_process is the relevant one). This PR correctly updates the process mode according to whether physics interpolation is being used.
This commit is contained in:
parent
494876e3d8
commit
fbbb208a35
|
@ -43,6 +43,14 @@ PoolVector<Face3> CPUParticles::get_faces(uint32_t p_usage_flags) const {
|
|||
return PoolVector<Face3>();
|
||||
}
|
||||
|
||||
void CPUParticles::_set_particles_processing(bool p_enable) {
|
||||
if (_interpolated) {
|
||||
set_physics_process_internal(p_enable);
|
||||
} else {
|
||||
set_process_internal(p_enable);
|
||||
}
|
||||
}
|
||||
|
||||
void CPUParticles::set_emitting(bool p_emitting) {
|
||||
if (emitting == p_emitting) {
|
||||
return;
|
||||
|
@ -50,7 +58,7 @@ void CPUParticles::set_emitting(bool p_emitting) {
|
|||
|
||||
emitting = p_emitting;
|
||||
if (emitting) {
|
||||
set_process_internal(true);
|
||||
_set_particles_processing(true);
|
||||
|
||||
// first update before rendering to avoid one frame delay after emitting starts
|
||||
if ((time == 0) && !_interpolated) {
|
||||
|
@ -534,7 +542,7 @@ void CPUParticles::_update_internal(bool p_on_physics_tick) {
|
|||
} else {
|
||||
inactive_time += delta;
|
||||
if (inactive_time > lifetime * 1.2) {
|
||||
set_process_internal(false);
|
||||
_set_particles_processing(false);
|
||||
_set_redraw(false);
|
||||
|
||||
//reset variables
|
||||
|
@ -1206,8 +1214,14 @@ void CPUParticles::_refresh_interpolation_state() {
|
|||
_set_redraw(false);
|
||||
|
||||
_interpolated = interpolated;
|
||||
set_process_internal(!_interpolated);
|
||||
set_physics_process_internal(_interpolated);
|
||||
|
||||
if (_interpolated) {
|
||||
set_process_internal(false);
|
||||
set_physics_process_internal(emitting);
|
||||
} else {
|
||||
set_physics_process_internal(false);
|
||||
set_process_internal(emitting);
|
||||
}
|
||||
|
||||
// re-establish all connections
|
||||
_set_redraw(curr_redraw);
|
||||
|
|
|
@ -212,6 +212,7 @@ private:
|
|||
void _update_render_thread();
|
||||
|
||||
void _set_redraw(bool p_redraw);
|
||||
void _set_particles_processing(bool p_enable);
|
||||
void _refresh_interpolation_state();
|
||||
|
||||
void _fill_particle_data(const ParticleBase &p_source, float *r_dest, bool p_active) const {
|
||||
|
|
Loading…
Reference in New Issue