diff options
Diffstat (limited to 'source/blender/depsgraph/intern/eval')
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc | 4 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc | 24 |
2 files changed, 14 insertions, 14 deletions
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 95521ee9e47..edb02ee331f 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -781,7 +781,9 @@ void update_id_after_copy(const Depsgraph *depsgraph, const Object *object_orig = (const Object *)id_orig; object_cow->mode = object_orig->mode; object_cow->sculpt = object_orig->sculpt; - object_cow->runtime.data_orig = (ID *)object_cow->data; + if (object_cow->type == OB_MESH) { + object_cow->runtime.mesh_orig = (Mesh *)object_cow->data; + } if (object_cow->type == OB_ARMATURE) { const bArmature *armature_orig = (bArmature *)object_orig->data; bArmature *armature_cow = (bArmature *)object_cow->data; diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc index acbcd4d551d..df7338e1076 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc @@ -44,6 +44,7 @@ ObjectRuntimeBackup::ObjectRuntimeBackup(const Depsgraph * /*depsgraph*/) void ObjectRuntimeBackup::init_from_object(Object *object) { /* Store evaluated mesh and curve_cache, and make sure we don't free it. */ + Mesh *mesh_eval = object->runtime.mesh_eval; runtime = object->runtime; BKE_object_runtime_reset(object); /* Keep bbox (for now at least). */ @@ -51,7 +52,9 @@ void ObjectRuntimeBackup::init_from_object(Object *object) /* Object update will override actual object->data to an evaluated version. * Need to make sure we don't have data set to evaluated one before free * anything. */ - object->data = runtime.data_orig; + if (mesh_eval != nullptr && object->data == mesh_eval) { + object->data = runtime.mesh_orig; + } /* Make a backup of base flags. */ base_flag = object->base_flag; base_local_view_bits = object->base_local_view_bits; @@ -95,13 +98,12 @@ void ObjectRuntimeBackup::backup_pose_channel_runtime_data(Object *object) void ObjectRuntimeBackup::restore_to_object(Object *object) { - ID *data_orig = object->runtime.data_orig; - ID *data_eval = object->runtime.data_eval; + Mesh *mesh_orig = object->runtime.mesh_orig; BoundBox *bb = object->runtime.bb; object->runtime = runtime; - object->runtime.data_orig = data_orig; + object->runtime.mesh_orig = mesh_orig; object->runtime.bb = bb; - if (object->type == OB_MESH && data_eval != nullptr) { + if (object->type == OB_MESH && object->runtime.mesh_eval != nullptr) { if (object->id.recalc & ID_RECALC_GEOMETRY) { /* If geometry is tagged for update it means, that part of * evaluated mesh are not valid anymore. In this case we can not @@ -109,24 +111,20 @@ void ObjectRuntimeBackup::restore_to_object(Object *object) * * We restore object's data datablock to an original copy of * that datablock. */ - object->data = data_orig; + object->data = mesh_orig; /* After that, immediately free the invalidated caches. */ BKE_object_free_derived_caches(object); } else { + Mesh *mesh_eval = object->runtime.mesh_eval; /* Do same thing as object update: override actual object data * pointer with evaluated datablock. */ - object->data = data_eval; - + object->data = mesh_eval; /* Evaluated mesh simply copied edit_mesh pointer from * original mesh during update, need to make sure no dead * pointers are left behind. */ - if (object->type == OB_MESH) { - Mesh *mesh_eval = (Mesh *)data_eval; - Mesh *mesh_orig = (Mesh *)data_orig; - mesh_eval->edit_mesh = mesh_orig->edit_mesh; - } + mesh_eval->edit_mesh = mesh_orig->edit_mesh; } } object->base_flag = base_flag; |