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

Joshua Leung aligorith at gmail.com
Tue Jan 27 12:09:33 CET 2009


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

Log Message:
-----------
Graph Editor: 

* Cleaned up code for borderselect with BKEY. There's still a bug here where y-values don't seem to be getting properly checked, so nothing seems to happen.

* Set up some code for transforming keyframes. It currently uses the wrong code though (i.e. it uses the code for Action Editor which is 1D not 2D, and doesn't have some of the special checks needed). More work on this later.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
    branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h
    branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_draw.c
    branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c
    branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_select.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2009-01-27 08:36:09 UTC (rev 18691)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_edit.c	2009-01-27 11:09:30 UTC (rev 18692)
@@ -38,7 +38,6 @@
 #include "DNA_action_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_curve_types.h"
-#include "DNA_ipo_types.h" // XXX to be phased out
 #include "DNA_key_types.h"
 #include "DNA_object_types.h"
 #include "DNA_space_types.h"
@@ -56,7 +55,7 @@
 /* This file defines an API and set of callback-operators for non-destructive editing of keyframe data.
  *
  * Two API functions are defined for actually performing the operations on the data:
- *			ipo_keys_bezier_loop() and icu_keys_bezier_loop()
+ *			ANIM_fcurve_keys_bezier_loop()
  * which take the data they operate on, a few callbacks defining what operations to perform.
  *
  * As operators which work on keyframes usually apply the same operation on all BezTriples in 
@@ -84,6 +83,10 @@
     BezTriple *bezt;
 	int b;
 	
+	/* sanity check */
+	if (fcu == NULL)
+		return 0;
+	
 	/* if function to apply to bezier curves is set, then loop through executing it on beztriples */
     if (bezt_cb) {
 		/* if there's a validation func, include that check in the loop 
@@ -233,7 +236,22 @@
 	return IS_EQ(bezt->vec[1][1], bed->f1);
 }
 
+static short ok_bezier_valuerange(BeztEditData *bed, BezTriple *bezt)
+{
+	/* value range is stored in float properties */
+	return ((bezt->vec[1][1] > bed->f1) && (bezt->vec[1][1] < bed->f2));
+}
 
+static short ok_bezier_region(BeztEditData *bed, BezTriple *bezt)
+{
+	/* rect is stored in data property (it's of type rectf, but may not be set) */
+	if (bed->data)
+		return BLI_in_rctf(bed->data, bezt->vec[1][0], bezt->vec[1][1]);
+	else 
+		return 0;
+}
+
+
 BeztEditFunc ANIM_editkeyframes_ok(short mode)
 {
 	/* eEditKeyframes_Validate */
@@ -242,10 +260,14 @@
 			return ok_bezier_frame;
 		case BEZT_OK_FRAMERANGE: /* only if bezt falls within the specified frame range (floats) */
 			return ok_bezier_framerange;
-		case BEZT_OK_SELECTED:	/* only if bezt is selected */
+		case BEZT_OK_SELECTED:	/* only if bezt is selected (self) */
 			return ok_bezier_selected;
 		case BEZT_OK_VALUE: /* only if bezt value matches (float) */
 			return ok_bezier_value;
+		case BEZT_OK_VALUERANGE: /* only if bezier falls within the specified value range (floats) */
+			return ok_bezier_valuerange;
+		case BEZT_OK_REGION: /* only if bezier falls within the specified rect (data -> rectf) */
+			return ok_bezier_region;
 		default: /* nothing was ok */
 			return NULL;
 	}
@@ -355,7 +377,7 @@
 }
 
 /* Note: for markers case, need to set global vars (eww...) */
-// calchandles_ipocurve
+// calchandles_fcurve
 BeztEditFunc ANIM_editkeyframes_mirror(short type)
 {
 	switch (type) {
@@ -437,7 +459,7 @@
 }
 
 /* Set all Bezier Handles to a single type */
-// calchandles_ipocurve
+// calchandles_fcurve
 BeztEditFunc ANIM_editkeyframes_handles(short code)
 {
 	switch (code) {
@@ -460,21 +482,21 @@
 static short set_bezt_constant(BeztEditData *bed, BezTriple *bezt) 
 {
 	if (bezt->f2 & SELECT) 
-		bezt->ipo= IPO_CONST;
+		bezt->ipo= BEZT_IPO_CONST;
 	return 0;
 }
 
 static short set_bezt_linear(BeztEditData *bed, BezTriple *bezt) 
 {
 	if (bezt->f2 & SELECT) 
-		bezt->ipo= IPO_LIN;
+		bezt->ipo= BEZT_IPO_LIN;
 	return 0;
 }
 
 static short set_bezt_bezier(BeztEditData *bed, BezTriple *bezt) 
 {
 	if (bezt->f2 & SELECT) 
-		bezt->ipo= IPO_BEZ;
+		bezt->ipo= BEZT_IPO_BEZ;
 	return 0;
 }
 
@@ -483,9 +505,9 @@
 BeztEditFunc ANIM_editkeyframes_ipo(short code)
 {
 	switch (code) {
-		case IPO_CONST: /* constant */
+		case BEZT_IPO_CONST: /* constant */
 			return set_bezt_constant;
-		case IPO_LIN: /* linear */	
+		case BEZT_IPO_LIN: /* linear */	
 			return set_bezt_linear;
 		default: /* bezier */
 			return set_bezt_bezier;

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-27 08:36:09 UTC (rev 18691)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_edit.h	2009-01-27 11:09:30 UTC (rev 18692)
@@ -53,6 +53,8 @@
 	BEZT_OK_FRAMERANGE,
 	BEZT_OK_SELECTED,
 	BEZT_OK_VALUE,
+	BEZT_OK_VALUERANGE,
+	BEZT_OK_REGION,
 } eEditKeyframes_Validate;
 
 /* ------------ */
@@ -89,7 +91,7 @@
 typedef struct BeztEditData {
 	ListBase list;				/* temp list for storing custom list of data to check */
 	struct Scene *scene;		/* pointer to current scene - many tools need access to cfra/etc.  */
-	void *data;					/* pointer to custom data - usually 'Object', but could be other types too */
+	void *data;					/* pointer to custom data - usually 'Object' but also 'rectf', but could be other types too */
 	float f1, f2;				/* storage of times/values as 'decimals' */
 	int i1, i2;					/* storage of times/values/flags as 'whole' numbers */
 } BeztEditData;
@@ -126,7 +128,7 @@
 
 void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc);
 void delete_fcurve_keys(struct FCurve *fcu);
-void duplicate_fcurve_keys(struct FCurve *fcu); // XXX fixme...
+void duplicate_fcurve_keys(struct FCurve *fcu);
 
 void clean_fcurve(struct FCurve *fcu, float thresh);
 void smooth_fcurve(struct FCurve *fcu, short mode);

Modified: branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_draw.c	2009-01-27 08:36:09 UTC (rev 18691)
+++ branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_draw.c	2009-01-27 11:09:30 UTC (rev 18692)
@@ -617,7 +617,7 @@
 		
 		/* map ipo-points for drawing if scaled F-Curve */
 		if (nob)
-			ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1); 
+			ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 0); 
 		
 		/* draw curve - we currently calculate colour on the fly, but that should probably be done in advance instead */
 		col= ipo_rainbow(i, items);
@@ -631,7 +631,7 @@
 		
 		/* undo mapping of keyframes for drawing if scaled F-Curve */
 		if (nob)
-			ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1); 
+			ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 0); 
 	}
 	
 	/* free list of curves */

Modified: branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c	2009-01-27 08:36:09 UTC (rev 18691)
+++ branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_ops.c	2009-01-27 11:09:30 UTC (rev 18692)
@@ -144,7 +144,7 @@
 #endif // XXX code to be sanitied for new system	
 		
 	/* transform system */
-	transform_keymap_for_space(wm, keymap, SPACE_IPO);
+	transform_keymap_for_space(wm, keymap, /*SPACE_IPO*/SPACE_ACTION); // xxx
 }
 
 /* --------------- */

Modified: branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_select.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_select.c	2009-01-27 08:36:09 UTC (rev 18691)
+++ branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_select.c	2009-01-27 11:09:30 UTC (rev 18692)
@@ -184,21 +184,17 @@
 
 /* ******************** Border Select Operator **************************** */
 /* This operator currently works in one of three ways:
- *	-> BKEY 	- 1) all keyframes within region are selected (GRAPHKEYS_BORDERSEL_ALLKEYS)
+ *	-> BKEY 	- 1) all keyframes within region are selected (validation with BEZT_OK_REGION)
  *	-> ALT-BKEY - depending on which axis of the region was larger...
- *		-> 2) x-axis, so select all frames within frame range (GRAPHKEYS_BORDERSEL_FRAMERANGE)
- *		-> 3) y-axis, so select all frames within channels that region included (GRAPHKEYS_BORDERSEL_CHANNELS)
+ *		-> 2) x-axis, so select all frames within frame range (validation with BEZT_OK_FRAMERANGE)
+ *		-> 3) y-axis, so select all frames within channels that region included (validation with BEZT_OK_VALUERANGE)
  */
 
-/* defines for borderselect mode */
-enum {
-	GRAPHKEYS_BORDERSEL_ALLKEYS	= 0,
-	GRAPHKEYS_BORDERSEL_FRAMERANGE,
-	GRAPHKEYS_BORDERSEL_CHANNELS,
-} egraphkeys_BorderSelect_Mode;
-
-
-static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short selectmode)
+/* Borderselect only selects keyframes now, as overshooting handles often get caught too,
+ * which means that they may be inadvertantly moved as well.
+ * Also, for convenience, handles should get same status as keyframe (if it was within bounds)
+ */
+static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, short selectmode)
 {
 	ListBase anim_data = {NULL, NULL};
 	bAnimListElem *ale;
@@ -210,30 +206,27 @@
 	rctf rectf;
 	
 	/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
-	UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin+2, &rectf.xmin, &rectf.ymin);
-	UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax-2, &rectf.xmax, &rectf.ymax);
+	UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
+	UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
 	
 	/* filter data */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 	
 	/* get beztriple editing/validation funcs  */
 	select_cb= ANIM_editkeyframes_select(selectmode);
+	ok_cb= ANIM_editkeyframes_ok(mode);
 	
-	if (ELEM(mode, GRAPHKEYS_BORDERSEL_FRAMERANGE, GRAPHKEYS_BORDERSEL_ALLKEYS))
-		ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
-	else
-		ok_cb= NULL;
-		
 	/* init editing data */
 	memset(&bed, 0, sizeof(BeztEditData));
+	bed.data= ▭
 	
 	/* loop over data, doing border select */
 	for (ale= anim_data.first; ale; ale= ale->next) {
 		Object *nob= ANIM_nla_mapping_get(ac, ale);
 		
 		/* set horizontal range (if applicable) */
-		if (ELEM(mode, GRAPHKEYS_BORDERSEL_FRAMERANGE, GRAPHKEYS_BORDERSEL_ALLKEYS)) {
+		if (mode != BEZT_OK_VALUERANGE) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list