[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20647] branches/soc-2009-aligorith/source /blender: NLA SoC: NLA-Evaluation Bugfixes

Joshua Leung aligorith at gmail.com
Fri Jun 5 13:51:28 CEST 2009


Revision: 20647
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20647
Author:   aligorith
Date:     2009-06-05 13:51:27 +0200 (Fri, 05 Jun 2009)

Log Message:
-----------
NLA SoC: NLA-Evaluation Bugfixes

* Fixed an evil bug where the last frame of a strip was always incorrectly evaluated. 
This was because these frames were not being included in the strip's 'range' as defined by the IN_RANGE() testing macro, which only considers the given range as an open interval (i.e. non-inclusive of boundary points). I've added a new macro, IN_RANGE_INCL(), which is inclusive of boundary points, since this is a common test in many other parts of the code.

* When an AnimData block is in 'tweaking' mode, the tracks following (and including the active track) are now correctly skipped during evaluation. 

* Finished coding the option of setting a single NLA-track per NLA-block to play 'solo' (i.e. only that track is enabled for evaluation). 
To enable this, simply click on one of the grey 'dots' beside the NLA-track names, turning this dot yellow. The 'yellow' dot means that the track will play by itself (even the 'active action' gets silenced). Only one track per AnimData block can play solo at a time. To disable, simply click on the 'yellow' dot again. 
NOTE: this currently uses the View3D layer-status icons. We probably need some special ones for these later (coloured vs grey star?)

* Also (not related to evaluation) made the selection operators for the NLA Editor only work when not in tweaking mode, since in tweaking mode they can potentially result in data being resolved inappropriately when leaving tweaking mode.

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/blenkernel/BKE_nla.h
    branches/soc-2009-aligorith/source/blender/blenkernel/BKE_utildefines.h
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_channels.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_select.c

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/BKE_nla.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/BKE_nla.h	2009-06-05 05:18:07 UTC (rev 20646)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/BKE_nla.h	2009-06-05 11:51:27 UTC (rev 20647)
@@ -56,12 +56,16 @@
 struct NlaTrack *BKE_nlatrack_find_active(ListBase *tracks);
 void BKE_nlatrack_set_active(ListBase *tracks, struct NlaTrack *nlt);
 
+void BKE_nlatrack_solo_toggle(struct AnimData *adt, struct NlaTrack *nlt);
+
 short BKE_nlatrack_has_space(struct NlaTrack *nlt, float start, float end);
 void BKE_nlatrack_sort_strips(struct NlaTrack *nlt);
 
+
 struct NlaStrip *BKE_nlastrip_find_active(struct NlaTrack *nlt);
 short BKE_nlastrip_within_bounds(struct NlaStrip *strip, float min, float max);
 
+
 void BKE_nla_action_pushdown(struct AnimData *adt);
 
 short BKE_nla_tweakmode_enter(struct AnimData *adt);

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/BKE_utildefines.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/BKE_utildefines.h	2009-06-05 05:18:07 UTC (rev 20646)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/BKE_utildefines.h	2009-06-05 11:51:27 UTC (rev 20647)
@@ -128,6 +128,7 @@
 
 #define IS_EQT(a, b, c) ((a > b)? (((a-b) <= c)? 1:0) : ((((b-a) <= c)? 1:0)))
 #define IN_RANGE(a, b, c) ((b < c)? ((b<a && a<c)? 1:0) : ((c<a && a<b)? 1:0))
+#define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0))
 
 /* this weirdo pops up in two places ... */
 #if !defined(WIN32) && !defined(__BeOS)

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c	2009-06-05 05:18:07 UTC (rev 20646)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/anim_sys.c	2009-06-05 11:51:27 UTC (rev 20647)
@@ -678,14 +678,10 @@
 	NlaEvalStrip *nes;
 	short side= 0;
 	
-	/* skip if track is muted or disabled */
-	if (nlt->flag & (NLATRACK_MUTED|NLATRACK_DISABLED)) 
-		return;
-	
 	/* loop over strips, checking if they fall within the range */
 	for (strip= nlt->strips.first; strip; strip= strip->next) {
 		/* check if current time occurs within this strip  */
-		if (IN_RANGE(ctime, strip->start, strip->end)) {
+		if (IN_RANGE_INCL(ctime, strip->start, strip->end)) {
 			/* this strip is active, so try to use it */
 			estrip= strip;
 			side= NES_TIME_WITHIN;
@@ -1013,8 +1009,21 @@
 	NlaEvalStrip *nes;
 	
 	/* 1. get the stack of strips to evaluate at current time (influence calculated here) */
-	for (nlt=adt->nla_tracks.first; nlt; nlt=nlt->next, track_index++) 
+	for (nlt=adt->nla_tracks.first; nlt; nlt=nlt->next, track_index++) { 
+		/* if tweaking is on and this strip is the tweaking track, stop on this one */
+		if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED))
+			break;
+			
+		/* skip if we're only considering a track tagged 'solo' */
+		if ((adt->flag & ADT_NLA_SOLO_TRACK) && (nlt->flag & NLATRACK_SOLO)==0)
+			continue;
+		/* skip if track is muted */
+		if (nlt->flag & NLATRACK_MUTED) 
+			continue;
+			
+		/* otherwise, get strip to evaluate for this channel */
 		nlatrack_ctime_get_strip(&estrips, nlt, track_index, ctime);
+	}
 	
 	/* only continue if there are strips to evaluate */
 	if (estrips.first == NULL)
@@ -1114,12 +1123,17 @@
 		/* evaluate NLA data */
 		if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF))
 		{
+			/* evaluate NLA-stack */
 			animsys_evaluate_nla(&id_ptr, adt, ctime);
+			
+			/* evaluate 'active' Action (may be tweaking track) on top of results of NLA-evaluation 
+			 *	- only do this if we're not exclusively evaluating the 'solo' NLA-track
+			 */
+			if ((adt->action) && !(adt->flag & ADT_NLA_SOLO_TRACK))
+				animsys_evaluate_action(&id_ptr, adt->action, adt->remap, ctime);
 		}
-		
-		/* evaluate Action data */
-		// FIXME: what if the solo track was not tweaking one, then nla-solo should be checked too?
-		if (adt->action) 
+		/* evaluate Active Action only */
+		else if (adt->action)
 			animsys_evaluate_action(&id_ptr, adt->action, adt->remap, ctime);
 		
 		/* reset tag */

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c	2009-06-05 05:18:07 UTC (rev 20646)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/nla.c	2009-06-05 11:51:27 UTC (rev 20647)
@@ -359,6 +359,38 @@
 	return NULL;
 }
 
+/* Toggle the 'solo' setting for the given NLA-track, making sure that it is the only one
+ * that has this status in its AnimData block.
+ */
+void BKE_nlatrack_solo_toggle (AnimData *adt, NlaTrack *nlt)
+{
+	NlaTrack *nt;
+	
+	/* sanity check */
+	if ELEM(NULL, adt, adt->nla_tracks.first)
+		return;
+		
+	/* firstly, make sure 'solo' flag for all tracks is disabled */
+	for (nt= adt->nla_tracks.first; nt; nt= nt->next) {
+		if (nt != nlt)
+			nt->flag &= ~NLATRACK_SOLO;
+	}
+		
+	/* now, enable 'solo' for the given track if appropriate */
+	if (nlt) {
+		/* toggle solo status */
+		nlt->flag ^= NLATRACK_SOLO;
+		
+		/* set or clear solo-status on AnimData */
+		if (nlt->flag & NLATRACK_SOLO)
+			adt->flag |= ADT_NLA_SOLO_TRACK;
+		else
+			adt->flag &= ~ADT_NLA_SOLO_TRACK;
+	}
+	else
+		adt->flag &= ~ADT_NLA_SOLO_TRACK;
+}
+
 /* Make the given NLA-track the active one for the given stack. If no track is provided, 
  * this function can be used to simply deactivate all the NLA tracks in the given stack too.
  */

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_channels.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_channels.c	2009-06-05 05:18:07 UTC (rev 20646)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_channels.c	2009-06-05 11:51:27 UTC (rev 20647)
@@ -326,7 +326,20 @@
 		case ANIMTYPE_NLATRACK:
 		{
 			NlaTrack *nlt= (NlaTrack *)ale->data;
+			AnimData *adt= BKE_animdata_from_id(ale->id);
+			short offset;
 			
+			/* offset for start of channel (on LHS of channel-list) */
+			if (ale->id) {
+				/* special exception for materials */
+				if (GS(ale->id->name) == ID_MA)
+					offset= 21 + NLACHANNEL_BUTTON_WIDTH;
+				else
+					offset= 14;
+			}
+			else
+				offset= 0;
+			
 			if (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) {
 				/* toggle protection (only if there's a toggle there) */
 				nlt->flag ^= NLATRACK_PROTECTED;
@@ -335,6 +348,10 @@
 				/* toggle mute */
 				nlt->flag ^= NLATRACK_MUTED;
 			}
+			else if (x <= ((NLACHANNEL_BUTTON_WIDTH*2)+offset)) {
+				/* toggle 'solo' */
+				BKE_nlatrack_solo_toggle(adt, nlt);
+			}
 			else {
 				/* set selection */
 				if (selectmode == SELECT_INVERT) {
@@ -359,7 +376,7 @@
 			
 			/* for now, only do something if user clicks on the 'push-down' button */
 			if (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) {
-				/* activate push-down operator */
+				/* activate push-down function */
 				// TODO: make this use the operator instead of calling the function directly
 				// 	however, calling the operator requires that we supply the args, and that works with proper buttons only
 				BKE_nla_action_pushdown(adt);

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h	2009-06-05 05:18:07 UTC (rev 20646)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h	2009-06-05 11:51:27 UTC (rev 20647)
@@ -30,6 +30,9 @@
 
 /* internal exports only */
 
+/* **************************************** */
+/* Macros, etc. only used by NLA */
+
 /* -------------- NLA Channel Defines -------------- */
 
 /* NLA channel heights */

Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_select.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_select.c	2009-06-05 05:18:07 UTC (rev 20646)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_select.c	2009-06-05 11:51:27 UTC (rev 20647)
@@ -199,7 +199,7 @@
 	
 	/* api callbacks */
 	ot->exec= nlaedit_deselectall_exec;
-	ot->poll= ED_operator_areaactive;
+	ot->poll= nlaop_poll_tweakmode_off;
 	
 	/* flags */
 	ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
@@ -441,7 +441,7 @@
 	
 	/* api callbacks - absolutely no exec() this yet... */
 	ot->invoke= nlaedit_clickselect_invoke;
-	ot->poll= ED_operator_areaactive;
+	ot->poll= nlaop_poll_tweakmode_off;
 	
 	/* flags */
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;





More information about the Bf-blender-cvs mailing list