[Bf-blender-cvs] [bb1bc7e] master: NLA: Store track that the strip being tweaked comes from

Joshua Leung noreply at git.blender.org
Tue Apr 14 08:40:29 CEST 2015


Commit: bb1bc7ecda28cc3c70992f8383151e4055a227e0
Author: Joshua Leung
Date:   Tue Apr 14 17:10:04 2015 +1200
Branches: master
https://developer.blender.org/rBbb1bc7ecda28cc3c70992f8383151e4055a227e0

NLA: Store track that the strip being tweaked comes from

There should be no functional changes visible from this change, but this commit
should make it easier to code tools which need to check on tweeakmode status,
by making it easier to figure out which NLA Track contains the strip which
owned the action being edited. (The strip is already saved, so this commit just
adds the track alongside it).

For now there is no version patch for this. The worst that happens is that an
extra refresh is needed in the NLA editor to get these to show up.

===================================================================

M	source/blender/blenkernel/intern/nla.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/animation/anim_filter.c
M	source/blender/makesdna/DNA_anim_types.h

===================================================================

diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index eaa4460..650efea 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -535,9 +535,14 @@ float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
 	/* if the active-strip info has been stored already, access this, otherwise look this up
 	 * and store for (very probable) future usage
 	 */
+	if (adt->act_track == NULL) {
+		if (adt->actstrip)
+			adt->act_track = BKE_nlatrack_find_tweaked(adt);
+		else
+			adt->act_track = BKE_nlatrack_find_active(&adt->nla_tracks);
+	}
 	if (adt->actstrip == NULL) {
-		NlaTrack *nlt = BKE_nlatrack_find_active(&adt->nla_tracks);
-		adt->actstrip = BKE_nlastrip_find_active(nlt);
+		adt->actstrip = BKE_nlastrip_find_active(adt->act_track);
 	}
 	strip = adt->actstrip;
 	
@@ -931,7 +936,6 @@ NlaTrack *BKE_nlatrack_find_active(ListBase *tracks)
  * as just using the active track, since multiple tracks may have been
  * entered at the same time.
  */
-// TODO: Store this info in AnimData... Old files would still need to use this function for version patching though
 NlaTrack *BKE_nlatrack_find_tweaked(AnimData *adt)
 {
 	NlaTrack *nlt;
@@ -1796,6 +1800,7 @@ bool BKE_nla_tweakmode_enter(AnimData *adt)
 	 */
 	adt->tmpact = adt->action;
 	adt->action = activeStrip->act;
+	adt->act_track = activeTrack;
 	adt->actstrip = activeStrip;
 	id_us_plus(&activeStrip->act->id);
 	adt->flag |= ADT_NLA_EDIT_ON;
@@ -1855,6 +1860,7 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
 	if (adt->action) adt->action->id.us--;
 	adt->action = adt->tmpact;
 	adt->tmpact = NULL;
+	adt->act_track = NULL;
 	adt->actstrip = NULL;
 	adt->flag &= ~ADT_NLA_EDIT_ON;
 }
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 9a269ca..9dd5245 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2431,12 +2431,13 @@ static void direct_link_animdata(FileData *fd, AnimData *adt)
 	link_list(fd, &adt->nla_tracks);
 	direct_link_nladata(fd, &adt->nla_tracks);
 	
-	/* relink active strip - even though strictly speaking this should only be used
+	/* relink active track/strip - even though strictly speaking this should only be used
 	 * if we're in 'tweaking mode', we need to be able to have this loaded back for
 	 * undo, but also since users may not exit tweakmode before saving (#24535)
 	 */
 	// TODO: it's not really nice that anyone should be able to save the file in this
 	//		state, but it's going to be too hard to enforce this single case...
+	adt->act_track = newdataadr(fd, adt->act_track);
 	adt->actstrip = newdataadr(fd, adt->actstrip);
 }	
 
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 25f2b0b..f575326 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1301,22 +1301,8 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop
 		 *	- active track should still get shown though (even though it has disabled flag set)
 		 */
 		// FIXME: the channels after should still get drawn, just 'differently', and after an active-action channel
-		if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED)) {
-			/* NOTE: The tweaking track may not be active, if strips from different AnimData blocks
-			 *       entered tweakmode at the same time. Since this loop works both ways, we can't
-			 *       just stop on the first disabled track we encounter...
-			 */
-			if (nlt->flag & NLATRACK_ACTIVE) {
-				/* OK = "the" active track */
-			}
-			else if (BLI_findindex(&nlt->strips, adt->actstrip) != -1) {
-				/* OK = this is the one containing the active strip */
-			}
-			else {
-				/* Not OK - neither of the previous two were met, so it must be one of the "later" ones */
-				continue;
-			}
-		}
+		if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED) && (adt->act_track != nlt))
+			continue;
 		
 		/* only work with this channel and its subchannels if it is editable */
 		if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) {
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 693e0fc..68f80cb 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -853,6 +853,8 @@ typedef struct AnimData {
 
 		/* nla-tracks */
 	ListBase    nla_tracks;
+		/* active NLA-track (only set/used during tweaking, so no need to worry about dangling pointers) */
+	NlaTrack	*act_track;
 		/* active NLA-strip (only set/used during tweaking, so no need to worry about dangling pointers) */
 	NlaStrip    *actstrip;




More information about the Bf-blender-cvs mailing list