[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41245] trunk/blender/source/blender: fix [#28961] FCurves.range() returns wrong values for one-point curves (sic!)

Campbell Barton ideasman42 at gmail.com
Mon Oct 24 14:26:15 CEST 2011


Revision: 41245
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41245
Author:   campbellbarton
Date:     2011-10-24 12:26:14 +0000 (Mon, 24 Oct 2011)
Log Message:
-----------
fix [#28961] FCurves.range() returns wrong values for one-point curves (sic!)
also fix for case where verts were treated as found but were infact not because none were selected.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_fcurve.h
    trunk/blender/source/blender/blenkernel/intern/action.c
    trunk/blender/source/blender/blenkernel/intern/fcurve.c
    trunk/blender/source/blender/editors/space_action/action_edit.c
    trunk/blender/source/blender/makesrna/intern/rna_fcurve.c

Modified: trunk/blender/source/blender/blenkernel/BKE_fcurve.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_fcurve.h	2011-10-24 10:26:37 UTC (rev 41244)
+++ trunk/blender/source/blender/blenkernel/BKE_fcurve.h	2011-10-24 12:26:14 UTC (rev 41245)
@@ -213,10 +213,12 @@
 int binarysearch_bezt_index(struct BezTriple array[], float frame, int arraylen, short *replace);
 
 /* get the time extents for F-Curve */
-void calc_fcurve_range(struct FCurve *fcu, float *min, float *max, const short selOnly);
+void calc_fcurve_range(struct FCurve *fcu, float *min, float *max,
+                       const short do_sel_only, const short do_min_length);
 
 /* get the bounding-box extents for F-Curve */
-void calc_fcurve_bounds(struct FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax, const short selOnly);
+void calc_fcurve_bounds(struct FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax,
+                        const short do_sel_only);
 
 /* .............. */
 

Modified: trunk/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/action.c	2011-10-24 10:26:37 UTC (rev 41244)
+++ trunk/blender/source/blender/blenkernel/intern/action.c	2011-10-24 12:26:14 UTC (rev 41245)
@@ -881,7 +881,7 @@
 				
 				/* get extents for this curve */
 				// TODO: allow enabling/disabling this?
-				calc_fcurve_range(fcu, &nmin, &nmax, FALSE);
+				calc_fcurve_range(fcu, &nmin, &nmax, FALSE, TRUE);
 				
 				/* compare to the running tally */
 				min= MIN2(min, nmin);

Modified: trunk/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fcurve.c	2011-10-24 10:26:37 UTC (rev 41244)
+++ trunk/blender/source/blender/blenkernel/intern/fcurve.c	2011-10-24 12:26:14 UTC (rev 41245)
@@ -433,7 +433,8 @@
 /* ...................................... */
 
 /* helper for calc_fcurve_* functions -> find first and last BezTriple to be used */
-static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple **last, const short selOnly)
+static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple **last,
+                                      const short do_sel_only)
 {
 	/* init outputs */
 	*first = NULL;
@@ -444,7 +445,7 @@
 		return;
 	
 	/* only include selected items? */
-	if (selOnly) {
+	if (do_sel_only) {
 		BezTriple *bezt;
 		unsigned int i;
 		
@@ -475,11 +476,12 @@
 
 
 /* Calculate the extents of F-Curve's data */
-void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax, const short selOnly)
+void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax,
+                         const short do_sel_only)
 {
 	float xminv=999999999.0f, xmaxv=-999999999.0f;
 	float yminv=999999999.0f, ymaxv=-999999999.0f;
-	short foundvert=0;
+	short foundvert= FALSE;
 	unsigned int i;
 	
 	if (fcu->totvert) {
@@ -488,7 +490,7 @@
 			
 			if (xmin || xmax) {
 				/* get endpoint keyframes */
-				get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, selOnly);
+				get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only);
 				
 				if (bezt_first) {
 					BLI_assert(bezt_last != NULL);
@@ -503,11 +505,12 @@
 				BezTriple *bezt;
 				
 				for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) {
-					if ((selOnly == 0) || BEZSELECTED(bezt)) {
+					if ((do_sel_only == 0) || BEZSELECTED(bezt)) {
 						if (bezt->vec[1][1] < yminv)
 							yminv= bezt->vec[1][1];
 						if (bezt->vec[1][1] > ymaxv)
 							ymaxv= bezt->vec[1][1];
+						foundvert= TRUE;
 					}
 				}
 			}
@@ -528,11 +531,11 @@
 						yminv= fpt->vec[1];
 					if (fpt->vec[1] > ymaxv)
 						ymaxv= fpt->vec[1];
+
+					foundvert= TRUE;
 				}
 			}
 		}
-		
-		foundvert=1;
 	}
 	
 	if (foundvert) {
@@ -555,43 +558,50 @@
 }
 
 /* Calculate the extents of F-Curve's keyframes */
-void calc_fcurve_range (FCurve *fcu, float *start, float *end, const short selOnly)
+void calc_fcurve_range (FCurve *fcu, float *start, float *end,
+                        const short do_sel_only, const short do_min_length)
 {
 	float min=999999999.0f, max=-999999999.0f;
-	short foundvert=0;
+	short foundvert= FALSE;
 
 	if (fcu->totvert) {
 		if (fcu->bezt) {
 			BezTriple *bezt_first= NULL, *bezt_last= NULL;
 			
 			/* get endpoint keyframes */
-			get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, selOnly);
-			
+			get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only);
+
 			if (bezt_first) {
 				BLI_assert(bezt_last != NULL);
-				
+
 				min= MIN2(min, bezt_first->vec[1][0]);
 				max= MAX2(max, bezt_last->vec[1][0]);
+
+				foundvert= TRUE;
 			}
 		}
 		else if (fcu->fpt) {
 			min= MIN2(min, fcu->fpt[0].vec[0]);
 			max= MAX2(max, fcu->fpt[fcu->totvert-1].vec[0]);
+
+			foundvert= TRUE;
 		}
 		
-		foundvert=1;
 	}
 	
-	/* minimum length is 1 frame */
-	if (foundvert) {
-		if (min == max) max += 1.0f;
-		*start= min;
-		*end= max;
+	if (foundvert == FALSE) {
+		min= max= 0.0f;
 	}
-	else {
-		*start= 0.0f;
-		*end= 1.0f;
+
+	if (do_min_length) {
+		/* minimum length is 1 frame */
+		if (min == max) {
+			max += 1.0f;
+		}
 	}
+
+	*start= min;
+	*end= max;
 }
 
 /* ----------------- Status Checks -------------------------- */

Modified: trunk/blender/source/blender/editors/space_action/action_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_edit.c	2011-10-24 10:26:37 UTC (rev 41244)
+++ trunk/blender/source/blender/editors/space_action/action_edit.c	2011-10-24 12:26:14 UTC (rev 41245)
@@ -261,7 +261,7 @@
 				float tmin, tmax;
 
 				/* get range and apply necessary scaling before processing */
-				calc_fcurve_range(fcu, &tmin, &tmax, onlySel);
+				calc_fcurve_range(fcu, &tmin, &tmax, onlySel, TRUE);
 
 				if (adt) {
 					tmin= BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP);

Modified: trunk/blender/source/blender/makesrna/intern/rna_fcurve.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_fcurve.c	2011-10-24 10:26:37 UTC (rev 41244)
+++ trunk/blender/source/blender/makesrna/intern/rna_fcurve.c	2011-10-24 12:26:14 UTC (rev 41245)
@@ -621,7 +621,7 @@
 
 static void rna_fcurve_range(FCurve *fcu, float range[2])
 {
-	calc_fcurve_range(fcu, range, range+1, FALSE);
+	calc_fcurve_range(fcu, range, range+1, FALSE, FALSE);
 }
 
 #else




More information about the Bf-blender-cvs mailing list