[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21469] branches/soc-2009-aligorith/source /blender: NLA SoC: Tweaks from feedback from Broken + jez

Joshua Leung aligorith at gmail.com
Fri Jul 10 02:32:13 CEST 2009


Revision: 21469
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21469
Author:   aligorith
Date:     2009-07-10 02:32:13 +0200 (Fri, 10 Jul 2009)

Log Message:
-----------
NLA SoC: Tweaks from feedback from Broken + jez

* Renamed the 'blend' blending mode to 'replace', since that's what it usually does

* Drawing a darkened rect behind the keyframes shown in the action line

--

* Fixed typo made last night which broke compiling
* Consolidated all the keyframe-shape drawing code to use a single codebase. Even if we don't ultimately go with OpenGL keyframes, there's always a tidy option for that now.

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/ipo.c
    branches/soc-2009-aligorith/source/blender/editors/animation/keyframes_draw.c
    branches/soc-2009-aligorith/source/blender/editors/include/ED_keyframes_draw.h
    branches/soc-2009-aligorith/source/blender/editors/space_action/action_draw.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c
    branches/soc-2009-aligorith/source/blender/makesdna/DNA_anim_types.h
    branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c	2009-07-09 21:41:38 UTC (rev 21468)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c	2009-07-10 00:32:13 UTC (rev 21469)
@@ -859,7 +859,7 @@
 			nec->value *= value;
 			break;
 		
-		case NLASTRIP_MODE_BLEND:
+		case NLASTRIP_MODE_REPLACE:
 		default: // TODO: do we really want to blend by default? it seems more uses might prefer add...
 			/* do linear interpolation 
 			 *	- the influence of the accumulated data (elsewhere, that is called dstweight) 

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/ipo.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/ipo.c	2009-07-09 21:41:38 UTC (rev 21468)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/ipo.c	2009-07-10 00:32:13 UTC (rev 21469)
@@ -1518,7 +1518,7 @@
 					/* blending */
 				strip->blendin= as->blendin;
 				strip->blendout= as->blendout;
-				strip->blendmode= (as->mode==ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_BLEND;
+				strip->blendmode= (as->mode==ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_REPLACE;
 				if (as->flag & ACTSTRIP_AUTO_BLENDS)	strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS;
 					
 					/* assorted setting flags */

Modified: branches/soc-2009-aligorith/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/animation/keyframes_draw.c	2009-07-09 21:41:38 UTC (rev 21468)
+++ branches/soc-2009-aligorith/source/blender/editors/animation/keyframes_draw.c	2009-07-10 00:32:13 UTC (rev 21469)
@@ -243,7 +243,7 @@
 }; 
 
 /* draw a simple diamond shape with OpenGL */
-static void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel)
+void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short mode)
 {
 	static GLuint displist1=0;
 	static GLuint displist2=0;
@@ -281,17 +281,22 @@
 	/* anti-aliased lines for more consistent appearance */
 	glEnable(GL_LINE_SMOOTH);
 	
-	/* draw! ---------------------------- */
+	/* draw! */
+	if ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH) {
+		/* interior - hardcoded colors (for selected and unselected only) */
+		if (sel) UI_ThemeColorShade(TH_STRIP_SELECT, 50);
+		else glColor3ub(0xE9, 0xE9, 0xE9);
+		
+		glCallList(displist2);
+	}
 	
-	/* interior - hardcoded colors (for selected and unselected only) */
-	if (sel) UI_ThemeColorShade(TH_STRIP_SELECT, 50);//glColor3ub(0xF1, 0xCA, 0x13);
-	else glColor3ub(0xE9, 0xE9, 0xE9);
-	glCallList(displist2);
+	if ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH) {
+		/* exterior - black frame */
+		glColor3ub(0, 0, 0);
+		
+		glCallList(displist1);
+	}
 	
-	/* exterior - black frame */
-	glColor3ub(0, 0, 0);
-	glCallList(displist1);
-	
 	glDisable(GL_LINE_SMOOTH);
 	
 	/* restore view transform */
@@ -345,7 +350,7 @@
 		for (ak= keys->first; ak; ak= ak->next) {
 			/* draw using OpenGL - uglier but faster */
 			// NOTE: a previous version of this didn't work nice for some intel cards
-			draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT));
+			draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), KEYFRAME_SHAPE_BOTH);
 			
 #if 0 // OLD CODE
 			//int sc_x, sc_y;

Modified: branches/soc-2009-aligorith/source/blender/editors/include/ED_keyframes_draw.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/include/ED_keyframes_draw.h	2009-07-09 21:41:38 UTC (rev 21468)
+++ branches/soc-2009-aligorith/source/blender/editors/include/ED_keyframes_draw.h	2009-07-10 00:32:13 UTC (rev 21469)
@@ -67,6 +67,22 @@
 	short totcurve; 
 } ActKeyBlock;
 
+
+/* *********************** Keyframe Drawing ****************************** */
+
+/* options for keyframe shape drawing */
+typedef enum eKeyframeShapeDrawOpts {
+		/* only the border */
+	KEYFRAME_SHAPE_FRAME	= 0,
+		/* only the inside filling */
+	KEYFRAME_SHAPE_INSIDE,
+		/* the whole thing */
+	KEYFRAME_SHAPE_BOTH
+} eKeyframeShapeDrawOpts;
+
+/* draw simple diamond-shape keyframe (with OpenGL) */
+void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short mode);
+
 /* ******************************* Methods ****************************** */
 
 /* Channel Drawing */

Modified: branches/soc-2009-aligorith/source/blender/editors/space_action/action_draw.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_action/action_draw.c	2009-07-09 21:41:38 UTC (rev 21468)
+++ branches/soc-2009-aligorith/source/blender/editors/space_action/action_draw.c	2009-07-10 00:32:13 UTC (rev 21469)
@@ -1194,7 +1194,7 @@
 		glColor3f(0.0f, 0.0f, 0.0f);
 		
 		glBegin(GL_LINES);
-			glVertex2f(saction->timeslide, v2d->cur.ymin-EXTRA_SCROLL_PAD)
+			glVertex2f(saction->timeslide, v2d->cur.ymin-EXTRA_SCROLL_PAD);
 			glVertex2f(saction->timeslide, v2d->cur.ymax);
 		glEnd();
 	}

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c	2009-07-09 21:41:38 UTC (rev 21468)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c	2009-07-10 00:32:13 UTC (rev 21469)
@@ -91,66 +91,78 @@
 /* *********************************************** */
 /* Strips */
 
-/* Keyframe Ghosts ---------------------- */
+/* Action-Line ---------------------- */
 
-/* helper func - draw keyframe as a frame only */
-static void draw_nla_keyframe_ghost (float x, float y, float xscale, float hsize)
+/* get colors for drawing Action-Line 
+ * NOTE: color returned includes fine-tuned alpha!
+ */
+static void nla_action_get_color (AnimData *adt, bAction *act, float color[4])
 {
-	static GLuint displist=0;
-	
-	/* initialise empty diamond shape */
-	if (displist == 0) {
-		const float dist= 1.0f;
-		
-		displist= glGenLists(1);
-		glNewList(displist, GL_COMPILE);
-		
-		glBegin(GL_LINE_LOOP);
-			glVertex2f(0.0f,  dist);
-			glVertex2f(dist,  0.0f);
-			glVertex2f(0.0f, -dist);
-			glVertex2f(-dist, 0.0f);
-		glEnd();
-		
-		glEndList();
+	// TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now)
+	if (adt && (adt->flag & ADT_NLA_EDIT_ON)) {
+		// greenish color (same as tweaking strip) - hardcoded for now
+		color[0]= 0.30f;
+		color[1]= 0.95f;
+		color[2]= 0.10f;
+		color[3]= 0.30f;
 	}
-	
-	/* adjust view transform before starting */
-	glTranslatef(x, y, 0.0f);
-	glScalef(1.0f/xscale*hsize, hsize, 1.0f);
-	
-	/* anti-aliased lines for more consistent appearance */
-	glEnable(GL_LINE_SMOOTH);
-	
-	/* draw! */
-	glCallList(displist);
-	
-	glDisable(GL_LINE_SMOOTH);
-	
-	/* restore view transform */
-	glScalef(xscale/hsize, 1.0f/hsize, 1.0);
-	glTranslatef(-x, -y, 0.0f);
+	else {
+		if (act) {
+			// reddish color - hardcoded for now 	
+			color[0]= 0.8f;
+			color[1]= 0.2f;
+			color[2]= 0.0f;
+			color[3]= 0.4f;
+		}
+		else {
+			// greyish-red color - hardcoded for now
+			color[0]= 0.6f;
+			color[1]= 0.5f;
+			color[2]= 0.5f;
+			color[3]= 0.3f;
+		}
+	}
 }
 
 /* draw the keyframes in the specified Action */
-static void nla_action_draw_keyframes (AnimData *adt, View2D *v2d, float y)
+static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, float y, float ymin, float ymax)
 {
 	ListBase keys = {NULL, NULL};
 	ActKeyColumn *ak;
-	float xscale;
+	float xscale, f1, f2;
+	float color[4];
 	
-	/* for now, color is hardcoded to be black */
-	glColor3f(0.0f, 0.0f, 0.0f);
-	
 	/* get a list of the keyframes with NLA-scaling applied */
-	action_to_keylist(adt, adt->action, &keys, NULL);
+	action_to_keylist(adt, act, &keys, NULL);
 	
+	if ELEM(NULL, act, keys.first)
+		return;
+	
+	/* draw a darkened region behind the strips 
+	 *	- get and reset the background color, this time without the alpha to stand out better 
+	 */
+	nla_action_get_color(adt, act, color);
+	glColor3fv(color);
+	/* 	- draw a rect from the first to the last frame (no extra overlaps for now) 
+	 *	  that is slightly stumpier than the track background (hardcoded 2-units here)
+	 */
+	f1= ((ActKeyColumn *)keys.first)->cfra;
+	f2= ((ActKeyColumn *)keys.last)->cfra;
+	
+	glRectf(f1, ymin+2, f2, ymax-2);
+	
+	
 	/* get View2D scaling factor */
 	UI_view2d_getscale(v2d, &xscale, NULL);
 	
-	/* just draw each keyframe as a simple dot (regardless of the selection status) */
+	/* for now, color is hardcoded to be black */
+	glColor3f(0.0f, 0.0f, 0.0f);
+	
+	/* just draw each keyframe as a simple dot (regardless of the selection status) 
+	 *	- size is 3.0f which is smaller than the editable keyframes, so that there is a distinction
+	 */
 	for (ak= keys.first; ak; ak= ak->next)
-		draw_nla_keyframe_ghost(ak->cfra, y, xscale, 3.0f);
+		draw_keyframe_shape(ak->cfra, y, xscale, 3.0f, 0, KEYFRAME_SHAPE_FRAME);
 	
 	/* free icons */
 	BLI_freelistN(&keys);
@@ -158,6 +170,7 @@
 
 /* Strips (Proper) ---------------------- */
 
+/* get colors for drawing NLA-Strips */
 static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float color[3])
 {
 	if (strip->type == NLASTRIP_TYPE_TRANSITION) {
@@ -179,6 +192,7 @@
 	}	
 	else if (strip->type == NLASTRIP_TYPE_META) {
 		/* Meta Clip */
+		// TODO: should temporary metas get different colours too?
 		if (strip->flag & NLASTRIP_FLAG_SELECT) {
 			/* selected - use a bold purple color */
 			// FIXME: hardcoded temp-hack colors
@@ -535,6 +549,7 @@
 				case ANIMTYPE_NLAACTION:
 				{
 					AnimData *adt= BKE_animdata_from_id(ale->id);
+					float color[4];
 					
 					/* just draw a semi-shaded rect spanning the width of the viewable area if there's data,
 					 * and a second darker rect within which we draw keyframe indicator dots if there's data
@@ -542,30 +557,17 @@
 					glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 					glEnable(GL_BLEND);
 						
-					// TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now)
-					if (adt && (adt->flag & ADT_NLA_EDIT_ON)) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list