[Bf-blender-cvs] [657ffe9aa70] geometry-nodes-simulation: Fix: Simulation resets when playback stops

Hans Goudey noreply at git.blender.org
Sat Dec 10 21:07:15 CET 2022


Commit: 657ffe9aa70fd35a2683eb3775ef5e558cc8a6bb
Author: Hans Goudey
Date:   Sat Dec 10 14:06:32 2022 -0600
Branches: geometry-nodes-simulation
https://developer.blender.org/rB657ffe9aa70fd35a2683eb3775ef5e558cc8a6bb

Fix: Simulation resets when playback stops

===================================================================

M	source/blender/blenkernel/BKE_compute_cache.hh

===================================================================

diff --git a/source/blender/blenkernel/BKE_compute_cache.hh b/source/blender/blenkernel/BKE_compute_cache.hh
index 1b06bbfc676..5b3e99e3f01 100644
--- a/source/blender/blenkernel/BKE_compute_cache.hh
+++ b/source/blender/blenkernel/BKE_compute_cache.hh
@@ -79,13 +79,13 @@ class SimulationCache {
     if (!values) {
       return std::nullopt;
     }
-    if (last_run_time_->time < time.time) {
-      if (values->non_persistent_value) {
+    if (values->non_persistent_value) {
+      if (last_run_time_->time < time.time) {
         return std::move(values->non_persistent_value);
       }
     }
-    /* TODO: Maybe separate retrieval of persistent and temprary cache values? Though that doesn't
-     * really provide a benefit right now. */
+    /* TODO: Maybe separate retrieval of persistent and temporary cache values?
+     * Though that doesn't really provide a benefit right now. */
     if (values->persistent_cache.is_empty()) {
       return std::nullopt;
     }
@@ -109,6 +109,11 @@ class SimulationCache {
     if (!values) {
       return std::nullopt;
     }
+    if (values->non_persistent_value) {
+      if (last_run_time_->frame == time.frame) {
+        return std::move(values->non_persistent_value);
+      }
+    }
     const int index = time.frame - start_time_->frame;
     if (!values->persistent_cache.index_range().contains(index)) {
       return std::nullopt;



More information about the Bf-blender-cvs mailing list