[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28896] branches/render25/source/blender/ editors: durian featurette: ^Cmekey in anim editors now respects scene/ preview frame range.

Joseph Eagar joeedh at gmail.com
Thu May 20 22:34:20 CEST 2010


Revision: 28896
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28896
Author:   joeedh
Date:     2010-05-20 22:34:20 +0200 (Thu, 20 May 2010)

Log Message:
-----------
durian featurette: ^Cmekey in anim editors now respects scene/preview frame range.  merge with trunk will happen if Aligorith approves this.  implemented view-all in the NLA editor btw, and fixed a bug where shift-select didn't work

Modified Paths:
--------------
    branches/render25/source/blender/editors/interface/view2d.c
    branches/render25/source/blender/editors/space_action/action_edit.c
    branches/render25/source/blender/editors/space_graph/graph_edit.c
    branches/render25/source/blender/editors/space_graph/graph_intern.h
    branches/render25/source/blender/editors/space_graph/space_graph.c
    branches/render25/source/blender/editors/space_nla/nla_edit.c
    branches/render25/source/blender/editors/space_nla/nla_intern.h
    branches/render25/source/blender/editors/space_nla/nla_ops.c
    branches/render25/source/blender/editors/space_nla/nla_select.c
    branches/render25/source/blender/editors/space_time/time_ops.c

Modified: branches/render25/source/blender/editors/interface/view2d.c
===================================================================
--- branches/render25/source/blender/editors/interface/view2d.c	2010-05-20 17:53:14 UTC (rev 28895)
+++ branches/render25/source/blender/editors/interface/view2d.c	2010-05-20 20:34:20 UTC (rev 28896)
@@ -719,7 +719,7 @@
 	ARegion *ar;
 	
 	/* don't continue if no view syncing to be done */
-	if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME|V2D_VIEWSYNC_AREA_VERTICAL)) == 0)
+	if (0==(v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME|V2D_VIEWSYNC_AREA_VERTICAL)))
 		return;
 		
 	/* check if doing within area syncing (i.e. channels/vertical) */

Modified: branches/render25/source/blender/editors/space_action/action_edit.c
===================================================================
--- branches/render25/source/blender/editors/space_action/action_edit.c	2010-05-20 17:53:14 UTC (rev 28895)
+++ branches/render25/source/blender/editors/space_action/action_edit.c	2010-05-20 20:34:20 UTC (rev 28896)
@@ -128,10 +128,14 @@
 /* Get the min/max keyframes*/
 static void get_keyframe_extents (bAnimContext *ac, float *min, float *max)
 {
+	Scene *scene = ac->scene;
 	ListBase anim_data = {NULL, NULL};
 	bAnimListElem *ale;
-	int filter;
-	
+	int filter, sfra, efra;
+
+	sfra = PSFRA;
+	efra = PEFRA;
+
 	/* get data to filter, from Action or Dopesheet */
 	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
@@ -157,8 +161,8 @@
 			}
 			
 			/* try to set cur using these values, if they're more extreme than previously set values */
-			*min= MIN2(*min, tmin);
-			*max= MAX2(*max, tmax);
+			*min= MAX2(MIN2(*min, tmin), sfra);
+			*max= MIN2(MAX2(*max, tmax), efra);
 		}
 		
 		/* free memory */

Modified: branches/render25/source/blender/editors/space_graph/graph_edit.c
===================================================================
--- branches/render25/source/blender/editors/space_graph/graph_edit.c	2010-05-20 17:53:14 UTC (rev 28895)
+++ branches/render25/source/blender/editors/space_graph/graph_edit.c	2010-05-20 20:34:20 UTC (rev 28896)
@@ -79,12 +79,16 @@
 
 /* Get the min/max keyframes*/
 /* note: it should return total boundbox, filter for selection only can be argument... */
-void get_graph_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax)
+void get_graph_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, int frame_clip)
 {
+	Scene *scene = ac->scene;
 	ListBase anim_data = {NULL, NULL};
 	bAnimListElem *ale;
-	int filter;
-	
+	int filter, efra, sfra;
+
+	sfra = PSFRA;
+	efra = PEFRA;
+
 	/* get data to filter, from Dopesheet */
 	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
@@ -113,11 +117,18 @@
 				txmax= BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP);
 			}
 			
+			if (frame_clip) {
+				if (txmin < sfra)
+					txmin = sfra;
+				if (txmax > efra)
+					txmax = efra;
+			}
+
 			/* apply unit corrections */
 			unitFac= ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
 			tymin *= unitFac;
 			tymax *= unitFac;
-			
+
 			/* try to set cur using these values, if they're more extreme than previously set values */
 			if ((xmin) && (txmin < *xmin)) 		*xmin= txmin;
 			if ((xmax) && (txmax > *xmax)) 		*xmax= txmax;
@@ -161,7 +172,7 @@
 		scene= ac.scene;
 	
 	/* set the range directly */
-	get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL);
+	get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, 0);
 	scene->r.flag |= SCER_PRV_RANGE;
 	scene->r.psfra= (int)floor(min + 0.5f);
 	scene->r.pefra= (int)floor(max + 0.5f);
@@ -201,7 +212,7 @@
 	v2d= &ac.ar->v2d;
 	
 	/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
-	get_graph_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax);
+	get_graph_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax, 1);
 	
 	extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
 	v2d->cur.xmin -= extra;

Modified: branches/render25/source/blender/editors/space_graph/graph_intern.h
===================================================================
--- branches/render25/source/blender/editors/space_graph/graph_intern.h	2010-05-20 17:53:14 UTC (rev 28895)
+++ branches/render25/source/blender/editors/space_graph/graph_intern.h	2010-05-20 20:34:20 UTC (rev 28896)
@@ -87,7 +87,8 @@
 /* ***************************************** */
 /* graph_edit.c */
 
-void get_graph_keyframe_extents (struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax);
+/*frame_clip clips the range by the scene/preview frame range*/
+void get_graph_keyframe_extents (struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, int frame_clip);
 
 void GRAPH_OT_previewrange_set(struct wmOperatorType *ot);
 void GRAPH_OT_view_all(struct wmOperatorType *ot);

Modified: branches/render25/source/blender/editors/space_graph/space_graph.c
===================================================================
--- branches/render25/source/blender/editors/space_graph/space_graph.c	2010-05-20 17:53:14 UTC (rev 28895)
+++ branches/render25/source/blender/editors/space_graph/space_graph.c	2010-05-20 20:34:20 UTC (rev 28896)
@@ -247,7 +247,7 @@
 		graph_draw_curves(&ac, sipo, ar, grid, 1);
 		
 		/* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
-		get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax);
+		get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax, 0);
 		/* extra offset so that these items are visible */
 		v2d->tot.xmin -= 10.0f;
 		v2d->tot.xmax += 10.0f;

Modified: branches/render25/source/blender/editors/space_nla/nla_edit.c
===================================================================
--- branches/render25/source/blender/editors/space_nla/nla_edit.c	2010-05-20 17:53:14 UTC (rev 28895)
+++ branches/render25/source/blender/editors/space_nla/nla_edit.c	2010-05-20 20:34:20 UTC (rev 28896)
@@ -63,6 +63,7 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "UI_view2d.h"
 #include "UI_interface.h"
 
 #include "nla_intern.h"	// own include
@@ -1777,4 +1778,160 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+/* ************************ View All Operator *******************************/
+
+
+/* Get the min/max keyframes*/
+/* note: it should return total boundbox, filter for selection only can be argument... */
+void get_nla_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, int frame_clip)
+{
+	Scene *scene = ac->scene;
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter, notfound=1, efra, sfra, items;
+	float y;
+
+	sfra = PSFRA;
+	efra = PEFRA;
+
+	/* get data to filter, from Dopesheet */
+	filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS);
+	items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+	/* set large values to try to override */
+	if (xmin) *xmin= 999999999.0f;
+	if (xmax) *xmax= -999999999.0f;
+	if (ymin) *ymin= 999999999.0f;
+	if (ymax) *ymax= -999999999.0f;
+
+	y= -NLACHANNEL_HEIGHT;
+
+	/* check if any channels to set range with */
+	if (anim_data.first) {
+		/* go through channels, finding max extents */
+		for (ale= anim_data.first; ale; ale= ale->next, y-=NLACHANNEL_STEP) {
+			AnimData *adt= ANIM_nla_mapping_get(ac, ale);
+			FCurve *fcu= (FCurve *)ale->key_data;
+			float txmin=9999999, txmax=-9999999, tymin=9999999, tymax=-9999999;
+
+			/*get range*/
+			switch (ale->type) {
+				case ANIMTYPE_NLATRACK: {
+					NlaTrack *nlt= (NlaTrack*)ale->data;
+					NlaStrip *strip;
+
+					for (strip=nlt->strips.first; strip; strip=strip->next) {
+						if (!(strip->flag & NLASTRIP_FLAG_SELECT))
+							continue;
+
+						txmin = MIN2(strip->start, txmin);
+						txmax = MAX2(strip->end, txmax);
+						notfound = 0;
+					}
+
+					break;
+				}
+
+				case ANIMTYPE_NLAACTION:
+					if (ale->data && (ale->flag & ANIMFILTER_SEL)) {
+						bAction *act= ale->data;
+						float start, end;
+
+						if (act) {
+							calc_action_range(act, &start, &end, 0);
+							txmin = MIN2(start, txmin);
+							txmax = MAX2(end, txmax);
+							notfound = 0;
+						}
+					}
+			}
+
+			if (notfound)
+				continue;
+
+			tymin= MIN2(tymin, y - NLACHANNEL_HEIGHT_HALF);
+			tymax= MAX2(tymax, y + NLACHANNEL_HEIGHT_HALF);
+
+			if (frame_clip) {
+				txmin = MAX2(txmin, sfra);
+				txmax = MIN2(txmax, efra);
+			}
+
+			/* try to set cur using these values, if they're more extreme than previously set values */
+			if ((xmin) && (txmin < *xmin)) 		*xmin= txmin;
+			if ((xmax) && (txmax > *xmax)) 		*xmax= txmax;
+			if ((ymin) && (tymin < *ymin)) 		*ymin= tymin;
+			if ((ymax) && (tymax > *ymax)) 		*ymax= tymax;
+		}
+
+		if (notfound) {
+			/* set default range */
+			if (xmin) *xmin= (float)(PSFRA-10);
+			if (ymin) *ymin= (float)(-ac->sa->winy)/3.0f;
+			if (xmax) *xmax= (float)(PEFRA+10);
+			if (ymax) *ymax= 0.0f;
+		}
+
+		/* free memory */
+		BLI_freelistN(&anim_data);
+	}
+	else {
+		/* set default range */
+		if (xmin) *xmin= (float)(PSFRA-10);
+		if (ymin) *ymin= (float)(-ac->sa->winy)/3.0f;
+		if (xmax) *xmax= (float)(PEFRA+10);
+		if (ymax) *ymax= 0.0f;
+	}
+}
+
+static int nla_view_all_exec(bContext *C, wmOperator *op)
+{
+	bAnimContext ac;
+	View2D *v2d;
+	float extra, height;
+
+	/* get editor data */
+	if (ANIM_animdata_get_context(C, &ac) == 0)
+		return OPERATOR_CANCELLED;
+
+	v2d= &ac.ar->v2d;
+
+	height = v2d->cur.ymax - v2d->cur.ymin;
+
+	/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
+	get_nla_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax, 1);
+
+	extra= 0.02f * (v2d->cur.xmax - v2d->cur.xmin);
+	v2d->cur.xmin -= extra;
+	v2d->cur.xmax += extra;
+
+	v2d->cur.ymin = v2d->cur.ymax - height;
+
+	v2d->cur.ymax += NLACHANNEL_HEIGHT;
+	v2d->cur.ymin += NLACHANNEL_HEIGHT;
+
+	/* do View2D syncing */
+	UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
+
+	/* set notifier that things have changed */
+	ED_area_tag_redraw(CTX_wm_area(C));
+
+	return OPERATOR_FINISHED;
+}
+
+void NLA_OT_view_all (wmOperatorType *ot)
+{
+	/* identifiers */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list