[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18587] branches/blender2.5/blender/source /blender: Animato - More work on Action Editor

Joshua Leung aligorith at gmail.com
Tue Jan 20 12:56:46 CET 2009


Revision: 18587
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18587
Author:   aligorith
Date:     2009-01-20 12:56:45 +0100 (Tue, 20 Jan 2009)

Log Message:
-----------
Animato - More work on Action Editor 

* Added back Auto Preview-Range tool (i.e. set preview-range from keyframe extents)

* Restored delete keyframe tool. For now, this doesn't delete empty F-Curves, even though its keyframe-api counterpart still does. I still need to figure out how to do this in the best way.

* Fixed crashes when selecting keyframes in 'object' summary channels

* Removed prototypes for a few unused/depreceated functions...

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
    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_select.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h	2009-01-20 11:54:00 UTC (rev 18586)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h	2009-01-20 11:56:45 UTC (rev 18587)
@@ -85,6 +85,9 @@
 /* find matching F-Curve in the given list of F-Curves */
 struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index);
 
+/* get the time extents for F-Curve */
+void calc_fcurve_range(struct FCurve *fcu, float *min, float *max);
+
 /* -------- Curve Sanity --------  */
 
 void calchandles_fcurve(struct FCurve *fcu);

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c	2009-01-20 11:54:00 UTC (rev 18586)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c	2009-01-20 11:56:45 UTC (rev 18587)
@@ -169,6 +169,37 @@
 	return NULL;
 }
 
+/* Calculate the extents of F-Curve's keyframes */
+void calc_fcurve_range (FCurve *fcu, float *start, float *end)
+{
+	float min=999999999.0f, max=-999999999.0f;
+	short foundvert=0;
+
+	if (fcu->totvert) {
+		if (fcu->bezt) {
+			min= MIN2(min, fcu->bezt[0].vec[1][0]);
+			max= MAX2(max, fcu->bezt[fcu->totvert-1].vec[1][0]);
+		}
+		else if (fcu->fpt) {
+			min= MIN2(min, fcu->fpt[0].vec[0]);
+			max= MAX2(max, fcu->fpt[fcu->totvert-1].vec[0]);
+		}
+		
+		foundvert=1;
+	}
+	
+	/* minimum length is 1 frame */
+	if (foundvert) {
+		if (min == max) max += 1.0f;
+		*start= min;
+		*end= max;
+	}
+	else {
+		*start= 0.0f;
+		*end= 1.0f;
+	}
+}
+
 /* ***************************** Keyframe Column Tools ********************************* */
 
 /* add a BezTriple to a column */

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-20 11:54:00 UTC (rev 18586)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_general.c	2009-01-20 11:56:45 UTC (rev 18587)
@@ -89,73 +89,62 @@
 		calchandles_fcurve(fcu);
 }
 
-#if 0 // XXX obsolete
-/* Delete selected keyframes in given IPO block */
-void delete_ipo_keys(Ipo *ipo)
+/* Delete selected keyframes in given F-Curve */
+void delete_fcurve_keys(FCurve *fcu)
 {
-	IpoCurve *icu, *next;
 	int i;
 	
-	if (ipo == NULL)
-		return;
-	
-	for (icu= ipo->curve.first; icu; icu= next) {
-		/* store pointer to next ipo-curve, as we may delete the current one */
-		next = icu->next;
-		
-		/* Delete selected BezTriples */
-		for (i=0; i<icu->totvert; i++) {
-			if (icu->bezt[i].f2 & SELECT) {
-				memmove(&icu->bezt[i], &icu->bezt[i+1], sizeof(BezTriple)*(icu->totvert-i-1));
-				icu->totvert--;
-				i--;
-			}
+	/* Delete selected BezTriples */
+	for (i=0; i < fcu->totvert; i++) {
+		if (fcu->bezt[i].f2 & SELECT) {
+			memmove(&fcu->bezt[i], &fcu->bezt[i+1], sizeof(BezTriple)*(fcu->totvert-i-1));
+			fcu->totvert--;
+			i--;
 		}
-		
-		/* Only delete if there isn't an ipo-driver still hanging around on an empty curve */
-		if ((icu->totvert==0) && (icu->driver==NULL)) {
-			BLI_remlink(&ipo->curve, icu);
-			free_ipo_curve(icu);
-		}
 	}
+	
+#if 0 // XXX for now, we don't get rid of empty curves...
+	/* Only delete if there isn't an ipo-driver still hanging around on an empty curve */
+	if ((icu->totvert==0) && (icu->driver==NULL)) {
+		BLI_remlink(&ipo->curve, icu);
+		free_ipo_curve(icu);
+	}
+#endif 
 }
-#endif // XXX obsolete
 
 /* ---------------- */
 
-/* duplicate selected keyframes for the given IPO block */
-void duplicate_ipo_keys(Ipo *ipo)
+/* duplicate selected keyframes for the given F-Curve */
+void duplicate_fcurve_keys(FCurve *fcu)
 {
-	IpoCurve *icu;
 	BezTriple *newbezt;
 	int i;
 
-	if (ipo == NULL)
+	if (fcu == NULL)
 		return;
-
-	for (icu= ipo->curve.first; icu; icu= icu->next) {
-		for (i=0; i<icu->totvert; i++) {
-			/* If a key is selected */
-			if (icu->bezt[i].f2 & SELECT) {
-				/* Expand the list */
-				newbezt = MEM_callocN(sizeof(BezTriple) * (icu->totvert+1), "beztriple");
-				
-				memcpy(newbezt, icu->bezt, sizeof(BezTriple) * (i+1));
-				memcpy(newbezt+i+1, icu->bezt+i, sizeof(BezTriple));
-				memcpy(newbezt+i+2, icu->bezt+i+1, sizeof (BezTriple) *(icu->totvert-(i+1)));
-				icu->totvert++;
-				
-				/* reassign pointers... (free old, and add new) */
-				MEM_freeN(icu->bezt);
-				icu->bezt=newbezt;
-				
-				/* Unselect the current key*/
-				BEZ_DESEL(&icu->bezt[i]);
-				i++;
-				
-				/* Select the copied key */
-				BEZ_SEL(&icu->bezt[i]);
-			}
+	
+	// XXX this does not take into account sample data...
+	for (i=0; i < fcu->totvert; i++) {
+		/* If a key is selected */
+		if (fcu->bezt[i].f2 & SELECT) {
+			/* Expand the list */
+			newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert+1), "beztriple");
+			
+			memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i+1));
+			memcpy(newbezt+i+1, fcu->bezt+i, sizeof(BezTriple));
+			memcpy(newbezt+i+2, fcu->bezt+i+1, sizeof (BezTriple) *(fcu->totvert-(i+1)));
+			fcu->totvert++;
+			
+			/* reassign pointers... (free old, and add new) */
+			MEM_freeN(fcu->bezt);
+			fcu->bezt=newbezt;
+			
+			/* Unselect the current key */
+			BEZ_DESEL(&fcu->bezt[i]);
+			i++;
+			
+			/* Select the copied key */
+			BEZ_SEL(&fcu->bezt[i]);
 		}
 	}
 }

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-20 11:54:00 UTC (rev 18586)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2009-01-20 11:56:45 UTC (rev 18587)
@@ -126,21 +126,11 @@
 
 void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc);
 void delete_fcurve_keys(struct FCurve *fcu);
-void duplicate_ipo_keys(struct Ipo *ipo);
+void duplicate_fcurve_keys(struct FCurve *fcu); // XXX fixme...
 
 void clean_fcurve(struct FCurve *fcu, float thresh);
 void smooth_fcurve(struct FCurve *fcu, short mode);
 
 /* ************************************************ */
 
-// XXX all of these funcs should be depreceated or at least renamed!
-
-/* in keyframes_edit.c */
-short is_ipo_key_selected(struct Ipo *ipo);
-void set_ipo_key_selection(struct Ipo *ipo, short sel);
-
-
-
-/* ************************************************ */
-
 #endif /* ED_KEYFRAMES_EDIT_H */

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-20 11:54:00 UTC (rev 18586)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c	2009-01-20 11:56:45 UTC (rev 18587)
@@ -109,11 +109,11 @@
 		/* go through channels, finding max extents */
 		for (ale= anim_data.first; ale; ale= ale->next) {
 			Object *nob= ANIM_nla_mapping_get(ac, ale);
-			//Ipo *ipo= (Ipo *)ale->key_data;  // XXX fixme
+			FCurve *fcu= (FCurve *)ale->key_data;
 			float tmin, tmax;
 			
 			/* get range and apply necessary scaling before */
-			//calc_ipo_range(ipo, &tmin, &tmax);
+			calc_fcurve_range(fcu, &tmin, &tmax);
 			tmin= tmax= 0.0f; // xxx
 			
 			if (nob) {
@@ -608,7 +608,7 @@
 		//if (ale->type == ANIMTYPE_GPLAYER)
 		//	delete_gplayer_frames((bGPDlayer *)ale->data);
 		//else
-		//	delete_ipo_keys((Ipo *)ale->key_data); // XXX fixme for the new animsys...
+			delete_fcurve_keys((FCurve *)ale->key_data); // XXX... this doesn't delete empty curves anymore
 	}
 	
 	/* free filtered list */

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_select.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_select.c	2009-01-20 11:54:00 UTC (rev 18586)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_select.c	2009-01-20 11:56:45 UTC (rev 18587)
@@ -198,7 +198,7 @@
 		
 		/* figure out what to return */
 		if (ac->datatype == ANIMCONT_ACTION) {
-			*par= ale->owner; /* assume that this is an action channel */
+			*par= ale->owner; /* assume that this is an action group */
 			*ret_type= ale->type;
 			data = ale->data;
 		}
@@ -863,11 +863,11 @@
 		ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
 	else if (agrp) {
 		for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next)
-			ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, select_cb, NULL);
+			ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
 	}
 	else if (act) {
 		for (fcu= act->curves.first; fcu; fcu= fcu->next)
-			ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, select_cb, NULL);
+			ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
 	}
 	else if (ob) {
 		AnimData *adt;
@@ -875,12 +875,13 @@
 		/* Object's own animation */
 		if (ob->adt && ob->adt->action) {
 			adt= ob->adt;
+			act= adt->action;
 			
 			selxa= get_action_frame(ob, selx); // xxx
 			bed.f1= selxa;
 			
 			for (fcu= act->curves.first; fcu; fcu= fcu->next)
-			ANIM_fcurve_keys_bezier_loop(&bed, fcu, NULL, select_cb, NULL);
+				ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL);
 		}
 		
 		/* 'Sub-Object' animation data */





More information about the Bf-blender-cvs mailing list