From 52c2f296bcd160b97f3c6eff756eacad362597aa Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 3 Aug 2020 17:17:57 +0200 Subject: Pose channel: Add session UUID Allows to identify pose channels more reliably than by the pointer. --- source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/depsgraph') 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 a4e88f4f8d2..c1e1ed3036d 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 @@ -283,6 +283,14 @@ bool id_copy_inplace_no_main(const ID *id, ID *newid) { const ID *id_for_copy = id; + if (G.debug & G_DEBUG_DEPSGRAPH_UUID) { + const ID_Type id_type = GS(id_for_copy->name); + if (id_type == ID_OB) { + const Object *object = reinterpret_cast(id_for_copy); + BKE_pose_check_uuids_unique_and_report(object->pose); + } + } + #ifdef NESTED_ID_NASTY_WORKAROUND NestedIDHackTempStorage id_hack_storage; id_for_copy = nested_id_hack_get_discarded_pointers(&id_hack_storage, id); -- cgit v1.2.3 From 8d3b8bc83589eccee10fcc0da4233b3adcf0cdde Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 3 Aug 2020 17:22:34 +0200 Subject: Depsgraph: Use UUID to identify pose channels Fixes possible fiasco caused by re-allocation re-using pointers between pose channels. Differential Revision: https://developer.blender.org/D8453 --- .../intern/eval/deg_eval_runtime_backup_object.cc | 21 +++++++++------------ .../intern/eval/deg_eval_runtime_backup_object.h | 5 ++++- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source/blender/depsgraph') 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 e0957a10cb1..88334e41192 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 @@ -85,11 +85,11 @@ void ObjectRuntimeBackup::backup_pose_channel_runtime_data(Object *object) { if (object->pose != nullptr) { LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) { - /* This is nullptr in Edit mode. */ - if (pchan->orig_pchan != nullptr) { - pose_channel_runtime_data.add(pchan->orig_pchan, pchan->runtime); - BKE_pose_channel_runtime_reset(&pchan->runtime); - } + const SessionUUID &session_uuid = pchan->runtime.session_uuid; + BLI_assert(BLI_session_uuid_is_generated(&session_uuid)); + + pose_channel_runtime_data.add(session_uuid, pchan->runtime); + BKE_pose_channel_runtime_reset(&pchan->runtime); } } } @@ -171,13 +171,10 @@ void ObjectRuntimeBackup::restore_pose_channel_runtime_data(Object *object) { if (object->pose != nullptr) { LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) { - /* This is nullptr in Edit mode. */ - if (pchan->orig_pchan != nullptr) { - optional runtime = pose_channel_runtime_data.pop_try( - pchan->orig_pchan); - if (runtime.has_value()) { - pchan->runtime = *runtime; - } + const SessionUUID &session_uuid = pchan->runtime.session_uuid; + optional runtime = pose_channel_runtime_data.pop_try(session_uuid); + if (runtime.has_value()) { + pchan->runtime = *runtime; } } } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h index 04d7fb1bc22..a10f15634ce 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h @@ -24,6 +24,9 @@ #pragma once #include "DNA_object_types.h" +#include "DNA_session_uuid_types.h" + +#include "BLI_session_uuid.h" #include "intern/eval/deg_eval_runtime_backup_modifier.h" #include "intern/eval/deg_eval_runtime_backup_pose.h" @@ -54,7 +57,7 @@ class ObjectRuntimeBackup { short base_flag; unsigned short base_local_view_bits; ModifierRuntimeDataBackup modifier_runtime_data; - Map pose_channel_runtime_data; + Map pose_channel_runtime_data; }; } // namespace deg -- cgit v1.2.3