Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-07-12 11:28:25 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-12 11:28:25 +0400
commit345be5cbbc8c78228b2ded7c2dcb7278c38631b1 (patch)
tree05d742b7db5161536e08f13d7745457d04973b43 /source/blender/editors/space_nla
parentfa8bd34d95d91712ffa6dc9066c255e9ee40e7e4 (diff)
2.5 - Tweaks for Split Strips in NLA and Graph Editor view ranges
* Split strips now uses the current frame as the splitting-point for selected strips if the current frame falls within in the bounds of the strip. Otherwise, the code defaults to splitting by the midpoints of the strips. * Time-range for Graph Editor is saner now when there is only a single keyframe or none at all.
Diffstat (limited to 'source/blender/editors/space_nla')
-rw-r--r--source/blender/editors/space_nla/nla_edit.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 9ddd8daab0d..01871d3d9d5 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -747,25 +747,37 @@ void NLA_OT_delete (wmOperatorType *ot)
// - variable-length splits?
/* split a given Action-Clip strip */
-static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip)
+static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, float cfra)
{
NlaStrip *nstrip;
- float midframe, midaframe, len;
+ float splitframe, splitaframe;
- /* 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);
+ /* calculate the frames to do the splitting at
+ * - use current frame if within extents of strip
+ */
+ if ((cfra > strip->start) && (cfra < strip->end)) {
+ /* use the current frame */
+ splitframe= cfra;
+ splitaframe= nlastrip_get_frame(strip, cfra, NLATIME_CONVERT_UNMAP);
+ }
+ else {
+ /* split in the middle */
+ float len;
+
+ /* strip extents */
+ len= strip->end - strip->start;
+ if (IS_EQ(len, 0.0f))
+ return;
+ else
+ splitframe= strip->start + (len / 2.0f);
+
+ /* action range */
+ len= strip->actend - strip->actstart;
+ if (IS_EQ(len, 0.0f))
+ splitaframe= strip->actend;
+ else
+ splitaframe= strip->actstart + (len / 2.0f);
+ }
/* make a copy (assume that this is possible) and append
* it immediately after the current strip
@@ -774,13 +786,16 @@ static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip
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
+ * to the splitframe values calculated above
*/
- strip->end= midframe;
- nstrip->start= midframe;
+ strip->end= splitframe;
+ nstrip->start= splitframe;
- strip->actend= midaframe;
- nstrip->actstart= midaframe;
+ if ((splitaframe > strip->actstart) && (splitaframe < strip->actend)) {
+ /* only do this if we're splitting down the middle... */
+ strip->actend= splitaframe;
+ nstrip->actstart= splitaframe;
+ }
/* clear the active flag from the copy */
nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE;
@@ -828,7 +843,7 @@ static int nlaedit_split_exec (bContext *C, wmOperator *op)
/* splitting method depends on the type of strip */
switch (strip->type) {
case NLASTRIP_TYPE_CLIP: /* action-clip */
- nlaedit_split_strip_actclip(adt, nlt, strip);
+ nlaedit_split_strip_actclip(adt, nlt, strip, (float)ac.scene->r.cfra);
break;
case NLASTRIP_TYPE_META: /* meta-strips need special handling */