diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-21 22:46:30 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-21 22:46:30 +0100 |
commit | 29464cb9dc4baa6bfde6ad90ad3010a18e6e4ad2 (patch) | |
tree | 4dcf229d4a9cefc3f687bf11f76caa6ff8bf4664 /servers/rendering/renderer_rd | |
parent | df4d827559e1e59b06c98630e3631b8b3fb23939 (diff) | |
parent | 886cae515c491e4e9f8e600f2406e74032a284a9 (diff) |
Merge pull request #70418 from clayjohn/RD-particles
Ensure that particles are processed at least once before being used
Diffstat (limited to 'servers/rendering/renderer_rd')
-rw-r--r-- | servers/rendering/renderer_rd/storage_rd/particles_storage.cpp | 9 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/storage_rd/particles_storage.h | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index 1e91982fe1..708455706b 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -1415,6 +1415,7 @@ void ParticlesStorage::update_particles() { } bool zero_time_scale = Engine::get_singleton()->get_time_scale() <= 0.0; + bool updated = false; if (particles->clear && particles->pre_process_time > 0.0) { double frame_time; @@ -1429,6 +1430,7 @@ void ParticlesStorage::update_particles() { while (todo >= 0) { _particles_process(particles, frame_time); todo -= frame_time; + updated = true; } } @@ -1450,9 +1452,10 @@ void ParticlesStorage::update_particles() { } double todo = particles->frame_remainder + delta; - while (todo >= frame_time) { + while (todo >= frame_time || (particles->clear && !updated)) { _particles_process(particles, frame_time); todo -= decr; + updated = true; } particles->frame_remainder = todo; @@ -1460,14 +1463,16 @@ void ParticlesStorage::update_particles() { } else { if (zero_time_scale) { _particles_process(particles, 0.0); + updated = true; } else { _particles_process(particles, RendererCompositorRD::singleton->get_frame_delta_time()); + updated = true; } } //copy particles to instance buffer - if (particles->draw_order != RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY) { + if (updated && particles->draw_order != RS::PARTICLES_DRAW_ORDER_VIEW_DEPTH && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD && particles->transform_align != RS::PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY) { //does not need view dependent operation, do copy here ParticlesShader::CopyPushConstant copy_push_constant; diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.h b/servers/rendering/renderer_rd/storage_rd/particles_storage.h index ef3299ba1e..2dc61fb992 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.h @@ -485,9 +485,9 @@ public: _FORCE_INLINE_ RID particles_get_instance_buffer_uniform_set(RID p_particles, RID p_shader, uint32_t p_set) { Particles *particles = particles_owner.get_or_null(p_particles); ERR_FAIL_COND_V(!particles, RID()); - if (particles->particles_transforms_buffer_uniform_set.is_null()) { + if (particles->particles_transforms_buffer_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(particles->particles_transforms_buffer_uniform_set)) { _particles_update_buffers(particles); - + update_particles(); Vector<RD::Uniform> uniforms; { |