Fix: Simulation resets when playback stops

This commit is contained in:
Hans Goudey 2022-12-10 14:06:32 -06:00
parent 3fcf50d37a
commit 657ffe9aa7
1 changed files with 9 additions and 4 deletions

View File

@ -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;