[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21545] branches/blender2.5/blender/source /blender/editors: 2. 5 - Tweaks for Split Strips in NLA and Graph Editor view ranges

Joshua Leung aligorith at gmail.com
Sun Jul 12 09:28:25 CEST 2009


Revision: 21545
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21545
Author:   aligorith
Date:     2009-07-12 09:28:25 +0200 (Sun, 12 Jul 2009)

Log Message:
-----------
2.5 - Tweaks for Split Strips in NLA and Graph Editor view ranges

* Split strips now uses the current frame as the splitting-point for selected strips if the current frame falls within in the bounds of the strip. Otherwise, the code defaults to splitting by the midpoints of the strips.

* Time-range for Graph Editor is saner now when there is only a single keyframe or none at all.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/space_graph/space_graph.c
    branches/blender2.5/blender/source/blender/editors/space_nla/nla_edit.c

Modified: branches/blender2.5/blender/source/blender/editors/space_graph/space_graph.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_graph/space_graph.c	2009-07-12 07:20:49 UTC (rev 21544)
+++ branches/blender2.5/blender/source/blender/editors/space_graph/space_graph.c	2009-07-12 07:28:25 UTC (rev 21545)
@@ -68,14 +68,16 @@
 {
 	ARegion *ar, *arnew;
 	
-	for(ar= sa->regionbase.first; ar; ar= ar->next)
+	for (ar= sa->regionbase.first; ar; ar= ar->next) {
 		if(ar->regiontype==RGN_TYPE_UI)
 			return ar;
+	}
 	
 	/* add subdiv level; after main window */
-	for(ar= sa->regionbase.first; ar; ar= ar->next)
+	for (ar= sa->regionbase.first; ar; ar= ar->next) {
 		if(ar->regiontype==RGN_TYPE_WINDOW)
 			break;
+	}
 	
 	/* is error! */
 	if(ar==NULL) return NULL;
@@ -246,7 +248,9 @@
 		
 		/* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
 		get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax);
-
+		/* extra offset so that these items are visible */
+		v2d->tot.xmin -= 10.0f;
+		v2d->tot.xmax += 10.0f;
 	}
 	
 	/* only free grid after drawing data, as we need to use it to determine sampling rate */

Modified: branches/blender2.5/blender/source/blender/editors/space_nla/nla_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_nla/nla_edit.c	2009-07-12 07:20:49 UTC (rev 21544)
+++ branches/blender2.5/blender/source/blender/editors/space_nla/nla_edit.c	2009-07-12 07:28:25 UTC (rev 21545)
@@ -747,25 +747,37 @@
 //	- variable-length splits?
 
 /* split a given Action-Clip strip */
-static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip)
+static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, float cfra)
 {
 	NlaStrip *nstrip;
-	float midframe, midaframe, len;
+	float splitframe, splitaframe;
 	
-	/* calculate the frames to do the splitting at */
-		/* strip extents */
-	len= strip->end - strip->start;
-	if (IS_EQ(len, 0.0f)) 
-		return;
-	else
-		midframe= strip->start + (len / 2.0f);
-		
-		/* action range */
-	len= strip->actend - strip->actstart;
-	if (IS_EQ(len, 0.0f))
-		midaframe= strip->actend;
-	else
-		midaframe= strip->actstart + (len / 2.0f);
+	/* calculate the frames to do the splitting at 
+	 *	- use current frame if within extents of strip 
+	 */
+	if ((cfra > strip->start) && (cfra < strip->end)) {
+		/* use the current frame */
+		splitframe= cfra;
+		splitaframe= nlastrip_get_frame(strip, cfra, NLATIME_CONVERT_UNMAP);
+	}
+	else {
+		/* split in the middle */
+		float len;
+			
+			/* strip extents */
+		len= strip->end - strip->start;
+		if (IS_EQ(len, 0.0f)) 
+			return;
+		else
+			splitframe= strip->start + (len / 2.0f);
+			
+			/* action range */
+		len= strip->actend - strip->actstart;
+		if (IS_EQ(len, 0.0f))
+			splitaframe= strip->actend;
+		else
+			splitaframe= strip->actstart + (len / 2.0f);
+	}
 	
 	/* make a copy (assume that this is possible) and append
 	 * it immediately after the current strip
@@ -774,13 +786,16 @@
 	BLI_insertlinkafter(&nlt->strips, strip, nstrip);
 	
 	/* set the endpoint of the first strip and the start of the new strip 
-	 * to the midframe values calculated above
+	 * to the splitframe values calculated above
 	 */
-	strip->end= midframe;
-	nstrip->start= midframe;
+	strip->end= splitframe;
+	nstrip->start= splitframe;
 	
-	strip->actend= midaframe;
-	nstrip->actstart= midaframe;
+	if ((splitaframe > strip->actstart) && (splitaframe < strip->actend)) {
+		/* only do this if we're splitting down the middle...  */
+		strip->actend= splitaframe;
+		nstrip->actstart= splitaframe;
+	}
 	
 	/* clear the active flag from the copy */
 	nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE;
@@ -828,7 +843,7 @@
 				/* splitting method depends on the type of strip */
 				switch (strip->type) {
 					case NLASTRIP_TYPE_CLIP: /* action-clip */
-						nlaedit_split_strip_actclip(adt, nlt, strip);
+						nlaedit_split_strip_actclip(adt, nlt, strip, (float)ac.scene->r.cfra);
 						break;
 						
 					case NLASTRIP_TYPE_META: /* meta-strips need special handling */





More information about the Bf-blender-cvs mailing list