[Bf-blender-cvs] [0a7aaa9] master: Fix T46236: NLA transition strips do not get resized when neighbouring strips change

Joshua Leung noreply at git.blender.org
Thu Oct 8 14:14:17 CEST 2015


Commit: 0a7aaa99d835b37eaf4d4919088f1db7f8d1ceaf
Author: Joshua Leung
Date:   Fri Oct 9 01:10:13 2015 +1300
Branches: master
https://developer.blender.org/rB0a7aaa99d835b37eaf4d4919088f1db7f8d1ceaf

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).

===================================================================

M	source/blender/blenkernel/intern/nla.c

===================================================================

diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 2069765..6524547 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -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
 			 */




More information about the Bf-blender-cvs mailing list