Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/nla.c
| Show First 20 Lines • Show All 967 Lines • ▼ Show 20 Lines | void BKE_nlameta_flush_transforms(NlaStrip *mstrip) | ||||
| /* get the original start/end points, and calculate the start-frame offset | /* get the original start/end points, and calculate the start-frame offset | ||||
| * - these are simply the start/end frames of the child strips, | * - these are simply the start/end frames of the child strips, | ||||
| * since we assume they weren't transformed yet | * since we assume they weren't transformed yet | ||||
| */ | */ | ||||
| oStart = ((NlaStrip *)mstrip->strips.first)->start; | oStart = ((NlaStrip *)mstrip->strips.first)->start; | ||||
| oEnd = ((NlaStrip *)mstrip->strips.last)->end; | oEnd = ((NlaStrip *)mstrip->strips.last)->end; | ||||
| offset = mstrip->start - oStart; | offset = mstrip->start - oStart; | ||||
| /* check if scale changed */ | |||||
| oLen = oEnd - oStart; | |||||
| nLen = mstrip->end - mstrip->start; | |||||
| scaleChanged = !IS_EQF(oLen, nLen); | |||||
| /* optimization: | /* optimization: | ||||
| * don't flush if nothing changed yet | * don't flush if nothing changed yet | ||||
| * TODO: maybe we need a flag to say always flush? | * TODO: maybe we need a flag to say always flush? | ||||
| */ | */ | ||||
| if (IS_EQF(oStart, mstrip->start) && IS_EQF(oEnd, mstrip->end)) { | if (IS_EQF(oStart, mstrip->start) && IS_EQF(oEnd, mstrip->end) && !scaleChanged) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* check if scale changed */ | |||||
| oLen = oEnd - oStart; | |||||
| nLen = mstrip->end - mstrip->start; | |||||
| if (IS_EQF(nLen, oLen) == 0) { | |||||
| scaleChanged = 1; | |||||
| } | |||||
| /* for each child-strip, calculate new start/end points based on this new info */ | /* for each child-strip, calculate new start/end points based on this new info */ | ||||
| for (strip = mstrip->strips.first; strip; strip = strip->next) { | for (strip = mstrip->strips.first; strip; strip = strip->next) { | ||||
| if (scaleChanged) { | if (scaleChanged) { | ||||
| float p1, p2; | float p1, p2; | ||||
| /* compute positions of endpoints relative to old extents of strip */ | /* compute positions of endpoints relative to old extents of strip */ | ||||
| p1 = (strip->start - oStart) / oLen; | p1 = (strip->start - oStart) / oLen; | ||||
| p2 = (strip->end - oStart) / oLen; | p2 = (strip->end - oStart) / oLen; | ||||
| /* Apply new strip endpoints using the proportions, | /* Apply new strip endpoints using the proportions, | ||||
| * then wait for second pass to flush scale properly. */ | * then wait for second pass to flush scale properly. */ | ||||
| strip->start = (p1 * nLen) + mstrip->start; | strip->start = (p1 * nLen) + mstrip->start; | ||||
| strip->end = (p2 * nLen) + mstrip->start; | strip->end = (p2 * nLen) + mstrip->start; | ||||
| // Recompute the playback scale, given the new start & end frame of the strip. | |||||
| const double action_len = strip->actend - strip->actstart; | |||||
| const double repeated_len = action_len * strip->repeat; | |||||
| const double strip_len = strip->end - strip->start; | |||||
| strip->scale = strip_len / repeated_len; | |||||
| } | } | ||||
| else { | else { | ||||
| /* just apply the changes in offset to both ends of the strip */ | /* just apply the changes in offset to both ends of the strip */ | ||||
| strip->start += offset; | strip->start += offset; | ||||
| strip->end += offset; | strip->end += offset; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,287 Lines • Show Last 20 Lines | |||||