[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21154] branches/soc-2009-aligorith/source /blender: NLA SoC: Fix transforms for transition strips.

Joshua Leung aligorith at gmail.com
Thu Jun 25 14:30:49 CEST 2009


Revision: 21154
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21154
Author:   aligorith
Date:     2009-06-25 14:30:49 +0200 (Thu, 25 Jun 2009)

Log Message:
-----------
NLA SoC: Fix transforms for transition strips.

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
    branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c
    branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c

Modified: branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c	2009-06-25 12:13:32 UTC (rev 21153)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c	2009-06-25 12:30:49 UTC (rev 21154)
@@ -2620,9 +2620,12 @@
 		/* only consider selected strips */
 		for (strip= nlt->strips.first; strip; strip= strip->next) {
 			// TODO: we can make strips have handles later on...
-			if (strip->flag & NLASTRIP_FLAG_SELECT) {
-				if (FrameOnMouseSide(side, strip->start, (float)CFRA)) count++;
-				if (FrameOnMouseSide(side, strip->end, (float)CFRA)) count++;
+			/* transition strips can't get directly transformed */
+			if (strip->type != NLASTRIP_TYPE_TRANSITION) {
+				if (strip->flag & NLASTRIP_FLAG_SELECT) {
+					if (FrameOnMouseSide(side, strip->start, (float)CFRA)) count++;
+					if (FrameOnMouseSide(side, strip->end, (float)CFRA)) count++;
+				}
 			}
 		}
 	}
@@ -2652,35 +2655,38 @@
 			/* only consider selected strips */
 			for (strip= nlt->strips.first; strip; strip= strip->next) {
 				// TODO: we can make strips have handles later on...
-				if (strip->flag & NLASTRIP_FLAG_SELECT) {
-					if (FrameOnMouseSide(side, strip->start, (float)CFRA)) 
-					{
-						/* init the 'extra' data for NLA strip handles first */
-						tdn->strip= strip;
-						tdn->val= strip->start;
-						tdn->handle= 0;
-						
-						/* now, link the transform data up to this data */
-						td->val= &tdn->val;
-						td->ival= tdn->val;
-						td->extra= tdn;
-						td++;
-						tdn++;
+				/* transition strips can't get directly transformed */
+				if (strip->type != NLASTRIP_TYPE_TRANSITION) {
+					if (strip->flag & NLASTRIP_FLAG_SELECT) {
+						if (FrameOnMouseSide(side, strip->start, (float)CFRA)) 
+						{
+							/* init the 'extra' data for NLA strip handles first */
+							tdn->strip= strip;
+							tdn->val= strip->start;
+							tdn->handle= 0;
+							
+							/* now, link the transform data up to this data */
+							td->val= &tdn->val;
+							td->ival= tdn->val;
+							td->extra= tdn;
+							td++;
+							tdn++;
+						}
+						if (FrameOnMouseSide(side, strip->end, (float)CFRA)) 
+						{	
+							/* init the 'extra' data for NLA strip handles first */
+							tdn->strip= strip;
+							tdn->val= strip->end;
+							tdn->handle= 1;
+							
+							/* now, link the transform data up to this data */
+							td->val= &tdn->val;
+							td->ival= tdn->val;
+							td->extra= tdn;
+							td++;
+							tdn++;
+						}
 					}
-					if (FrameOnMouseSide(side, strip->end, (float)CFRA)) 
-					{	
-						/* init the 'extra' data for NLA strip handles first */
-						tdn->strip= strip;
-						tdn->val= strip->end;
-						tdn->handle= 1;
-						
-						/* now, link the transform data up to this data */
-						td->val= &tdn->val;
-						td->ival= tdn->val;
-						td->extra= tdn;
-						td++;
-						tdn++;
-					}
 				}
 			}
 		}

Modified: branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c	2009-06-25 12:13:32 UTC (rev 21153)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c	2009-06-25 12:30:49 UTC (rev 21154)
@@ -358,11 +358,21 @@
 				 * ones (i.e. don't go through RNA), as we get some artifacts...
 				 */
 				if (t->state == TRANS_CANCEL) {
-					/* write the value set by the transform tools to the appropriate property using RNA */
-					if (tdn->handle)
+					/* clear the values by directly overwriting the originals, but also need to restore 
+					 * endpoints of neighboring transition-strips
+					 */
+					if (tdn->handle) {
 						strip->end= tdn->val;
-					else
+						
+						if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION))
+							strip->next->start= tdn->val;
+					}
+					else {
 						strip->start= tdn->val;
+						
+						if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
+							strip->prev->end= tdn->val;
+					}
 				}
 				else {
 					PointerRNA strip_ptr;

Modified: branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c	2009-06-25 12:13:32 UTC (rev 21153)
+++ branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c	2009-06-25 12:30:49 UTC (rev 21154)
@@ -40,17 +40,30 @@
 #include <stdio.h>
 #include <math.h>
 
+/* temp constant defined for these funcs only... */
+#define NLASTRIP_MIN_LEN_THRESH 	0.1f
+
 static void rna_NlaStrip_start_frame_set(PointerRNA *ptr, float value)
 {
 	NlaStrip *data= (NlaStrip*)ptr->data;
 	
 	/* clamp value to lie within valid limits 
 	 *	- cannot start past the end of the strip + some flexibility threshold
-	 *	- cannot start before the previous strip (if present) ends 
+	 *	- cannot start before the previous strip (if present) ends
+	 *		-> but if it was a transition, we could go up to the start of the strip + some flexibility threshold
+	 *		as long as we re-adjust the transition afterwards
 	 *	- minimum frame is -MAXFRAME so that we don't get clipping on frame 0
 	 */
 	if (data->prev) {
-		CLAMP(value, data->prev->end, data->end-0.1f);
+		if (data->prev->type == NLASTRIP_TYPE_TRANSITION) {
+			CLAMP(value, data->prev->start+NLASTRIP_MIN_LEN_THRESH, data->end-NLASTRIP_MIN_LEN_THRESH);
+			
+			/* readjust the transition to stick to the endpoints of the action-clips */
+			data->prev->end= value;
+		}
+		else {
+			CLAMP(value, data->prev->end, data->end-NLASTRIP_MIN_LEN_THRESH);
+		}
 	}
 	else {
 		CLAMP(value, -MAXFRAME, data->end);
@@ -61,28 +74,42 @@
 static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, float value)
 {
 	NlaStrip *data= (NlaStrip*)ptr->data;
-	float len, actlen;
 	
 	/* clamp value to lie within valid limits
 	 *	- must not have zero or negative length strip, so cannot start before the first frame 
 	 *	  + some minimum-strip-length threshold
 	 *	- cannot end later than the start of the next strip (if present)
+	 *		-> but if it was a transition, we could go up to the start of the end - some flexibility threshold
+	 *		as long as we re-adjust the transition afterwards
 	 */
 	if (data->next) {
-		CLAMP(value, data->start+0.1f, data->next->start);
+		if (data->next->type == NLASTRIP_TYPE_TRANSITION) {
+			CLAMP(value, data->start+NLASTRIP_MIN_LEN_THRESH, data->next->end-NLASTRIP_MIN_LEN_THRESH);
+			
+			/* readjust the transition to stick to the endpoints of the action-clips */
+			data->next->start= value;
+		}
+		else {
+			CLAMP(value, data->start+NLASTRIP_MIN_LEN_THRESH, data->next->start);
+		}
 	}
 	else {
-		CLAMP(value, data->start+0.1f, MAXFRAME);
+		CLAMP(value, data->start+NLASTRIP_MIN_LEN_THRESH, MAXFRAME);
 	}
 	data->end= value;
 	
+	
 	/* calculate the lengths the strip and its action (if applicable) */
-	len= data->end - data->start;
-	actlen= data->actend - data->actstart;
-	if (IS_EQ(actlen, 0.0f)) actlen= 1.0f;
-	
-	/* now, adjust the 'scale' setting to reflect this (so that this change can be valid) */
-	data->scale= len / ((actlen) * data->repeat);
+	if (data->type == NLASTRIP_TYPE_CLIP) {
+		float len, actlen;
+		
+		len= data->end - data->start;
+		actlen= data->actend - data->actstart;
+		if (IS_EQ(actlen, 0.0f)) actlen= 1.0f;
+		
+		/* now, adjust the 'scale' setting to reflect this (so that this change can be valid) */
+		data->scale= len / ((actlen) * data->repeat);
+	}
 }
 
 static void rna_NlaStrip_scale_set(PointerRNA *ptr, float value)





More information about the Bf-blender-cvs mailing list