Fix T64710: Rigid body stops simulating when an object is selected

Need to preserve last evaluated time through copy-on-write process.
This commit is contained in:
Sergey Sharybin 2019-06-12 12:11:49 +02:00
parent 75958326ad
commit 27441c7557
Notes: blender-bot 2023-02-14 09:24:53 +01:00
Referenced by issue #64710, Rigid body stops simulating when an object is selected
Referenced by issue #60136, Rigid body simulation does not bake when using Python API to create and remove mesh data in frame_change_pre_handler
1 changed files with 11 additions and 0 deletions

View File

@ -63,6 +63,7 @@ extern "C" {
#include "DNA_sound_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_rigidbody_types.h"
#include "DRW_engine.h"
@ -1010,6 +1011,7 @@ class SceneBackup {
void *playback_handle;
void *sound_scrub_handle;
void *speaker_handles;
float rigidbody_last_time;
SequencerBackup sequencer_backup;
};
@ -1025,6 +1027,7 @@ void SceneBackup::reset()
playback_handle = NULL;
sound_scrub_handle = NULL;
speaker_handles = NULL;
rigidbody_last_time = -1;
}
void SceneBackup::init_from_scene(Scene *scene)
@ -1034,6 +1037,10 @@ void SceneBackup::init_from_scene(Scene *scene)
sound_scrub_handle = scene->sound_scrub_handle;
speaker_handles = scene->speaker_handles;
if (scene->rigidbody_world != NULL) {
rigidbody_last_time = scene->rigidbody_world->ltime;
}
/* Clear pointers stored in the scene, so they are not freed when copied-on-written datablock
* is freed for re-allocation. */
scene->sound_scene = NULL;
@ -1051,6 +1058,10 @@ void SceneBackup::restore_to_scene(Scene *scene)
scene->sound_scrub_handle = sound_scrub_handle;
scene->speaker_handles = speaker_handles;
if (scene->rigidbody_world != NULL) {
scene->rigidbody_world->ltime = rigidbody_last_time;
}
sequencer_backup.restore_to_scene(scene);
reset();