From 962b64769018414616d50d28914a4ce4b65b490b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20de=20Vill=C3=A8le?= Date: Mon, 10 Oct 2022 17:19:26 +0200 Subject: Cleanup: NLA transforms, simplify `recalcData_nla()` Refactor the `recalcData_nla()` function, which takes data from the transform system and updates NLA strips, such that the actual logic to change the strip is moved into its own function. This also moves some generic code (find prev/next strip) from that function to BKE. This is to make the code easier to adjust when different transform operations need to perform different modifications of the strip (i.e. to fix T101130). Manifest Task: T101130 Reviewed By: sybren Differential Revision: https://developer.blender.org/D16181 --- source/blender/blenkernel/intern/nla.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source/blender/blenkernel/intern/nla.c') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index fd3580a7e88..ba63cdff917 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1272,6 +1272,34 @@ float BKE_nlastrip_compute_frame_to_next_strip(NlaStrip *strip) return limit_next; } +NlaStrip *BKE_nlastrip_next_in_track(struct NlaStrip *strip, bool skip_transitions) +{ + NlaStrip *next = strip->next; + while (next != NULL) { + if (skip_transitions && (next->type & NLASTRIP_TYPE_TRANSITION)) { + next = next->next; + } + else { + return next; + } + } + return NULL; +} + +NlaStrip *BKE_nlastrip_prev_in_track(struct NlaStrip *strip, bool skip_transitions) +{ + NlaStrip *prev = strip->prev; + while (prev != NULL) { + if (skip_transitions && (prev->type & NLASTRIP_TYPE_TRANSITION)) { + prev = prev->prev; + } + else { + return prev; + } + } + return NULL; +} + NlaStrip *BKE_nlastrip_find_active(NlaTrack *nlt) { if (nlt == NULL) { -- cgit v1.2.3 From 9f560219751240cc15a8de0b2e485e1538fee642 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 22 Oct 2022 17:19:55 +0200 Subject: Fix T101930: NLA Actions Stash remove doesn't work on overriden linked data. Code adding stash track was clearing out track flags, instead of editing them as it should have... Note that there are a lot of other weaknesses in action stash code (like relying on the (translated!!!!!!) name of the track to know whether it's a stah or not). --- source/blender/blenkernel/intern/nla.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/nla.c') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index ba63cdff917..24663d6db05 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1918,7 +1918,7 @@ bool BKE_nla_action_stash(AnimData *adt, const bool is_liboverride) * NOTE: this must be done *after* adding the strip to the track, or else * the strip locking will prevent the strip from getting added */ - nlt->flag = (NLATRACK_MUTED | NLATRACK_PROTECTED); + nlt->flag |= (NLATRACK_MUTED | NLATRACK_PROTECTED); strip->flag &= ~(NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE); /* also mark the strip for auto syncing the length, so that the strips accurately -- cgit v1.2.3