[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40678] trunk/blender/source/blender: fix [#28765] keyframe handles do not move with curves in graph editor when hidden, resulting in bad curves.

Campbell Barton ideasman42 at gmail.com
Thu Sep 29 07:03:24 CEST 2011


Revision: 40678
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40678
Author:   campbellbarton
Date:     2011-09-29 05:03:21 +0000 (Thu, 29 Sep 2011)
Log Message:
-----------
fix [#28765] keyframe handles do not move with curves in graph editor when hidden, resulting in bad curves.

hide handles wasn't properly respected by transform function testhandles_fcurve().

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_fcurve.h
    trunk/blender/source/blender/blenkernel/intern/fcurve.c
    trunk/blender/source/blender/editors/animation/keyframes_edit.c
    trunk/blender/source/blender/editors/space_graph/graph_buttons.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c

Modified: trunk/blender/source/blender/blenkernel/BKE_fcurve.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_fcurve.h	2011-09-28 23:43:48 UTC (rev 40677)
+++ trunk/blender/source/blender/blenkernel/BKE_fcurve.h	2011-09-29 05:03:21 UTC (rev 40678)
@@ -231,7 +231,7 @@
 /* -------- Curve Sanity --------  */
 
 void calchandles_fcurve(struct FCurve *fcu);
-void testhandles_fcurve(struct FCurve *fcu);
+void testhandles_fcurve(struct FCurve *fcu, const short use_handle);
 void sort_time_fcurve(struct FCurve *fcu);
 short test_time_fcurve(struct FCurve *fcu);
 

Modified: trunk/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fcurve.c	2011-09-28 23:43:48 UTC (rev 40677)
+++ trunk/blender/source/blender/blenkernel/intern/fcurve.c	2011-09-29 05:03:21 UTC (rev 40678)
@@ -818,7 +818,7 @@
  * 		-> Vector handles: become 'nothing' when (one half selected AND other not)
  *  - PHASE 2: recalculate handles
 */
-void testhandles_fcurve (FCurve *fcu)
+void testhandles_fcurve (FCurve *fcu, const short use_handle)
 {
 	BezTriple *bezt;
 	unsigned int a;
@@ -834,9 +834,16 @@
 		/* flag is initialised as selection status
 		 * of beztriple control-points (labelled 0,1,2)
 		 */
-		if (bezt->f1 & SELECT) flag |= (1<<0); // == 1
 		if (bezt->f2 & SELECT) flag |= (1<<1); // == 2
-		if (bezt->f3 & SELECT) flag |= (1<<2); // == 4
+		if(use_handle == FALSE) {
+			if(flag & 2) {
+				flag |= (1<<0) | (1<<2);
+			}
+		}
+		else {
+			if (bezt->f1 & SELECT) flag |= (1<<0); // == 1
+			if (bezt->f3 & SELECT) flag |= (1<<2); // == 4
+		}
 		
 		/* one or two handles selected only */
 		if (ELEM(flag, 0, 7)==0) {

Modified: trunk/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframes_edit.c	2011-09-28 23:43:48 UTC (rev 40677)
+++ trunk/blender/source/blender/editors/animation/keyframes_edit.c	2011-09-29 05:03:21 UTC (rev 40678)
@@ -51,6 +51,7 @@
 #include "DNA_node_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_space_types.h"
 #include "DNA_world_types.h"
 
 #include "BKE_fcurve.h"
@@ -386,6 +387,9 @@
 	ListBase anim_data = {NULL, NULL};
 	bAnimListElem *ale;
 	int filter;
+	/* when not in graph view, don't use handles */
+	SpaceIpo *sipo= (ac->spacetype == SPACE_IPO) ? (SpaceIpo *)ac->sl : NULL;
+	const short use_handle = sipo ? !(sipo->flag & SIPO_NOHANDLES) : FALSE;
 	
 	/* filter animation data */
 	filter= ANIMFILTER_DATA_VISIBLE; 
@@ -397,7 +401,7 @@
 		
 		/* make sure keyframes in F-Curve are all in order, and handles are in valid positions */
 		sort_time_fcurve(fcu);
-		testhandles_fcurve(fcu);
+		testhandles_fcurve(fcu, use_handle);
 	}
 	
 	/* free temp data */

Modified: trunk/blender/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_buttons.c	2011-09-28 23:43:48 UTC (rev 40677)
+++ trunk/blender/source/blender/editors/space_graph/graph_buttons.c	2011-09-29 05:03:21 UTC (rev 40678)
@@ -245,13 +245,15 @@
 }
 
 /* update callback for active keyframe properties - base updates stuff */
-static void graphedit_activekey_update_cb(bContext *UNUSED(C), void *fcu_ptr, void *UNUSED(bezt_ptr))
+static void graphedit_activekey_update_cb(bContext *C, void *fcu_ptr, void *UNUSED(bezt_ptr))
 {
+	SpaceIpo *sipo= CTX_wm_space_graph(C);
+	const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
 	FCurve *fcu = (FCurve *)fcu_ptr;
 	
 	/* make sure F-Curve and its handles are still valid after this editing */
 	sort_time_fcurve(fcu);
-	testhandles_fcurve(fcu);
+	testhandles_fcurve(fcu, use_handle);
 }
 
 /* update callback for active keyframe properties - handle-editing wrapper */

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2011-09-28 23:43:48 UTC (rev 40677)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2011-09-29 05:03:21 UTC (rev 40678)
@@ -2785,7 +2785,7 @@
 /* Called during special_aftertrans_update to make sure selected keyframes replace
  * any other keyframes which may reside on that frame (that is not selected).
  */
-static void posttrans_fcurve_clean (FCurve *fcu)
+static void posttrans_fcurve_clean (FCurve *fcu, const short use_handle)
 {
 	float *selcache;	/* cache for frame numbers of selected frames (fcu->totvert*sizeof(float)) */
 	int len, index, i;	/* number of frames in cache, item index */
@@ -2834,7 +2834,7 @@
 			}
 		}
 		
-		testhandles_fcurve(fcu);
+		testhandles_fcurve(fcu, use_handle);
 	}
 
 	/* free cache */
@@ -2865,11 +2865,11 @@
 		
 		if (adt) {
 			ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
-			posttrans_fcurve_clean(ale->key_data);
+			posttrans_fcurve_clean(ale->key_data, FALSE); /* only use handles in graph editor */
 			ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
 		}
 		else
-			posttrans_fcurve_clean(ale->key_data);
+			posttrans_fcurve_clean(ale->key_data, FALSE); /* only use handles in graph editor */
 	}
 
 	/* free temp data */
@@ -3320,9 +3320,9 @@
 		/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
 		for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
 			if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
-				const char sel1= use_handle ? bezt->f1 & SELECT : 0;
 				const char sel2= bezt->f2 & SELECT;
-				const char sel3= use_handle ? bezt->f3 & SELECT : 0;
+				const char sel1= use_handle ? bezt->f1 & SELECT : sel2;
+				const char sel3= use_handle ? bezt->f3 & SELECT : sel2;
 
 				if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) {
 					/* for 'normal' pivots - just include anything that is selected.
@@ -3413,9 +3413,9 @@
 		/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
 		for (i=0, bezt= fcu->bezt; i < fcu->totvert; i++, bezt++) {
 			if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
-				const char sel1= use_handle ? bezt->f1 & SELECT : 0;
 				const char sel2= bezt->f2 & SELECT;
-				const char sel3= use_handle ? bezt->f3 & SELECT : 0;
+				const char sel1= use_handle ? bezt->f1 & SELECT : sel2;
+				const char sel3= use_handle ? bezt->f3 & SELECT : sel2;
 
 				TransDataCurveHandleFlags *hdata = NULL;
 				/* short h1=1, h2=1; */ /* UNUSED */
@@ -3475,7 +3475,7 @@
 		}
 		
 		/* Sets handles based on the selection */
-		testhandles_fcurve(fcu);
+		testhandles_fcurve(fcu, use_handle);
 	}
 	
 	/* cleanup temp list */
@@ -3679,7 +3679,7 @@
 			sort_time_fcurve(fcu);
 			
 			/* make sure handles are all set correctly */
-			testhandles_fcurve(fcu);
+			testhandles_fcurve(fcu, use_handle);
 		}
 	}
 }
@@ -4832,11 +4832,11 @@
 				{
 					if (adt) {
 						ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
-						posttrans_fcurve_clean(fcu);
+						posttrans_fcurve_clean(fcu, FALSE); /* only use handles in graph editor */
 						ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
 					}
 					else
-						posttrans_fcurve_clean(fcu);
+						posttrans_fcurve_clean(fcu, FALSE); /* only use handles in graph editor */
 				}
 			}
 			
@@ -4916,6 +4916,7 @@
 	else if (t->spacetype == SPACE_IPO) {
 		SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
 		bAnimContext ac;
+		const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
 		
 		/* initialise relevant anim-context 'context' data */
 		if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -4944,11 +4945,11 @@
 				{
 					if (adt) {
 						ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0);
-						posttrans_fcurve_clean(fcu);
+						posttrans_fcurve_clean(fcu, use_handle);
 						ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
 					}
 					else
-						posttrans_fcurve_clean(fcu);
+						posttrans_fcurve_clean(fcu, use_handle);
 				}
 			}
 			




More information about the Bf-blender-cvs mailing list