[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18708] branches/blender2.5/blender/source /blender/editors/transform: Graph Editor - Restored all Transform tools

Joshua Leung aligorith at gmail.com
Wed Jan 28 03:57:16 CET 2009


Revision: 18708
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18708
Author:   aligorith
Date:     2009-01-28 03:56:58 +0100 (Wed, 28 Jan 2009)

Log Message:
-----------
Graph Editor - Restored all Transform tools 

I've ported the transform tools for this editor as they existed in the AnimSys2 branch (minus some of the experimental pivot options which were not useful enough yet).

Hotkeys are:
* GKEY - transforms points as always
* RKEY - rotates points (only useful for a single 'knot') 
* SKEY - scales points
* EKEY - like in the DopeSheet, the 'extend' translation tool only moves all the keyframes on the same side of the current frame indicator as the mouse

Useful tweaks ported from AnimSys2 include:
* Auto-snapping is on by default for time-values on the keyframes only. Handles are not snapped (or shouldn't be).
* Rotating/Scaling new keyframes using default handles (i.e. Auto-Handles) now works, as the handle is now converted to aligned so that changes can be seen.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/transform/transform.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.h
    branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_generics.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_ops.c

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.c	2009-01-28 00:50:56 UTC (rev 18707)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.c	2009-01-28 02:56:58 UTC (rev 18708)
@@ -376,52 +376,6 @@
 		if (G.sima->lock) force_draw_plus(SPACE_VIEW3D, 0);
 		else force_draw(0);
 	}
-	else if (t->spacetype == SPACE_ACTION) {
-		if (G.saction->lock) {
-			short context;
-			
-			/* we ignore the pointer this function returns (not needed) */
-			get_action_context(&context);
-			
-			if (context == ACTCONT_ACTION)
-				force_draw_plus(SPACE_VIEW3D, 0);
-			else if (context == ACTCONT_SHAPEKEY) 
-				force_draw_all(0);
-			else
-				force_draw(0);
-		}
-		else {
-			force_draw(0);
-		}
-	}
-	else if (t->spacetype == SPACE_NLA) {
-		if (G.snla->lock)
-			force_draw_all(0);
-		else
-			force_draw(0);
-	}
-	else if (t->spacetype == SPACE_IPO) {
-		/* update realtime */
-		if (G.sipo->lock) {
-			if (G.sipo->blocktype==ID_MA || G.sipo->blocktype==ID_TE)
-				force_draw_plus(SPACE_BUTS, 0);
-			else if (G.sipo->blocktype==ID_CA)
-				force_draw_plus(SPACE_VIEW3D, 0);
-			else if (G.sipo->blocktype==ID_KE)
-				force_draw_plus(SPACE_VIEW3D, 0);
-			else if (G.sipo->blocktype==ID_PO)
-				force_draw_plus(SPACE_VIEW3D, 0);
-			else if (G.sipo->blocktype==ID_OB) 
-				force_draw_plus(SPACE_VIEW3D, 0);
-			else if (G.sipo->blocktype==ID_SEQ) 
-				force_draw_plus(SPACE_SEQ, 0);
-			else 
-				force_draw(0);
-		}
-		else {
-			force_draw(0);
-		}
-	}
 #endif	
 }
 
@@ -1111,8 +1065,15 @@
 		initTimeScale(t);
 		break;
 	case TFM_TIME_EXTEND: 
-		/* now that transdata has been made, do like for TFM_TIME_TRANSLATE */
-		initTimeTranslate(t);
+		/* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
+		 * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
+		 * (for Graph Editor only since it uses 'standard' transforms to get 2D movement)
+		 * depending on which editor this was called from 
+		 */
+		if (t->spacetype == SPACE_IPO)
+			initTranslation(t);
+		else
+			initTimeTranslate(t);
 		break;
 	case TFM_BAKE_TIME:
 		initBakeTime(t);

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.h	2009-01-28 00:50:56 UTC (rev 18707)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.h	2009-01-28 02:56:58 UTC (rev 18708)
@@ -331,6 +331,7 @@
 #define TD_SKIP				(1 << 11)	/* don't transform this data */
 #define TD_BEZTRIPLE		(1 << 12)	/* if this is a bez triple, we need to restore the handles, if this is set transdata->misc.hdata needs freeing */
 #define TD_NO_LOC			(1 << 13)	/* when this is set, don't apply translation changes to this element */
+#define TD_NOTIMESNAP		(1 << 14)	/* for Graph Editor autosnap, indicates that point should not undergo autosnapping */
 
 /* transsnap->status */
 #define SNAP_ON			1
@@ -441,8 +442,10 @@
 
 /*********************** transform_conversions.c ********** */
 struct ListBase;
+
 void flushTransGPactionData(TransInfo *t);
-void flushTransIpoData(TransInfo *t);
+void flushTransGraphData(TransInfo *t);
+void remake_graph_transdata(TransInfo *t, struct ListBase *anim_data);
 void flushTransUVs(TransInfo *t);
 void flushTransParticles(TransInfo *t);
 int clipUVTransform(TransInfo *t, float *vec, int resize);

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c	2009-01-28 00:50:56 UTC (rev 18707)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c	2009-01-28 02:56:58 UTC (rev 18708)
@@ -3125,12 +3125,12 @@
 
 /* ********************* GRAPH EDITOR ************************* */
 
-#if 0 // GRAPH EDIT TO PORT
 
+
 /* Helper function for make_ipo_transdata, which is reponsible for associating
  * source data with transform data
  */
-static void bezt_to_transdata (TransData *td, TransData2D *td2d, float *loc, float *cent, short selected, short ishandle, short onlytime)
+static void bezt_to_transdata (TransData *td, TransData2D *td2d, Object *nob, float *loc, float *cent, short selected, short ishandle)
 {
 	/* New location from td gets dumped onto the old-location of td2d, which then
 	 * gets copied to the actual data at td2d->loc2d (bezt->vec[n])
@@ -3139,15 +3139,15 @@
 	 * and then that scaling will be undone after transform is done.
 	 */
 	
-	if (NLA_IPO_SCALED) {
-		td2d->loc[0] = get_action_frame_inv(OBACT, loc[0]);
+	if (nob) {
+		td2d->loc[0] = get_action_frame_inv(nob, loc[0]);
 		td2d->loc[1] = loc[1];
 		td2d->loc[2] = 0.0f;
 		td2d->loc2d = loc;
 		
 		/*td->flag = 0;*/ /* can be set beforehand, else make sure its set to 0 */
 		td->loc = td2d->loc;
-		td->center[0] = get_action_frame_inv(OBACT, cent[0]);
+		td->center[0] = get_action_frame_inv(nob, cent[0]);
 		td->center[1] = cent[1];
 		td->center[2] = 0.0f;
 		
@@ -3177,207 +3177,185 @@
 	else
 		td->dist= MAXFLOAT;
 	
-	if (onlytime)
-		td->flag |= TD_TIMEONLY;
-		
 	if (ishandle)	
 		td->flag |= TD_NOTIMESNAP;
 	
 	Mat3One(td->mtx);
 	Mat3One(td->smtx);
 }	
- 
-/* This function is called by createTransIpoData and remake_ipo_transdata to
- * create the TransData and TransData2D arrays for transform. The costly counting
- * stage is only performed for createTransIpoData case, and is indicated by t->total==-1;
- */
-void make_ipo_transdata (TransInfo *t)
+
+static void createTransGraphEditData(bContext *C, TransInfo *t)
 {
+	Scene *scene= CTX_data_scene(C);
+	ARegion *ar= CTX_wm_region(C);
+	View2D *v2d= &ar->v2d;
+	
 	TransData *td = NULL;
 	TransData2D *td2d = NULL;
 	
-	EditIpo *ei;
+	bAnimContext ac;
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
 	BezTriple *bezt, *prevbezt;
-	int a, b;
+	int count=0, i;
+	float cfra;
+	char side;
 	
-	/* countsel and propmode are used for proportional edit, which is not yet available */
-	int count=0/*, countsel=0*/;
-	/*int propmode = t->flag & T_PROP_EDIT;*/
+	/* determine what type of data we are operating on */
+	if (ANIM_animdata_get_context(C, &ac) == 0)
+		return;
 	
-	/* count data and allocate memory (if needed) */
-	if (t->total == 0) {
-		/* count data first */
-		if (totipo_vertsel) {
-			/* we're probably in editmode, so only selected verts */
-			if (G.v2d->around == V3D_LOCAL) {
-				/* we're in editmode, but we need to count the number of selected handles only */
-				ei= G.sipo->editipo;
-				for (a=0; a<G.sipo->totipo; a++, ei++) {
-					if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu)) {
-						IpoCurve *icu= ei->icu;
-						
-						if (icu->bezt) { 
-							bezt= icu->bezt;
-							for (b=0; b < icu->totvert; b++, bezt++) {
-								if (bezt->ipo == IPO_BEZ) {
-									if (bezt->f1 & SELECT) count++;
-									if (bezt->f2 & SELECT) count++;
-								}
-								else if (bezt->f2 & SELECT) count++;
-							}
+	/* filter data */
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
+	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+		
+	/* which side of the current frame should be allowed */
+		// XXX we still want this mode, but how to get this using standard transform too?
+	if (t->mode == TFM_TIME_EXTEND) {
+		/* only side on which mouse is gets transformed */
+		float xmouse, ymouse;
+		
+		UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
+		side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
+	}
+	else {
+		/* normal transform - both sides of current frame are considered */
+		side = 'B';
+	}
+	
+	/* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */
+	for (ale= anim_data.first; ale; ale= ale->next) {
+		Object *nob= NULL; //ANIM_nla_mapping_get(&ac, ale); // XXX we don't handle NLA mapping for now here...
+		FCurve *fcu= (FCurve *)ale->key_data;
+		
+		/* convert current-frame to action-time (slightly less accurate, espcially under
+		 * higher scaling ratios, but is faster than converting all points) 
+		 */
+		if (nob) 
+			cfra = get_action_frame(nob, (float)CFRA);
+		else
+			cfra = (float)CFRA;
+		
+		/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
+		if (fcu->bezt) {
+			for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
+				if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
+					if (v2d->around == V3D_LOCAL) {
+						/* for local-pivot we only need to count the number of selected handles only, so that centerpoitns don't
+						 * don't get moved wrong
+						 */
+						if (bezt->ipo == BEZT_IPO_BEZ) {
+							if (bezt->f1 & SELECT) count++;
+							if (bezt->f3 & SELECT) count++;
 						}
+						else if (bezt->f2 & SELECT) count++;
 					}
-				}
-				if (count==0) return;
-			}
-			else
-				count= totipo_vertsel; 
-		}
-		else if (totipo_edit==0 && totipo_sel!=0) {
-			/* we're not in editmode, so entire curves get moved */
-			ei= G.sipo->editipo;
-			for (a=0; a<G.sipo->totipo; a++, ei++) {
-				if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu)) {
-					IpoCurve *icu= ei->icu;
-					
-					if (icu->bezt) { 
-						if (icu->ipo == IPO_MIXED) {
-							bezt= icu->bezt;
-							for (b=0; b < icu->totvert; b++, bezt++) {
-								if (bezt->ipo == IPO_BEZ) count += 3;
-								else count++;
-							}
+					else {
+						/* for 'norma' pivots */
+						if (bezt->ipo == BEZT_IPO_BEZ) {
+							if (bezt->f1 & SELECT) count++;
+							if (bezt->f2 & SELECT) count++;
+							if (bezt->f3 & SELECT) count++;
 						}
-						else if (icu->ipo == IPO_BEZ)
-							count+= 3*icu->totvert;
-						else 
-							count+= icu->totvert;
+						else if (bezt->f2 & SELECT) count++;
 					}
-					else 
-						count+= icu->totvert;
 				}
 			}
-			if (count==0) return;
 		}
-		else {
-			/* this case should not happen */
-			return;
-		}
-		
-		/* memory allocation */
-		/*t->total= (propmode)? count: countsel;*/
-		t->total= count;
-		t->data= MEM_callocN(t->total*sizeof(TransData), "TransData (IPO Editor)");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list