Fix T46236: NLA transition strips do not get resized when neighbouring strips change

Transition strips in the NLA should always stick to whatever strips are beside it,
and are allowed to grow/shrink as needed to achieve this. Previously the code here
was only checking if the neighbouring strips started encroaching on the transition,
but not whether the transition needed to grow to fill a gap. It was also just
moving all strips when there was insufficient space, even though that would alter
timing down the track.

Now transition strip resizing works as follows:
* It will grow/shrink as necessary to absorb any changes in the length of its neighbours
  instead of shunting everything around to maintain its length
* If the neighbour has been resized by an amount greater than the transition's length,
  all the strips will need to be shunted away to make way for the neighbour. In this
  case, the transition will shrink down to being 1 frame long to ensure that it is
  still visible (so that it can be removed if necessary).
This commit is contained in:
Joshua Leung 2015-10-09 01:10:13 +13:00
parent bf969e9dde
commit 0a7aaa99d8
Notes: blender-bot 2023-02-14 08:37:00 +01:00
Referenced by issue #46236, Transition in NLA is not updated
1 changed files with 56 additions and 2 deletions

View File

@ -1178,7 +1178,34 @@ static void nlastrip_fix_resize_overlaps(NlaStrip *strip)
NlaStrip *nls = strip->next;
float offset = 0.0f;
if (strip->end > nls->start) {
if (nls->type == NLASTRIP_TYPE_TRANSITION) {
/* transition strips should grow/shrink to accomodate the resized strip,
* but if the strip's bounds now exceed the transition, we're forced to
* offset everything to maintain the balance
*/
if (strip->end <= nls->start) {
/* grow the transition to fill the void */
nls->start = strip->end;
}
else if (strip->end < nls->end) {
/* shrink the transition to give the strip room */
nls->start = strip->end;
}
else {
/* shrink transition down to 1 frame long (so that it can still be found),
* then offset everything else by the remaining defict to give the strip room
*/
nls->start = nls->end - 1.0f;
offset = ceilf(strip->end - nls->start); /* XXX: review whether preventing fractionals is good here... */
/* apply necessary offset to ensure that the strip has enough space */
for (; nls; nls = nls->next) {
nls->start += offset;
nls->end += offset;
}
}
}
else if (strip->end > nls->start) {
/* NOTE: need to ensure we don't have a fractional frame offset, even if that leaves a gap,
* otherwise it will be very hard to get rid of later
*/
@ -1198,7 +1225,34 @@ static void nlastrip_fix_resize_overlaps(NlaStrip *strip)
NlaStrip *nls = strip->prev;
float offset = 0.0f;
if (strip->start < nls->end) {
if (nls->type == NLASTRIP_TYPE_TRANSITION) {
/* transition strips should grow/shrink to accomodate the resized strip,
* but if the strip's bounds now exceed the transition, we're forced to
* offset everything to maintain the balance
*/
if (strip->start >= nls->end) {
/* grow the transition to fill the void */
nls->end = strip->start;
}
else if (strip->start > nls->start) {
/* shrink the transition to give the strip room */
nls->end = strip->start;
}
else {
/* shrink transition down to 1 frame long (so that it can still be found),
* then offset everything else by the remaining defict to give the strip room
*/
nls->end = nls->start + 1.0f;
offset = ceilf(nls->end - strip->start); /* XXX: review whether preventing fractionals is good here... */
/* apply necessary offset to ensure that the strip has enough space */
for (; nls; nls = nls->next) {
nls->start -= offset;
nls->end -= offset;
}
}
}
else if (strip->start < nls->end) {
/* NOTE: need to ensure we don't have a fractional frame offset, even if that leaves a gap,
* otherwise it will be very hard to get rid of later
*/