[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17579] branches/animsys2/source/blender: AnimSys2: Finishing off dopesheet and NLA issues

Joshua Leung aligorith at gmail.com
Wed Nov 26 12:01:57 CET 2008


Revision: 17579
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17579
Author:   aligorith
Date:     2008-11-26 12:01:56 +0100 (Wed, 26 Nov 2008)

Log Message:
-----------
AnimSys2: Finishing off dopesheet and NLA issues

* Added scaling support to the column-select tools 
* Fixed the Action keyframe summary that's included in the Object summaries, so that it shows with NLA scaling
* Made a few irrelevant entries in the menus be hidden too

Modified Paths:
--------------
    branches/animsys2/source/blender/include/BDR_drawaction.h
    branches/animsys2/source/blender/src/drawaction.c
    branches/animsys2/source/blender/src/editaction.c
    branches/animsys2/source/blender/src/header_action.c

Modified: branches/animsys2/source/blender/include/BDR_drawaction.h
===================================================================
--- branches/animsys2/source/blender/include/BDR_drawaction.h	2008-11-26 06:14:41 UTC (rev 17578)
+++ branches/animsys2/source/blender/include/BDR_drawaction.h	2008-11-26 11:01:56 UTC (rev 17579)
@@ -95,6 +95,7 @@
 void ipo_to_keylist(struct Ipo *ipo, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
 void agroup_to_keylist(struct bActionGroup *agrp, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
 void action_to_keylist(struct bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
+void action_nlascaled_to_keylist(struct Object *ob, struct bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
 void ob_to_keylist(struct Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
 void gpl_to_keylist(struct bGPDlayer *gpl, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
 

Modified: branches/animsys2/source/blender/src/drawaction.c
===================================================================
--- branches/animsys2/source/blender/src/drawaction.c	2008-11-26 06:14:41 UTC (rev 17578)
+++ branches/animsys2/source/blender/src/drawaction.c	2008-11-26 11:01:56 UTC (rev 17579)
@@ -121,29 +121,21 @@
 
 #define XIC 20
 #define YIC 20
-
-	/* lets make the rvk sliders */
-
+	
+	/* lets make the shapekey sliders */
+	
 	/* reset the damn myortho2 or the sliders won't draw/redraw
 	 * correctly *grumble*
 	 */
 	mywinset(curarea->win);
 	myortho2(-0.375f, curarea->winx-0.375f, G.v2d->cur.ymin, G.v2d->cur.ymax);
-
+	
     sprintf(str, "actionbuttonswin %d", curarea->win);
     block= uiNewBlock (&curarea->uiblocks, str, UI_EMBOSS, UI_HELV, curarea->win);
 
 	x = NAMEWIDTH + 1;
     y = 0.0f;
-
-	/* make the little 'open the sliders' widget */
-	// should eventually be removed
-    BIF_ThemeColor(TH_FACE); // this slot was open... (???... Aligorith)
-	glRects(2, (short)y + 2*CHANNELHEIGHT - 2, ACTWIDTH - 2, (short)y + CHANNELHEIGHT + 2);
-	glColor3ub(0, 0, 0);
-	glRasterPos2f(4, y + CHANNELHEIGHT + 6);
-	BMF_DrawString(G.font, "Sliders");
-
+	
 	uiBlockSetEmboss(block, UI_EMBOSSN);
 
 	if (!(G.saction->flag & SACTION_SLIDERS)) {
@@ -156,7 +148,6 @@
 					  "Show action window sliders");
 		/* no hilite, the winmatrix is not correct later on... */
 		uiButSetFlag(but, UI_NO_HILITE);
-
 	}
 	else {
 		but= uiDefIconButBitS(block, TOG, SACTION_SLIDERS, B_REDR, 
@@ -2092,7 +2083,7 @@
 		/* get filterflag */
 		if (ads)
 			filterflag= ads->filterflag;
-		else if (aki && aki->actmode == -1) /* only set like this by NLA */
+		else if ((aki) && (aki->actmode == -1)) /* only set like this by NLA */
 			filterflag= ADS_FILTER_NLADUMMY;
 		else
 			filterflag= 0;
@@ -2102,10 +2093,8 @@
 			ipo_to_keylist(ob->ipo, keys, blocks, aki);
 		
 		/* Add action keyframes */
-		// FIXME: we may need to apply NLA-scaling here...
-		if ((ob->action) && !(filterflag & ADS_FILTER_NOACTS)) {
-			action_to_keylist(ob->action, keys, blocks, aki);
-		}
+		if ((ob->action) && !(filterflag & ADS_FILTER_NOACTS))
+			action_nlascaled_to_keylist(ob, ob->action, keys, blocks, aki);
 		
 		/* Add shapekey keyframes (only if dopesheet allows, if it is available) */
 		if ((key && key->ipo) && !(filterflag & ADS_FILTER_NOSHAPEKEYS))
@@ -2284,6 +2273,52 @@
 	}
 }
 
+void action_nlascaled_to_keylist(Object *ob, bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
+{
+	bActionChannel *achan;
+	bConstraintChannel *conchan;
+	Object *oldob= NULL;
+	
+	/* although apply and clearing NLA-scaling pre-post creating keylist does impact on performance,
+	 * the effects should be fairly minimal, as we're already going through the keyframes multiple times 
+	 * already for blocks too...
+	 */
+	if (act) {	
+		/* if 'aki' is provided, store it's current ob to restore later as it might not be the same */
+		if (aki) {
+			oldob= aki->ob;
+			aki->ob= ob;
+		}
+		
+		/* loop through action channels */
+		for (achan= act->chanbase.first; achan; achan= achan->next) {
+			/* firstly, add keys from action channel's ipo block 
+			 *	- scaling correction only does times for center-points, so should be faster
+			 */
+			if (achan->ipo) {
+				actstrip_map_ipo_keys(ob, achan->ipo, 0, 1);
+				ipo_to_keylist(achan->ipo, keys, blocks, aki);
+				actstrip_map_ipo_keys(ob, achan->ipo, 1, 1);
+			}
+			
+			/* then, add keys from constraint channels 
+			 *	- scaling correction only does times for center-points, so should be faster
+			 */
+			for (conchan= achan->constraintChannels.first; conchan; conchan= conchan->next) {
+				if (conchan->ipo) {
+					actstrip_map_ipo_keys(ob, conchan->ipo, 0, 1);
+					ipo_to_keylist(conchan->ipo, keys, blocks, aki);
+					actstrip_map_ipo_keys(ob, conchan->ipo, 1, 1);
+				}
+			}
+		}
+		
+		/* if 'aki' is provided, restore ob */
+		if (aki)
+			aki->ob= oldob;
+	}
+}
+
 void gpl_to_keylist(bGPDlayer *gpl, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
 {
 	bGPDframe *gpf;

Modified: branches/animsys2/source/blender/src/editaction.c
===================================================================
--- branches/animsys2/source/blender/src/editaction.c	2008-11-26 06:14:41 UTC (rev 17578)
+++ branches/animsys2/source/blender/src/editaction.c	2008-11-26 11:01:56 UTC (rev 17579)
@@ -4175,7 +4175,6 @@
 			make_marker_cfra_list(&elems, 1);
 			
 			/* apply scaled action correction if needed */
-			// FIXME: this can also apply in the dopesheet for channels... how to fix?
 			if (NLA_ACTION_SCALED && datatype==ACTCONT_ACTION) {
 				for (ce= elems.first; ce; ce= ce->next) 
 					ce->cfra= get_action_frame(OBACT, ce->cfra);
@@ -4187,7 +4186,6 @@
 			BLI_addtail(&elems, ce);
 			
 			/* apply scaled action correction if needed */
-			// FIXME: this can also apply in the dopesheet for channels... how to fix?
 			if (NLA_ACTION_SCALED && datatype==ACTCONT_ACTION)
 				ce->cfra= (float)get_action_frame(OBACT, (float)CFRA);
 			else
@@ -4205,13 +4203,21 @@
 	
 	for (ale= act_data.first; ale; ale= ale->next) {
 		for (ce= elems.first; ce; ce= ce->next) {
+			int ecfra;
+			
+			/* apply scaling? */
+			if (NLA_CHAN_SCALED(ale) && NLA_ACTION_SCALED==0)
+				ecfra= (int)get_action_frame((Object *)ale->id, ce->cfra);
+			else
+				ecfra= ce->cfra;
+			
 			/* select elements with frame number matching cfraelem */
 			if (ale->type == ACTTYPE_GPLAYER) {
 				bGPDlayer *gpl= (bGPDlayer *)ale->data;
 				bGPDframe *gpf;
 				
 				for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
-					if ( (int)ce->cfra == gpf->framenum ) 
+					if (ecfra == gpf->framenum) 
 						gpf->flag |= GP_FRAME_SELECT;
 				}
 			}
@@ -4222,8 +4228,8 @@
 					
 					for (bezt=icu->bezt; verts<icu->totvert; bezt++, verts++) {
 						if (bezt) {
-							if( (int)(ce->cfra) == (int)(bezt->vec[1][0]) )
-								bezt->f2 |= 1;
+							if (ecfra == (int)(bezt->vec[1][0]))
+								bezt->f2 |= SELECT;
 						}
 					}
 				}
@@ -4552,7 +4558,7 @@
 	
 	void *act_channel;
 	short sel, act_type = 0;
-	float selx = 0.0;
+	float selx = 0.0f, selxa;
 	
 	/* determine what type of data we are operating on */
 	data = get_action_context(&datatype);
@@ -4718,13 +4724,15 @@
 		else if (ob) {
 			if (ob->ipo) 
 				select_ipo_key(ob->ipo, selx, selectmode);
+			
+			if (ob->action) {
+				selxa= get_action_frame(ob, selx);
 				
-			if (ob->action) {
 				for (achan= ob->action->chanbase.first; achan; achan= achan->next) {
-					select_ipo_key(achan->ipo, selx, selectmode);
+					select_ipo_key(achan->ipo, selxa, selectmode);
 					
 					for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next)
-						select_ipo_key(conchan->ipo, selx, selectmode);
+						select_ipo_key(conchan->ipo, selxa, selectmode);
 				}
 			}
 			

Modified: branches/animsys2/source/blender/src/header_action.c
===================================================================
--- branches/animsys2/source/blender/src/header_action.c	2008-11-26 06:14:41 UTC (rev 17578)
+++ branches/animsys2/source/blender/src/header_action.c	2008-11-26 11:01:56 UTC (rev 17579)
@@ -996,13 +996,15 @@
 	uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
 					menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 	
-	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
-			"Delete|X", 0, yco-=20,
-			menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_CHANNELS_DELETE, "");
-	
-	uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
-					menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+	if (G.saction->mode == SACTCONT_ACTION) {
+		uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
+				"Delete|X", 0, yco-=20,
+				menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_CHANNELS_DELETE, "");
 		
+		uiDefBut(block, SEPR, 0, "", 0, yco-=6, 
+						menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+	}
+		
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, 
 			"Toggle Show Hierachy|~", 0, yco-=20,
 			menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_CHANNELS_EXPANDALL, "");





More information about the Bf-blender-cvs mailing list