瀏覽代碼

Initialize particle trail history frame numbers

Fixes #88712

All particle trail sections were activated at once on the first cycle, instead
of being spread out over the trail's lifetime.

(cherry picked from commit 9b2d77a23826d0bfaadb13f9d9d98a3e15ea1830)
Per Melin 1 年之前
父節點
當前提交
7204d66b28
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      servers/rendering/renderer_rd/storage_rd/particles_storage.cpp

+ 5 - 0
servers/rendering/renderer_rd/storage_rd/particles_storage.cpp

@@ -1439,6 +1439,11 @@ void ParticlesStorage::update_particles() {
 			if (uint32_t(history_size) != particles->frame_history.size()) {
 			if (uint32_t(history_size) != particles->frame_history.size()) {
 				particles->frame_history.resize(history_size);
 				particles->frame_history.resize(history_size);
 				memset(particles->frame_history.ptr(), 0, sizeof(ParticlesFrameParams) * history_size);
 				memset(particles->frame_history.ptr(), 0, sizeof(ParticlesFrameParams) * history_size);
+				// Set the frame number so that we are able to distinguish an uninitialized
+				// frame from the true frame number zero. See issue #88712 for details.
+				for (int i = 0; i < history_size; i++) {
+					particles->frame_history[i].frame = UINT32_MAX;
+				}
 			}
 			}
 
 
 			if (uint32_t(trail_steps) != particles->trail_params.size() || particles->frame_params_buffer.is_null()) {
 			if (uint32_t(trail_steps) != particles->trail_params.size() || particles->frame_params_buffer.is_null()) {