diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-07-06 16:24:09 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-07-06 16:24:09 +0400 |
commit | f98c3ed70b86d12945078c288c2bd3288a297841 (patch) | |
tree | 00dd7a85ef217aecf6fb21d1d6ff46731f4c7cd5 /source/blender/editors/space_nla | |
parent | 158657026122d3b169f1bea12a69ff8eb16bbe04 (diff) |
NLA SoC: Fixes for Meta-Strips and Editing
* Split strip (YKEY) now plays nicely with Transitions and Metas. Meta strips get split up into their child strips, while transitions are ignored.
* Wrapped Meta_Strip->strips in RNA
* Bugfixes in Meta-strip API functions to silence some runtime-errors...
Diffstat (limited to 'source/blender/editors/space_nla')
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 96 |
1 files changed, 62 insertions, 34 deletions
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index f7d4db17e2c..676d0aac1b1 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -736,6 +736,55 @@ void NLA_OT_delete (wmOperatorType *ot) // - multiple splits // - variable-length splits? +/* split a given Action-Clip strip */ +static void nlaedit_split_strip_actclip (NlaTrack *nlt, NlaStrip *strip) +{ + NlaStrip *nstrip; + float midframe, midaframe, len; + + /* calculate the frames to do the splitting at */ + /* strip extents */ + len= strip->end - strip->start; + if (IS_EQ(len, 0.0f)) + return; + else + midframe= strip->start + (len / 2.0f); + + /* action range */ + len= strip->actend - strip->actstart; + if (IS_EQ(len, 0.0f)) + midaframe= strip->actend; + else + midaframe= strip->actstart + (len / 2.0f); + + /* make a copy (assume that this is possible) and append + * it immediately after the current strip + */ + nstrip= copy_nlastrip(strip); + BLI_insertlinkafter(&nlt->strips, strip, nstrip); + + /* set the endpoint of the first strip and the start of the new strip + * to the midframe values calculated above + */ + strip->end= midframe; + nstrip->start= midframe; + + strip->actend= midaframe; + nstrip->actstart= midaframe; + + /* clear the active flag from the copy */ + nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE; +} + +/* split a given Meta strip */ +static void nlaedit_split_strip_meta (NlaTrack *nlt, NlaStrip *strip) +{ + /* simply ungroup it for now... */ + BKE_nlastrips_clear_metastrip(&nlt->strips, strip); +} + +/* ----- */ + static int nlaedit_split_exec (bContext *C, wmOperator *op) { bAnimContext ac; @@ -755,47 +804,26 @@ static int nlaedit_split_exec (bContext *C, wmOperator *op) /* for each NLA-Track, split all selected strips into two strips */ for (ale= anim_data.first; ale; ale= ale->next) { NlaTrack *nlt= (NlaTrack *)ale->data; - NlaStrip *strip, *nstrip, *next; + NlaStrip *strip, *next; for (strip= nlt->strips.first; strip; strip= next) { next= strip->next; /* if selected, split the strip at its midpoint */ if (strip->flag & NLASTRIP_FLAG_SELECT) { - float midframe, midaframe, len; - - /* calculate the frames to do the splitting at */ - /* strip extents */ - len= strip->end - strip->start; - if (IS_EQ(len, 0.0f)) - continue; - else - midframe= strip->start + (len / 2.0f); + /* splitting method depends on the type of strip */ + switch (strip->type) { + case NLASTRIP_TYPE_CLIP: /* action-clip */ + nlaedit_split_strip_actclip(nlt, strip); + break; + + case NLASTRIP_TYPE_META: /* meta-strips need special handling */ + nlaedit_split_strip_meta(nlt, strip); + break; - /* action range */ - len= strip->actend - strip->actstart; - if (IS_EQ(len, 0.0f)) - midaframe= strip->actend; - else - midaframe= strip->actstart + (len / 2.0f); - - /* make a copy (assume that this is possible) and append - * it immediately after the current strip - */ - nstrip= copy_nlastrip(strip); - BLI_insertlinkafter(&nlt->strips, strip, nstrip); - - /* set the endpoint of the first strip and the start of the new strip - * to the midframe values calculated above - */ - strip->end= midframe; - nstrip->start= midframe; - - strip->actend= midaframe; - nstrip->actstart= midaframe; - - /* clear the active flag from the copy */ - nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE; + default: /* for things like Transitions, do not split! */ + break; + } } } } |