diff options
-rw-r--r-- | source/blender/blenkernel/BKE_nla.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_utildefines.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 34 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 32 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_channels.c | 19 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_select.c | 4 |
7 files changed, 84 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 89e5f1af7e1..da824fd2093 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -56,12 +56,16 @@ struct NlaStrip *add_nlastrip_to_stack(struct AnimData *adt, struct bAction *act 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); diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 6584af085cd..0bed2c095e2 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -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) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index dbc38d2fc7e..fb4c2663c3c 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -678,14 +678,10 @@ static void nlatrack_ctime_get_strip (ListBase *list, NlaTrack *nlt, short index 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 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) 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 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re /* 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 */ diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 84f98096364..d3a01b6d610 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -359,6 +359,38 @@ NlaTrack *BKE_nlatrack_find_active (ListBase *tracks) 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. */ diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 8db85ffa0b1..ed401c3596b 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -326,6 +326,19 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh 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) */ @@ -335,6 +348,10 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh /* 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 @@ static void mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sh /* 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); diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index a7188a7cccd..3d8cb7548c0 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -30,6 +30,9 @@ /* internal exports only */ +/* **************************************** */ +/* Macros, etc. only used by NLA */ + /* -------------- NLA Channel Defines -------------- */ /* NLA channel heights */ diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 2e3d5572711..463479c0909 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -199,7 +199,7 @@ void NLAEDIT_OT_select_all_toggle (wmOperatorType *ot) /* 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 @@ void NLAEDIT_OT_click_select (wmOperatorType *ot) /* 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; |