From 46d56bd9567045965a6a46e2b5205020514bbee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 4 May 2021 16:19:51 +0200 Subject: Animation: correct active track/strip pointers after copying NLA tracks After copying NLA tracks from one `AnimData` to another, also ensure that the `AnimData::act_track` and `AnimData::actstrip` pointers are pointing to the copy rather than the original. This is a necessary step to allow library overrides on NLA modifiers without crashing Blender. The remapping of the pointers is done by looping over the tracks/strips and comparing pointers. Alternatively, I could update the copy functions themselves to keep track of those pointers and return them, but IMO that would produce more spaghetti (they're also used in cases where this pointer-remapping is not desired). --- source/blender/blenkernel/BKE_nla.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/BKE_nla.h') diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 16d48024d07..af238fda659 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -58,7 +58,14 @@ struct NlaTrack *BKE_nlatrack_copy(struct Main *bmain, struct NlaTrack *nlt, const bool use_same_actions, const int flag); -void BKE_nla_tracks_copy(struct Main *bmain, ListBase *dst, ListBase *src, const int flag); +void BKE_nla_tracks_copy(struct Main *bmain, ListBase *dst, const ListBase *src, const int flag); + +/* Copy NLA tracks from #adt_source to #adt_dest, and update the active track/strip pointers to + * point at those copies. */ +void BKE_nla_tracks_copy_from_adt(struct Main *bmain, + struct AnimData *adt_dest, + const struct AnimData *adt_source, + int flag); struct NlaTrack *BKE_nlatrack_add(struct AnimData *adt, struct NlaTrack *prev, -- cgit v1.2.3