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.
This commit is contained in:
Joshua Leung
2015-04-14 17:10:04 +12:00
parent c95f38b92a
commit bb1bc7ecda
4 changed files with 15 additions and 20 deletions

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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)) {

View File

@@ -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;