[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39022] branches/soc-2011-pepper/source/ blender: Bassam Feature Request: "Auto Clamped" handles can now be set per

Joshua Leung aligorith at gmail.com
Thu Aug 4 16:13:05 CEST 2011


Revision: 39022
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39022
Author:   aligorith
Date:     2011-08-04 14:13:05 +0000 (Thu, 04 Aug 2011)
Log Message:
-----------
Bassam Feature Request: "Auto Clamped" handles can now be set per
handle/key

This used to be a weird per-curve setting which would happen to get
applied/work correctly if handles were set to "auto", and was a source
of constant confusion for both old and new animators. The main effect
of this handle-type/option was really to just ensure that auto-handles
stayed horizontal, instead of tilting as the keys were moved.

This commit simply changes this from a per-curve to per
keyframe/handle setting.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/blenkernel/intern/curve.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/fcurve.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/ipo.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/nla.c
    branches/soc-2011-pepper/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-pepper/source/blender/editors/animation/drivers.c
    branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c
    branches/soc-2011-pepper/source/blender/editors/animation/keyframing.c
    branches/soc-2011-pepper/source/blender/editors/include/UI_resources.h
    branches/soc-2011-pepper/source/blender/editors/interface/resources.c
    branches/soc-2011-pepper/source/blender/editors/space_action/action_edit.c
    branches/soc-2011-pepper/source/blender/editors/space_graph/graph_edit.c
    branches/soc-2011-pepper/source/blender/makesdna/DNA_anim_types.h
    branches/soc-2011-pepper/source/blender/makesdna/DNA_curve_types.h
    branches/soc-2011-pepper/source/blender/makesdna/DNA_userdef_types.h
    branches/soc-2011-pepper/source/blender/makesrna/RNA_enum_types.h
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_curve.c
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_fcurve.c
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_userdef.c

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/curve.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/curve.c	2011-08-04 14:06:30 UTC (rev 39021)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/curve.c	2011-08-04 14:13:05 UTC (rev 39022)
@@ -2473,7 +2473,7 @@
 	if(len2==0.0f) len2=1.0f;
 
 
-	if(bezt->h1==HD_AUTO || bezt->h2==HD_AUTO) {    /* auto */
+	if(ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) || ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) {    /* auto */
 		vx= dx1/len2 + dx/len1;
 		vy= dy1/len2 + dy/len1;
 		vz= dz1/len2 + dz/len1;
@@ -2484,13 +2484,13 @@
 			if(len1>5.0f*len2) len1= 5.0f*len2;	
 			if(len2>5.0f*len1) len2= 5.0f*len1;
 			
-			if(bezt->h1==HD_AUTO) {
+			if(ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM)) {
 				len1/=len;
 				*(p2-3)= *p2-vx*len1;
 				*(p2-2)= *(p2+1)-vy*len1;
 				*(p2-1)= *(p2+2)-vz*len1;
 				
-				if(mode==2 && next && prev) {	// keep horizontal if extrema
+				if((bezt->h1==HD_AUTO_ANIM) && next && prev) {	// keep horizontal if extrema
 					float ydiff1= prev->vec[1][1] - bezt->vec[1][1];
 					float ydiff2= next->vec[1][1] - bezt->vec[1][1];
 					if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
@@ -2512,13 +2512,13 @@
 					}
 				}
 			}
-			if(bezt->h2==HD_AUTO) {
+			if(ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) {
 				len2/=len;
 				*(p2+3)= *p2+vx*len2;
 				*(p2+4)= *(p2+1)+vy*len2;
 				*(p2+5)= *(p2+2)+vz*len2;
 				
-				if(mode==2 && next && prev) {	// keep horizontal if extrema
+				if((bezt->h2==HD_AUTO_ANIM) && next && prev) {	// keep horizontal if extrema
 					float ydiff1= prev->vec[1][1] - bezt->vec[1][1];
 					float ydiff2= next->vec[1][1] - bezt->vec[1][1];
 					if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/fcurve.c	2011-08-04 14:06:30 UTC (rev 39021)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/fcurve.c	2011-08-04 14:13:05 UTC (rev 39022)
@@ -792,13 +792,10 @@
 		if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0]= bezt->vec[1][0];
 		
 		/* calculate auto-handles */
-		if (fcu->flag & FCURVE_AUTO_HANDLES) 
-			calchandleNurb(bezt, prev, next, 2);	/* 2==special autohandle && keep extrema horizontal */
-		else
-			calchandleNurb(bezt, prev, next, 1);	/* 1==special autohandle */
+		calchandleNurb(bezt, prev, next, 1);	/* 1==special autohandle */
 		
 		/* for automatic ease in and out */
-		if ((bezt->h1==HD_AUTO) && (bezt->h2==HD_AUTO)) {
+		if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) && ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) {
 			/* only do this on first or last beztriple */
 			if ((a == 0) || (a == fcu->totvert-1)) {
 				/* set both handles to have same horizontal value as keyframe */
@@ -846,9 +843,9 @@
 		/* one or two handles selected only */
 		if (ELEM(flag, 0, 7)==0) {
 			/* auto handles become aligned */
-			if (bezt->h1==HD_AUTO)
+			if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM))
 				bezt->h1= HD_ALIGN;
-			if (bezt->h2==HD_AUTO)
+			if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM))
 				bezt->h2= HD_ALIGN;
 			
 			/* vector handles become 'free' when only one half selected */

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/ipo.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/ipo.c	2011-08-04 14:06:30 UTC (rev 39021)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/ipo.c	2011-08-04 14:13:05 UTC (rev 39022)
@@ -1157,7 +1157,6 @@
 	if (icu->flag & IPO_ACTIVE) fcu->flag |= FCURVE_ACTIVE;
 	if (icu->flag & IPO_MUTE) fcu->flag |= FCURVE_MUTED;
 	if (icu->flag & IPO_PROTECT) fcu->flag |= FCURVE_PROTECTED;
-	if (icu->flag & IPO_AUTO_HORIZ) fcu->flag |= FCURVE_AUTO_HANDLES;
 	
 	/* set extrapolation */
 	switch (icu->extrap) {
@@ -1242,6 +1241,12 @@
 					/* 'hide' flag is now used for keytype - only 'keyframes' existed before */
 					dst->hide= BEZT_KEYTYPE_KEYFRAME;
 					
+					/* auto-handles - per curve to per handle */
+					if (icu->flag & IPO_AUTO_HORIZ) {
+						if (dst->h1 == HD_AUTO) dst->h1 = HD_AUTO_ANIM;
+						if (dst->h2 == HD_AUTO) dst->h2 = HD_AUTO_ANIM;
+					}
+					
 					/* correct values, by checking if the flag of interest is set */
 					if ( ((int)(dst->vec[1][1])) & (abp->bit) )
 						dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 1.0f;
@@ -1292,6 +1297,12 @@
 					
 				/* 'hide' flag is now used for keytype - only 'keyframes' existed before */
 				dst->hide= BEZT_KEYTYPE_KEYFRAME;
+				
+				/* auto-handles - per curve to per handle */
+				if (icu->flag & IPO_AUTO_HORIZ) {
+					if (dst->h1 == HD_AUTO) dst->h1 = HD_AUTO_ANIM;
+					if (dst->h2 == HD_AUTO) dst->h2 = HD_AUTO_ANIM;
+				}
 					
 				/* correct values for euler rotation curves 
 				 *	- they were degrees/10 

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/nla.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/nla.c	2011-08-04 14:06:30 UTC (rev 39021)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/nla.c	2011-08-04 14:13:05 UTC (rev 39022)
@@ -1185,7 +1185,7 @@
 			BLI_addtail(&strip->fcurves, fcu);
 			
 			/* set default flags */
-			fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
+			fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED);
 			
 			/* store path - make copy, and store that */
 			fcu->rna_path= BLI_strdupn("influence", 9);
@@ -1206,7 +1206,7 @@
 			BLI_addtail(&strip->fcurves, fcu);
 			
 			/* set default flags */
-			fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
+			fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED);
 			
 			/* store path - make copy, and store that */
 			fcu->rna_path= BLI_strdupn("strip_time", 10);

Modified: branches/soc-2011-pepper/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenloader/intern/readfile.c	2011-08-04 14:06:30 UTC (rev 39021)
+++ branches/soc-2011-pepper/source/blender/blenloader/intern/readfile.c	2011-08-04 14:13:05 UTC (rev 39022)
@@ -11799,6 +11799,38 @@
 				SEQ_END
 			}
 		}
+		{
+			/* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve 
+			 *
+			 * We're only patching F-Curves in Actions here, since it is assumed that most
+			 * drivers out there won't be using this (and if they are, they're in the minority).
+			 * While we should aim to fix everything ideally, in practice it's far too hard
+			 * to get to every animdata block, not to mention the performance hit that'd have
+			 */
+			bAction *act;
+			FCurve *fcu;
+			
+			for (act = main->action.first; act; act = act->id.next) {
+				for (fcu = act->curves.first; fcu; fcu = fcu->next) {
+					BezTriple *bezt;
+					unsigned int i = 0;
+					
+					/* only need to touch curves that had this flag set */
+					if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0)
+						continue;
+					if ((fcu->totvert == 0) || (fcu->bezt == NULL))
+						continue;
+						
+					/* only change auto-handles to auto-clamped */
+					for (bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+						if (bezt->h1 == HD_AUTO) bezt->h1 = HD_AUTO_ANIM;
+						if (bezt->h2 == HD_AUTO) bezt->h2 = HD_AUTO_ANIM;
+					}
+					
+					fcu->flag &= ~FCURVE_AUTO_HANDLES;
+				}
+			}
+		}
 	}
 	
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */

Modified: branches/soc-2011-pepper/source/blender/editors/animation/drivers.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/drivers.c	2011-08-04 14:06:30 UTC (rev 39021)
+++ branches/soc-2011-pepper/source/blender/editors/animation/drivers.c	2011-08-04 14:13:05 UTC (rev 39022)
@@ -108,7 +108,7 @@
 		/* use default settings to make a F-Curve */
 		fcu= MEM_callocN(sizeof(FCurve), "FCurve");
 		
-		fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
+		fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED);
 		
 		/* store path - make copy, and store that */
 		fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
@@ -386,10 +386,6 @@
 		copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers);
 		
 			/* flags - on a per-relevant-flag basis */
-		if (channeldriver_copypaste_buf->flag & FCURVE_AUTO_HANDLES)
-			fcu->flag |= FCURVE_AUTO_HANDLES;
-		else
-			fcu->flag &= ~FCURVE_AUTO_HANDLES;
 			/* extrapolation mode */
 		fcu->extend= channeldriver_copypaste_buf->extend;
 			

Modified: branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c	2011-08-04 14:06:30 UTC (rev 39021)
+++ branches/soc-2011-pepper/source/blender/editors/animation/keyframes_edit.c	2011-08-04 14:13:05 UTC (rev 39022)
@@ -756,24 +756,41 @@
 /* ******************************************* */
 /* Settings */
 
+/* standard validation step for a few of these (implemented as macro for inlining without fn-call overhead):
+ *	"if the handles are not of the same type, set them to type free"
+ */
+#define ENSURE_HANDLES_MATCH(bezt) \
+		if (bezt->h1 != bezt->h2) { \
+			if ELEM3(bezt->h1, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM) bezt->h1= HD_FREE; \
+			if ELEM3(bezt->h2, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM) bezt->h2= HD_FREE; \
+		}
+
 /* Sets the selected bezier handles to type 'auto' */
 static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) 
 {
-	if((bezt->f1  & SELECT) || (bezt->f3 & SELECT)) {
-		if (bezt->f1 & SELECT) bezt->h1= HD_AUTO; /* the secret code for auto */
+	if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
+		if (bezt->f1 & SELECT) bezt->h1= HD_AUTO;
 		if (bezt->f3 & SELECT) bezt->h2= HD_AUTO;
 		
-		/* if the handles are not of the same type, set them
-		 * to type free
-		 */
-		if (bezt->h1 != bezt->h2) {
-			if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE;
-			if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE;
-		}
+		ENSURE_HANDLES_MATCH(bezt);
 	}
 	return 0;
 }
 
+/* Sets the selected bezier handles to type 'auto-clamped'

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list