[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18712] branches/blender2.5/blender/source /blender/editors: Graph Editor: Restoring most tools

Joshua Leung aligorith at gmail.com
Wed Jan 28 10:55:41 CET 2009


Revision: 18712
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18712
Author:   aligorith
Date:     2009-01-28 10:55:36 +0100 (Wed, 28 Jan 2009)

Log Message:
-----------
Graph Editor: Restoring most tools

* Copy/Paste still needs to be cleaned up to be functional. Auto-set preview range + View All also need some work to become functional...
* Smooth has been moved to Alt-O hotkey, as Shift-O was taken for Sample 
* Renamed a few operators for DopeSheet to be more in line with Graph Editor ones, and to be less obscure.
* The 'join' and 'remove doubles' tools are not likely to be restored. I think that a few of the new tools cover this lack anyway. We can restore them if there is a real need.

* Record tool needs a rethink to be genuinely useful, so it's not included here anymore.
A note for anyone wanting to play with implementing this: store the sampled points using the new FPoint type in the FCurve instead of using BezTriples, as FPoints are used for storing sampled/baked data. 

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/keyframes_general.c
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
    branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_edit.c
    branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_intern.h
    branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_generics.c

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_general.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_general.c	2009-01-28 09:32:31 UTC (rev 18711)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_general.c	2009-01-28 09:55:36 UTC (rev 18712)
@@ -152,11 +152,6 @@
 /* **************************************************** */
 /* Various Tools */
 
-// XXX - stub... until keyframing code is fixed...
-static void insert_vert_fcu(FCurve *fcu, float x, float y, short flag)
-{
-}
-
 /* Basic IPO-Curve 'cleanup' function that removes 'double points' and unnecessary keyframes on linear-segments only */
 void clean_fcurve(FCurve *fcu, float thresh)
 {
@@ -176,7 +171,7 @@
 	
 	/* now insert first keyframe, as it should be ok */
 	bezt = old_bezts;
-	insert_vert_fcu(fcu, bezt->vec[1][0], bezt->vec[1][1], 0);
+	insert_vert_fcurve(fcu, bezt->vec[1][0], bezt->vec[1][1], 0);
 	
 	/* Loop through BezTriples, comparing them. Skip any that do 
 	 * not fit the criteria for "ok" points.
@@ -213,7 +208,7 @@
 				if (cur[1] > next[1]) {
 					if (IS_EQT(cur[1], prev[1], thresh) == 0) {
 						/* add new keyframe */
-						insert_vert_fcu(fcu, cur[0], cur[1], 0);
+						insert_vert_fcurve(fcu, cur[0], cur[1], 0);
 					}
 				}
 			}
@@ -221,7 +216,7 @@
 				/* only add if values are a considerable distance apart */
 				if (IS_EQT(cur[1], prev[1], thresh) == 0) {
 					/* add new keyframe */
-					insert_vert_fcu(fcu, cur[0], cur[1], 0);
+					insert_vert_fcurve(fcu, cur[0], cur[1], 0);
 				}
 			}
 		}
@@ -231,18 +226,18 @@
 				/* does current have same value as previous and next? */
 				if (IS_EQT(cur[1], prev[1], thresh) == 0) {
 					/* add new keyframe*/
-					insert_vert_fcu(fcu, cur[0], cur[1], 0);
+					insert_vert_fcurve(fcu, cur[0], cur[1], 0);
 				}
 				else if (IS_EQT(cur[1], next[1], thresh) == 0) {
 					/* add new keyframe */
-					insert_vert_fcu(fcu, cur[0], cur[1], 0);
+					insert_vert_fcurve(fcu, cur[0], cur[1], 0);
 				}
 			}
 			else {	
 				/* add if value doesn't equal that of previous */
 				if (IS_EQT(cur[1], prev[1], thresh) == 0) {
 					/* add new keyframe */
-					insert_vert_fcu(fcu, cur[0], cur[1], 0);
+					insert_vert_fcurve(fcu, cur[0], cur[1], 0);
 				}
 			}
 		}
@@ -261,8 +256,7 @@
 } tSmooth_Bezt;
 
 /* Use a weighted moving-means method to reduce intensity of fluctuations */
-//mode= pupmenu("Smooth F-Curve%t|Tweak Points%x1|Flatten Handles%x2");
-void smooth_fcurve(FCurve *fcu, short mode)
+void smooth_fcurve (FCurve *fcu)
 {
 	BezTriple *bezt;
 	int i, x, totSel = 0;
@@ -283,8 +277,6 @@
 		}
 	}
 	
-	/* check if adjust values too... */
-	if (mode == 2) {
 		/* if any points were selected, allocate tSmooth_Bezt points to work on */
 		if (totSel >= 3) {
 			tSmooth_Bezt *tarray, *tsb;
@@ -309,51 +301,50 @@
 				}
 			}
 			
-			/* calculate the new smoothed ipo's with weighted averages:
-			 *	- this is done with two passes
-			 *	- uses 5 points for each operation (which stores in the relevant handles)
-			 *	-	previous: w/a ratio = 3:5:2:1:1
-			 *	- 	next: w/a ratio = 1:1:2:5:3
-			 */
+	/* calculate the new smoothed F-Curve's with weighted averages:
+	 *	- this is done with two passes
+	 *	- uses 5 points for each operation (which stores in the relevant handles)
+	 *	-	previous: w/a ratio = 3:5:2:1:1
+	 *	- 	next: w/a ratio = 1:1:2:5:3
+	 */
+	
+	/* round 1: calculate previous and next */ 
+	tsb= tarray;
+	for (i=0; i < totSel; i++, tsb++) {
+		/* don't touch end points (otherwise, curves slowly explode) */
+		if (ELEM(i, 0, (totSel-1)) == 0) {
+			const tSmooth_Bezt *tP1 = tsb - 1;
+			const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL);
+			const tSmooth_Bezt *tN1 = tsb + 1;
+			const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL);
 			
-			/* round 1: calculate previous and next */ 
-			tsb= tarray;
-			for (i=0; i < totSel; i++, tsb++) {
-				/* don't touch end points (otherwise, curves slowly explode) */
-				if (ELEM(i, 0, (totSel-1)) == 0) {
-					const tSmooth_Bezt *tP1 = tsb - 1;
-					const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL);
-					const tSmooth_Bezt *tN1 = tsb + 1;
-					const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL);
-					
-					const float p1 = *tP1->h2;
-					const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2);
-					const float c1 = *tsb->h2;
-					const float n1 = *tN1->h2;
-					const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2);
-					
-					/* calculate previous and next */
-					*tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12;
-					*tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12;
-				}
-			}
+			const float p1 = *tP1->h2;
+			const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2);
+			const float c1 = *tsb->h2;
+			const float n1 = *tN1->h2;
+			const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2);
 			
-			/* round 2: calculate new values and reset handles */
-			tsb= tarray;
-			for (i=0; i < totSel; i++, tsb++) {
-				/* calculate new position by averaging handles */
-				*tsb->h2 = (*tsb->h1 + *tsb->h3) / 2;
-				
-				/* reset handles now */
-				*tsb->h1 = *tsb->h2;
-				*tsb->h3 = *tsb->h2;
-			}
-			
-			/* free memory required for tarray */
-			MEM_freeN(tarray);
+			/* calculate previous and next */
+			*tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12;
+			*tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12;
 		}
 	}
 	
+	/* round 2: calculate new values and reset handles */
+	tsb= tarray;
+	for (i=0; i < totSel; i++, tsb++) {
+		/* calculate new position by averaging handles */
+		*tsb->h2 = (*tsb->h1 + *tsb->h3) / 2;
+		
+		/* reset handles now */
+		*tsb->h1 = *tsb->h2;
+		*tsb->h3 = *tsb->h2;
+	}
+	
+	/* free memory required for tarray */
+	MEM_freeN(tarray);
+}
+	
 	/* recalculate handles */
 	calchandles_fcurve(fcu);
 }

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2009-01-28 09:32:31 UTC (rev 18711)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2009-01-28 09:55:36 UTC (rev 18712)
@@ -132,7 +132,7 @@
 void duplicate_fcurve_keys(struct FCurve *fcu);
 
 void clean_fcurve(struct FCurve *fcu, float thresh);
-void smooth_fcurve(struct FCurve *fcu, short mode);
+void smooth_fcurve(struct FCurve *fcu);
 
 /* ************************************************ */
 

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c	2009-01-28 09:32:31 UTC (rev 18711)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c	2009-01-28 09:55:36 UTC (rev 18712)
@@ -627,6 +627,7 @@
 	ot->idname= "ACT_OT_keyframes_delete";
 	
 	/* api callbacks */
+	ot->invoke= WM_operator_confirm;
 	ot->exec= actkeys_delete_exec;
 	ot->poll= ED_operator_areaactive;
 	
@@ -825,8 +826,6 @@
 
 /* ******************** Set Extrapolation-Type Operator *********************** */
 
-// XXX rename this operator...
-
 /* defines for set extrapolation-type for selected keyframes tool */
 EnumPropertyItem prop_actkeys_expo_types[] = {
 	{FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", "Constant Extrapolation", ""},
@@ -883,11 +882,11 @@
 	return OPERATOR_FINISHED;
 }
  
-void ACT_OT_keyframes_expotype (wmOperatorType *ot)
+void ACT_OT_keyframes_extrapolation_type (wmOperatorType *ot)
 {
 	/* identifiers */
 	ot->name= "Set Keyframe Extrapolation";
-	ot->idname= "ACT_OT_keyframes_expotype";
+	ot->idname= "ACT_OT_keyframes_extrapolation_type";
 	
 	/* api callbacks */
 	ot->invoke= WM_menu_invoke;
@@ -961,11 +960,11 @@
 	return OPERATOR_FINISHED;
 }
  
-void ACT_OT_keyframes_ipotype (wmOperatorType *ot)
+void ACT_OT_keyframes_interpolation_type (wmOperatorType *ot)
 {
 	/* identifiers */
 	ot->name= "Set Keyframe Interpolation";
-	ot->idname= "ACT_OT_keyframes_ipotype";
+	ot->idname= "ACT_OT_keyframes_interpolation_type";
 	
 	/* api callbacks */
 	ot->invoke= WM_menu_invoke;

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h	2009-01-28 09:32:31 UTC (rev 18711)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h	2009-01-28 09:55:36 UTC (rev 18712)
@@ -88,8 +88,8 @@
 void ACT_OT_keyframes_sample(struct wmOperatorType *ot);
 
 void ACT_OT_keyframes_handletype(struct wmOperatorType *ot);
-void ACT_OT_keyframes_ipotype(struct wmOperatorType *ot);
-void ACT_OT_keyframes_expotype(struct wmOperatorType *ot);
+void ACT_OT_keyframes_interpolation_type(struct wmOperatorType *ot);
+void ACT_OT_keyframes_extrapolation_type(struct wmOperatorType *ot);
 
 void ACT_OT_keyframes_cfrasnap(struct wmOperatorType *ot);
 void ACT_OT_keyframes_snap(struct wmOperatorType *ot);

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c	2009-01-28 09:32:31 UTC (rev 18711)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c	2009-01-28 09:55:36 UTC (rev 18712)
@@ -73,8 +73,8 @@
 	WM_operatortype_append(ACT_OT_keyframes_mirror);
 	WM_operatortype_append(ACT_OT_keyframes_cfrasnap);
 	WM_operatortype_append(ACT_OT_keyframes_handletype);
-	WM_operatortype_append(ACT_OT_keyframes_ipotype);
-	WM_operatortype_append(ACT_OT_keyframes_expotype);
+	WM_operatortype_append(ACT_OT_keyframes_interpolation_type);
+	WM_operatortype_append(ACT_OT_keyframes_extrapolation_type);
 	WM_operatortype_append(ACT_OT_keyframes_sample);
 	WM_operatortype_append(ACT_OT_keyframes_clean);
 	WM_operatortype_append(ACT_OT_keyframes_delete);
@@ -121,8 +121,8 @@
 	
 		/* menu + set setting */
 	WM_keymap_add_item(keymap, "ACT_OT_keyframes_handletype", HKEY, KM_PRESS, 0, 0);
-	WM_keymap_add_item(keymap, "ACT_OT_keyframes_ipotype", TKEY, KM_PRESS, KM_SHIFT, 0);
-	WM_keymap_add_item(keymap, "ACT_OT_keyframes_expotype", EKEY, KM_PRESS, KM_SHIFT, 0); // temp...

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list