diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-01-24 09:28:53 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-01-24 09:28:53 +0300 |
commit | ac38eba721a5c0d8c9cf47c0222b38212acb9ae6 (patch) | |
tree | e962e250a9f6348f51befddbdf63228a0d14d53a /source/blender/blenkernel | |
parent | 351d239ac7cdc028549ae84f2ff1acd594570a07 (diff) |
NLA Editor: Sync Action Extents with Referenced Range
This operator can be accessed from the "Action Clip" panel, and is used to include keyframes that have been added to a strip already in the NLA. Although this is not a recommended workflow, having this ability is useful at times.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_nla.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 989043c1d67..780f871ebd8 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -83,6 +83,7 @@ struct NlaStrip *BKE_nlastrip_find_active(struct NlaTrack *nlt); void BKE_nlastrip_set_active(struct AnimData *adt, struct NlaStrip *strip); short BKE_nlastrip_within_bounds(struct NlaStrip *strip, float min, float max); +void BKE_nlastrip_recalculate_bounds(struct NlaStrip *strip); void BKE_nlastrip_validate_name(struct AnimData *adt, struct NlaStrip *strip); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index c9008e91646..2af9159f70f 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1035,6 +1035,31 @@ short BKE_nlastrip_within_bounds (NlaStrip *strip, float min, float max) return 1; } +/* Recalculate the start and end frames for the current strip, after changing + * the extents of the action or the mapping (repeats or scale factor) info + */ +void BKE_nlastrip_recalculate_bounds (NlaStrip *strip) +{ + float actlen, mapping; + + /* sanity checks + * - must have a strip + * - can only be done for action clips + */ + if ((strip == NULL) || (strip->type != NLASTRIP_TYPE_CLIP)) + return; + + /* calculate new length factors */ + actlen= strip->actend - strip->actstart; + if (IS_EQ(actlen, 0.0f)) actlen= 1.0f; + + mapping= strip->scale * strip->repeat; + + /* adjust endpoint of strip in response to this */ + if (IS_EQ(mapping, 0.0f) == 0) + strip->end = (actlen * mapping) + strip->start; +} + /* Is the given NLA-strip the first one to occur for the given AnimData block */ // TODO: make this an api method if necesary, but need to add prefix first static short nlastrip_is_first (AnimData *adt, NlaStrip *strip) |