[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21541] branches/blender2.5/blender/source /blender/editors: 2.5 - Editing Animation data (keyframes/nla-strips) using transform tools now refreshes the 3d-view in realtime.

Joshua Leung aligorith at gmail.com
Sun Jul 12 05:42:40 CEST 2009


Revision: 21541
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21541
Author:   aligorith
Date:     2009-07-12 05:42:39 +0200 (Sun, 12 Jul 2009)

Log Message:
-----------
2.5 - Editing Animation data (keyframes/nla-strips) using transform tools now refreshes the 3d-view in realtime. 

For now, this directly sets the update flags, though this really should be calling the Depsgraph API instead.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c
    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

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c	2009-07-12 02:06:15 UTC (rev 21540)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c	2009-07-12 03:42:39 UTC (rev 21541)
@@ -413,11 +413,13 @@
 			switch(wmn->data) {
 				case ND_KEYFRAME_EDIT:
 				case ND_KEYFRAME_PROP:
+				case ND_NLA_EDIT:
 				case ND_NLA_ACTCHANGE:
 				case ND_ANIMCHAN_SELECT:
 					ED_region_tag_redraw(ar);
 					break;
 			}
+			break;
 		case NC_SCENE:
 			switch(wmn->data) {
 				case ND_TRANSFORM:
@@ -536,6 +538,16 @@
 {
 	/* context changes */
 	switch(wmn->category) {
+		case NC_ANIMATION:
+			switch(wmn->data) {
+				case ND_KEYFRAME_EDIT:
+				case ND_KEYFRAME_PROP:
+				case ND_NLA_EDIT:
+				case ND_NLA_ACTCHANGE:
+					ED_region_tag_redraw(ar);
+					break;
+			}
+			break;
 		case NC_SCENE:
 			switch(wmn->data) {
 				case ND_FRAME:

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.c	2009-07-12 02:06:15 UTC (rev 21540)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.c	2009-07-12 03:42:39 UTC (rev 21541)
@@ -308,7 +308,7 @@
 		WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
 	}
 	else if (t->spacetype == SPACE_NLA) {
-		WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+		WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
 	}
 	else if(t->spacetype == SPACE_NODE)
 	{

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.h	2009-07-12 02:06:15 UTC (rev 21540)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.h	2009-07-12 03:42:39 UTC (rev 21541)
@@ -163,6 +163,8 @@
 
 /* for NLA transform (stored in td->extra pointer) */
 typedef struct TransDataNla {
+	ID *id;						/* ID-block NLA-data is attached to */
+	
 	struct NlaTrack *oldTrack;	/* Original NLA-Track that the strip belongs to */
 	struct NlaTrack *nlt;		/* Current NLA-Track that the strip belongs to */
 	

Modified: branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c	2009-07-12 02:06:15 UTC (rev 21540)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c	2009-07-12 03:42:39 UTC (rev 21541)
@@ -2578,28 +2578,28 @@
 	Scene *scene= CTX_data_scene(C);
 	TransData *td = NULL;
 	TransDataNla *tdn = NULL;
-
+	
 	bAnimContext ac;
 	ListBase anim_data = {NULL, NULL};
 	bAnimListElem *ale;
 	int filter;
-
+	
 	int count=0;
 	char side;
-
+	
 	/* determine what type of data we are operating on */
 	if (ANIM_animdata_get_context(C, &ac) == 0)
 		return;
-
+	
 	/* filter data */
 	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
 	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+	
 	/* which side of the current frame should be allowed */
 	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
 	}
@@ -2607,15 +2607,15 @@
 		/* normal transform - both sides of current frame are considered */
 		side = 'B';
 	}
-
+	
 	/* loop 1: count how many strips are selected (consider each strip as 2 points) */
 	for (ale= anim_data.first; ale; ale= ale->next) {
 		NlaTrack *nlt= (NlaTrack *)ale->data;
 		NlaStrip *strip;
-
+		
 		/* make some meta-strips for chains of selected strips */
 		BKE_nlastrips_make_metas(&nlt->strips, 1);
-
+		
 		/* only consider selected strips */
 		for (strip= nlt->strips.first; strip; strip= strip->next) {
 			// TODO: we can make strips have handles later on...
@@ -2628,29 +2628,29 @@
 			}
 		}
 	}
-
+	
 	/* stop if trying to build list if nothing selected */
 	if (count == 0) {
 		/* cleanup temp list */
 		BLI_freelistN(&anim_data);
 		return;
 	}
-
+	
 	/* allocate memory for data */
 	t->total= count;
-
+	
 	t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(NLA Editor)");
 	td= t->data;
 	t->customData= MEM_callocN(t->total*sizeof(TransDataNla), "TransDataNla (NLA Editor)");
 	tdn= t->customData;
-
+	
 	/* loop 2: build transdata array */
 	for (ale= anim_data.first; ale; ale= ale->next) {
 		/* only if a real NLA-track */
 		if (ale->type == ANIMTYPE_NLATRACK) {
 			NlaTrack *nlt= (NlaTrack *)ale->data;
 			NlaStrip *strip;
-
+			
 			/* only consider selected strips */
 			for (strip= nlt->strips.first; strip; strip= strip->next) {
 				// TODO: we can make strips have handles later on...
@@ -2667,44 +2667,45 @@
 						 *	  cases, there will need to be 1 of these tdn elements in the array skipped...
 						 */
 						float center[3], yval;
-
+						
 						/* firstly, init tdn settings */
+						tdn->id= ale->id;
 						tdn->oldTrack= tdn->nlt= nlt;
 						tdn->strip= strip;
 						tdn->trackIndex= BLI_findindex(&nlt->strips, strip);
-
+						
 						yval= (float)(tdn->trackIndex * NLACHANNEL_STEP);
-
+						
 						tdn->h1[0]= strip->start;
 						tdn->h1[1]= yval;
 						tdn->h2[0]= strip->end;
 						tdn->h2[1]= yval;
-
+						
 						center[0]= (float)CFRA;
 						center[1]= yval;
 						center[2]= 0.0f;
-
+						
 						/* set td's based on which handles are applicable */
 						if (FrameOnMouseSide(side, strip->start, (float)CFRA))
 						{
 							/* just set tdn to assume that it only has one handle for now */
 							tdn->handle= -1;
-
+							
 							/* now, link the transform data up to this data */
 							if (t->mode == TFM_TRANSLATION) {
 								td->loc= tdn->h1;
 								VECCOPY(td->iloc, tdn->h1);
-
+								
 								/* store all the other gunk that is required by transform */
 								VECCOPY(td->center, center);
 								memset(td->axismtx, 0, sizeof(td->axismtx));
 								td->axismtx[2][2] = 1.0f;
-
+								
 								td->ext= NULL; td->tdi= NULL; td->val= NULL;
-
+								
 								td->flag |= TD_SELECTED;
 								td->dist= 0.0f;
-
+								
 								Mat3One(td->mtx);
 								Mat3One(td->smtx);
 							}
@@ -2712,7 +2713,7 @@
 								td->val= &tdn->h1[0];
 								td->ival= tdn->h1[0];
 							}
-
+							
 							td->extra= tdn;
 							td++;
 						}
@@ -2720,22 +2721,22 @@
 						{
 							/* if tdn is already holding the start handle, then we're doing both, otherwise, only end */
 							tdn->handle= (tdn->handle) ? 2 : 1;
-
+							
 							/* now, link the transform data up to this data */
 							if (t->mode == TFM_TRANSLATION) {
 								td->loc= tdn->h2;
 								VECCOPY(td->iloc, tdn->h2);
-
+								
 								/* store all the other gunk that is required by transform */
 								VECCOPY(td->center, center);
 								memset(td->axismtx, 0, sizeof(td->axismtx));
 								td->axismtx[2][2] = 1.0f;
-
+								
 								td->ext= NULL; td->tdi= NULL; td->val= NULL;
-
+								
 								td->flag |= TD_SELECTED;
 								td->dist= 0.0f;
-
+								
 								Mat3One(td->mtx);
 								Mat3One(td->smtx);
 							}
@@ -2743,11 +2744,11 @@
 								td->val= &tdn->h2[0];
 								td->ival= tdn->h2[0];
 							}
-
+							
 							td->extra= tdn;
 							td++;
 						}
-
+						
 						/* if both handles were used, skip the next tdn (i.e. leave it blank) since the counting code is dumb...
 						 * otherwise, just advance to the next one...
 						 */
@@ -3114,32 +3115,32 @@
 	Scene *scene= CTX_data_scene(C);
 	TransData *td = NULL;
 	tGPFtransdata *tfd = NULL;
-
+	
 	bAnimContext ac;
 	ListBase anim_data = {NULL, NULL};
 	bAnimListElem *ale;
 	int filter;
-
+	
 	int count=0;
 	float cfra;
 	char side;
-
+	
 	/* determine what type of data we are operating on */
 	if (ANIM_animdata_get_context(C, &ac) == 0)
 		return;
-
+	
 	/* filter data */
 	if (ac.datatype == ANIMCONT_GPENCIL)
 		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
 	else
 		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
 	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+	
 	/* which side of the current frame should be allowed */
 	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
 	}
@@ -3147,11 +3148,11 @@
 		/* normal transform - both sides of current frame are considered */
 		side = 'B';
 	}
-
+	
 	/* loop 1: fully select ipo-keys and count how many BezTriples are selected */
 	for (ale= anim_data.first; ale; ale= ale->next) {
 		AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
-
+		
 		/* convert current-frame to action-time (slightly less accurate, espcially under
 		 * higher scaling ratios, but is faster than converting all points)
 		 */
@@ -3159,26 +3160,26 @@
 			cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
 		else
 			cfra = (float)CFRA;
-
+		
 		//if (ale->type == ANIMTYPE_GPLAYER)
 		//	count += count_gplayer_frames(ale->data, side, cfra);
 		//else
 			count += count_fcurve_keys(ale->key_data, side, cfra);
 	}
-
+	
 	/* stop if trying to build list if nothing selected */
 	if (count == 0) {
 		/* cleanup temp list */
 		BLI_freelistN(&anim_data);
 		return;
 	}
-
+	
 	/* allocate memory for data */
 	t->total= count;
-
+	
 	t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(Action Editor)");
 	td= t->data;
-
+	
 	if (ac.datatype == ANIMCONT_GPENCIL) {
 		if (t->mode == TFM_TIME_SLIDE) {
 			t->customData= MEM_callocN((sizeof(float)*2)+(sizeof(tGPFtransdata)*count), "TimeSlide + tGPFtransdata");
@@ -3191,7 +3192,7 @@
 	}
 	else if (t->mode == TFM_TIME_SLIDE)
 		t->customData= MEM_callocN(sizeof(float)*2, "TimeSlide Min/Max");
-
+	
 	/* loop 2: build transdata array */
 	for (ale= anim_data.first; ale; ale= ale->next) {
 		//if (ale->type == ANIMTYPE_GPLAYER) {
@@ -3205,7 +3206,7 @@
 		//else {
 			AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
 			FCurve *fcu= (FCurve *)ale->key_data;
-
+			

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list