[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13306] trunk/blender/source/blender/src/ editaction.c: == Action Editor - Copy/Paste Improvements ==

Joshua Leung aligorith at gmail.com
Sun Jan 20 06:10:35 CET 2008


Revision: 13306
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13306
Author:   aligorith
Date:     2008-01-20 06:10:35 +0100 (Sun, 20 Jan 2008)

Log Message:
-----------
== Action Editor - Copy/Paste Improvements ==

Changed the way the offsetting of pasted keys relative to the current time works. Now, all pasted frames are offset by the same amount. This is calculated as the difference in the times of the current frame and the 'first keyframe' (i.e. the earliest one in all channels to be pasted). The 'first keyframe' is found when doing the copying.  

Modified Paths:
--------------
    trunk/blender/source/blender/src/editaction.c

Modified: trunk/blender/source/blender/src/editaction.c
===================================================================
--- trunk/blender/source/blender/src/editaction.c	2008-01-20 04:39:50 UTC (rev 13305)
+++ trunk/blender/source/blender/src/editaction.c	2008-01-20 05:10:35 UTC (rev 13306)
@@ -1582,10 +1582,15 @@
 /* - The copy/paste buffer currently stores a set of Action Channels, with temporary
  *	IPO-blocks, and also temporary IpoCurves which only contain the selected keyframes.
  * - Only pastes between compatable data is possible (i.e. same achan->name, ipo-curve type, etc.)
+ *	Unless there is only one element in the buffer, names are also tested to check for compatability.
+ * - All pasted frames are offset by the same amount. This is calculated as the difference in the times of
+ *	the current frame and the 'first keyframe' (i.e. the earliest one in all channels).
+ * - The earliest frame is calculated per copy operation.
  */
 
 /* globals for copy/paste data (like for other copy/paste buffers) */
 ListBase actcopybuf = {NULL, NULL};
+static float actcopy_firstframe= 999999999.0f;
 
 /* This function frees any MEM_calloc'ed copy/paste buffer data */
 void free_actcopybuf ()
@@ -1616,6 +1621,7 @@
 	}
 	
 	actcopybuf.first= actcopybuf.last= NULL;
+	actcopy_firstframe= 999999999.0f;
 }
 
 /* This function adds data to the copy/paste buffer, freeing existing data first
@@ -1687,10 +1693,16 @@
 			icn->adrcode = icu->adrcode;
 			BLI_addtail(&ipn->curve, icn);
 			
-			/* find selected BezTriples to add to the buffer */
+			/* find selected BezTriples to add to the buffer (and set first frame) */
 			for (i=0, bezt=icu->bezt; i < icu->totvert; i++, bezt++) {
-				if (BEZSELECTED(bezt))
+				if (BEZSELECTED(bezt)) {
+					/* add to buffer ipo-curve */
 					insert_bezt_icu(icn, bezt);
+					
+					/* check if this is the earliest frame encountered so far */
+					if (bezt->vec[1][0] < actcopy_firstframe)
+						actcopy_firstframe= bezt->vec[1][0];
+				}
 			}
 		}
 	}
@@ -1710,7 +1722,9 @@
 	int filter;
 	void *data;
 	short datatype;
+	
 	short no_name= 0;
+	float offset = CFRA - actcopy_firstframe;
 	
 	/* check if buffer is empty */
 	if (ELEM(NULL, actcopybuf.first, actcopybuf.last)) {
@@ -1736,8 +1750,6 @@
 		IpoCurve *ico, *icu;
 		BezTriple *bezt;
 		int i;
-		float offset= 0.0f;
-		short offsetInit= 1;
 		
 		/* find matching ipo-block */
 		for (achan= actcopybuf.first; achan; achan= achan->next) {
@@ -1785,13 +1797,7 @@
 				/* only paste if compatable blocktype + adrcode */
 				if ((ico->blocktype==icu->blocktype) && (ico->adrcode==icu->adrcode)) {
 					/* just start pasting, with the the first keyframe on the current frame, and so on */
-					for (i=0, bezt=ico->bezt; i < ico->totvert; i++, bezt++) {
-						/* initialise offset (if not already done) */
-						if (offsetInit) {
-							offset= CFRA - bezt->vec[1][0];
-							offsetInit= 0;
-						}
-						
+					for (i=0, bezt=ico->bezt; i < ico->totvert; i++, bezt++) {						
 						/* temporarily apply offset to src beztriple while copying */
 						bezt->vec[0][0] += offset;
 						bezt->vec[1][0] += offset;





More information about the Bf-blender-cvs mailing list