From 264af1519e08bf634401802e462ebd19eeba8b7b Mon Sep 17 00:00:00 2001 From: Wayde Moss Date: Wed, 3 Feb 2021 16:01:11 -0500 Subject: NLA: Fix Strip Truncate When Next to Transition **Problem**: Translating a strip will truncate it when next to a transition. **Solution**: The code only accounted for the prev/next strip for whether it exceeds. When it was a transition, the exceed logic fails. Now, we use the nearest non-transition strip instead. Reviewed By: sybren, #animation_rigging Differential Revision: https://developer.blender.org/D10083 --- .../editors/transform/transform_convert_nla.c | 32 ++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/transform/transform_convert_nla.c b/source/blender/editors/transform/transform_convert_nla.c index adc2d03e2dc..51802a1e769 100644 --- a/source/blender/editors/transform/transform_convert_nla.c +++ b/source/blender/editors/transform/transform_convert_nla.c @@ -304,7 +304,7 @@ void recalcData_nla(TransInfo *t) for (i = 0; i < tc->data_len; i++, tdn++) { NlaStrip *strip = tdn->strip; PointerRNA strip_ptr; - short pExceeded, nExceeded, iter; + short iter; int delta_y1, delta_y2; /* if this tdn has no handles, that means it is just a dummy that should be skipped */ @@ -358,21 +358,31 @@ void recalcData_nla(TransInfo *t) * * this is done as a iterative procedure (done 5 times max for now) */ + NlaStrip *prev = strip->prev; + while (prev != NULL && (prev->type & NLASTRIP_TYPE_TRANSITION)) { + prev = prev->prev; + } + + NlaStrip *next = strip->next; + while (next != NULL && (next->type & NLASTRIP_TYPE_TRANSITION)) { + next = next->next; + } + for (iter = 0; iter < 5; iter++) { - pExceeded = ((strip->prev) && (strip->prev->type != NLASTRIP_TYPE_TRANSITION) && - (tdn->h1[0] < strip->prev->end)); - nExceeded = ((strip->next) && (strip->next->type != NLASTRIP_TYPE_TRANSITION) && - (tdn->h2[0] > strip->next->start)); + + const bool pExceeded = (prev != NULL) && (tdn->h1[0] < prev->end); + const bool nExceeded = (next != NULL) && (tdn->h2[0] > next->start); if ((pExceeded && nExceeded) || (iter == 4)) { - /* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise) + /* both endpoints exceeded (or iteration ping-pong'd meaning that we need a + * compromise) * - Simply crop strip to fit within the bounds of the strips bounding it * - If there were no neighbors, clear the transforms * (make it default to the strip's current values). */ - if (strip->prev && strip->next) { - tdn->h1[0] = strip->prev->end; - tdn->h2[0] = strip->next->start; + if (prev && next) { + tdn->h1[0] = prev->end; + tdn->h2[0] = next->start; } else { tdn->h1[0] = strip->start; @@ -381,14 +391,14 @@ void recalcData_nla(TransInfo *t) } else if (nExceeded) { /* move backwards */ - float offset = tdn->h2[0] - strip->next->start; + float offset = tdn->h2[0] - next->start; tdn->h1[0] -= offset; tdn->h2[0] -= offset; } else if (pExceeded) { /* more forwards */ - float offset = strip->prev->end - tdn->h1[0]; + float offset = prev->end - tdn->h1[0]; tdn->h1[0] += offset; tdn->h2[0] += offset; -- cgit v1.2.3