From 60060fbfd64b06a15b2c38c40a3ea0d42bc35e20 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 28 Mar 2024 12:13:23 +0100 Subject: [PATCH 1/3] the fix --- source/blender/animrig/intern/keyframing.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/animrig/intern/keyframing.cc b/source/blender/animrig/intern/keyframing.cc index cc26df19d15..5c95ea9ac8d 100644 --- a/source/blender/animrig/intern/keyframing.cc +++ b/source/blender/animrig/intern/keyframing.cc @@ -1015,9 +1015,13 @@ void insert_key_rna(PointerRNA *rna_pointer, /* Keyframing functions can deal with the nla_context being a nullptr. */ ListBase nla_cache = {nullptr, nullptr}; NlaKeyframingContext *nla_context = nullptr; + /* The function to get the NLA context needs to get the PointerRNA from the ID because it uses + * F-Curve paths to resolve properties. Since F-Curve paths are always relative to the ID this + * would fail if the PointerRNA was a bone. */ + PointerRNA id_pointer = RNA_id_pointer_create(id); if (adt && adt->action == action) { nla_context = BKE_animsys_get_nla_keyframing_context( - &nla_cache, rna_pointer, adt, &anim_eval_context); + &nla_cache, &id_pointer, adt, &anim_eval_context); } const float nla_frame = BKE_nla_tweakedit_remap(adt, scene_frame, NLATIME_CONVERT_UNMAP); -- 2.30.2 From 087221fd822dba8fc9b9440dfb0f9b43ab0d3b1e Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 28 Mar 2024 12:51:38 +0100 Subject: [PATCH 2/3] move comment and add assert --- source/blender/animrig/intern/keyframing.cc | 4 +--- source/blender/blenkernel/BKE_animsys.h | 2 +- source/blender/blenkernel/intern/anim_sys.cc | 5 +++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/blender/animrig/intern/keyframing.cc b/source/blender/animrig/intern/keyframing.cc index 5c95ea9ac8d..c7df7ea31a5 100644 --- a/source/blender/animrig/intern/keyframing.cc +++ b/source/blender/animrig/intern/keyframing.cc @@ -1015,9 +1015,7 @@ void insert_key_rna(PointerRNA *rna_pointer, /* Keyframing functions can deal with the nla_context being a nullptr. */ ListBase nla_cache = {nullptr, nullptr}; NlaKeyframingContext *nla_context = nullptr; - /* The function to get the NLA context needs to get the PointerRNA from the ID because it uses - * F-Curve paths to resolve properties. Since F-Curve paths are always relative to the ID this - * would fail if the PointerRNA was a bone. */ + PointerRNA id_pointer = RNA_id_pointer_create(id); if (adt && adt->action == action) { nla_context = BKE_animsys_get_nla_keyframing_context( diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 31617dd56b5..55528b67734 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -237,7 +237,7 @@ typedef struct NlaKeyframingContext NlaKeyframingContext; * * \param cache: List used to cache contexts for reuse when keying * multiple channels in one operation. - * \param ptr: RNA pointer to the Object with the animation. + * \param ptr: RNA pointer to the ID with the animation. * \return Keyframing context, or NULL if not necessary. */ struct NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context( diff --git a/source/blender/blenkernel/intern/anim_sys.cc b/source/blender/blenkernel/intern/anim_sys.cc index 8ac5231e8ce..7813ddd6e3d 100644 --- a/source/blender/blenkernel/intern/anim_sys.cc +++ b/source/blender/blenkernel/intern/anim_sys.cc @@ -3673,6 +3673,11 @@ void nlasnapshot_blend_get_inverted_lower_snapshot(NlaEvalData *eval_data, NlaKeyframingContext *BKE_animsys_get_nla_keyframing_context( ListBase *cache, PointerRNA *ptr, AnimData *adt, const AnimationEvalContext *anim_eval_context) { + /* The PointerRNA needs to point to an ID because animsys_evaluate_nla_for_keyframing uses + * F-Curve paths to resolve properties. Since F-Curve paths are always relative to the ID this + * would fail if the PointerRNA was e.g. a bone. */ + BLI_assert(RNA_struct_is_ID(ptr->type)); + /* No remapping needed if NLA is off or no action. */ if ((adt == nullptr) || (adt->action == nullptr) || (adt->nla_tracks.first == nullptr) || (adt->flag & ADT_NLA_EVAL_OFF)) -- 2.30.2 From 2d705d89ba528068210442a351765ce673b801eb Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 28 Mar 2024 14:46:07 +0100 Subject: [PATCH 3/3] declaration into if --- source/blender/animrig/intern/keyframing.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/animrig/intern/keyframing.cc b/source/blender/animrig/intern/keyframing.cc index c7df7ea31a5..8b09b04c5aa 100644 --- a/source/blender/animrig/intern/keyframing.cc +++ b/source/blender/animrig/intern/keyframing.cc @@ -1016,8 +1016,8 @@ void insert_key_rna(PointerRNA *rna_pointer, ListBase nla_cache = {nullptr, nullptr}; NlaKeyframingContext *nla_context = nullptr; - PointerRNA id_pointer = RNA_id_pointer_create(id); if (adt && adt->action == action) { + PointerRNA id_pointer = RNA_id_pointer_create(id); nla_context = BKE_animsys_get_nla_keyframing_context( &nla_cache, &id_pointer, adt, &anim_eval_context); } -- 2.30.2