diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-07-07 06:12:50 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-07-07 06:12:50 +0400 |
commit | 905b1380054f42fe30b19fb37861057af4760e32 (patch) | |
tree | 878b56d7ef97e56e4af8f6c46e710479441c81b0 /source/blender/blenkernel/intern/nla.c | |
parent | f98c3ed70b86d12945078c288c2bd3288a297841 (diff) |
NLA SoC: Start of integration of Meta-strips in Transform
* Chains of selected strips are now converted to meta-strips before transforms begin, and converted back afterwards. This simplifies the transform code needed in later stages...
* Transform-flushing code for Meta-Strips should now work. There seems to be a little bit of numeric inaccuracy problems somewhere, as two strips which met at the same frame can get separated when scaling.
* Meta-strips now draw with proper text identification
* Snapping strips now properly clears meta-strips if a moved strip needs to be moved into a new track to be accomodated.
* Fixed a filter used by a selection-operator.
Diffstat (limited to 'source/blender/blenkernel/intern/nla.c')
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index a83fa0abe1e..851a0d7b549 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -781,6 +781,8 @@ void BKE_nlameta_flush_transforms (NlaStrip *mstrip) { NlaStrip *strip; float oStart, oEnd, offset; + float oLen, nLen; + short scaleChanged= 0; /* sanity checks * - strip must exist @@ -806,16 +808,43 @@ void BKE_nlameta_flush_transforms (NlaStrip *mstrip) if (IS_EQ(oStart, mstrip->start) && IS_EQ(oEnd, mstrip->end)) return; + /* check if scale changed */ + oLen = oEnd - oStart; + nLen = mstrip->end - mstrip->start; + if (IS_EQ(nLen, oLen) == 0) + scaleChanged= 1; + /* for each child-strip, calculate new start/end points based on this new info */ for (strip= mstrip->strips.first; strip; strip= strip->next) { - //PointerRNA strip_ptr; - - /* firstly, just apply the changes in offset to both ends of the strip */ - strip->start += offset; - strip->end += offset; - - /* now, we need to fix the endpoint to take into account scaling */ - // TODO.. + if (scaleChanged) { + PointerRNA ptr; + float p1, p2, nStart, nEnd; + + /* compute positions of endpoints relative to old extents of strip */ + p1= (strip->start - oStart) / oLen; + p2= (strip->end - oStart) / oLen; + + /* compute the new strip endpoints using the proportions */ + nStart= (p1 * nLen) + mstrip->start; + nEnd= (p2 * nLen) + mstrip->start; + + /* firstly, apply the new positions manually, then apply using RNA + * - first time is to make sure no truncation errors from one endpoint not being + * set yet occur + * - second time is to make sure scale is computed properly... + */ + strip->start= nStart; + strip->end= nEnd; + + RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &ptr); + RNA_float_set(&ptr, "start_frame", nStart); + RNA_float_set(&ptr, "end_frame", nEnd); + } + else { + /* just apply the changes in offset to both ends of the strip */ + strip->start += offset; + strip->end += offset; + } /* finally, make sure the strip's children (if it is a meta-itself), get updated */ BKE_nlameta_flush_transforms(strip); |