diff --git a/src/animation/mouthAnimation.cpp b/src/animation/mouthAnimation.cpp index f43db6a..6178ee3 100644 --- a/src/animation/mouthAnimation.cpp +++ b/src/animation/mouthAnimation.cpp @@ -20,11 +20,11 @@ using boost::adaptors::transformed; using std::pair; using std::tuple; -JoiningTimeline createTweens(JoiningContinuousTimeline shapes) { +JoiningContinuousTimeline insertTweens(JoiningContinuousTimeline shapes) { centiseconds minTweenDuration = 4_cs; centiseconds maxTweenDuration = 10_cs; - JoiningTimeline tweens; + JoiningContinuousTimeline result(shapes); for (auto first = shapes.begin(), second = std::next(shapes.begin()); first != shapes.end() && second != shapes.end(); @@ -60,14 +60,14 @@ JoiningTimeline createTweens(JoiningContinuousTimeline shapes) { if (tweenDuration < minTweenDuration) continue; - tweens.set(tweenStart, tweenStart + tweenDuration, tweenShape); + result.set(tweenStart, tweenStart + tweenDuration, tweenShape); } - return tweens; + return result; } -JoiningTimeline animatePauses(const JoiningContinuousTimeline& shapes) { - JoiningTimeline result; +JoiningContinuousTimeline animatePauses(const JoiningContinuousTimeline& shapes) { + JoiningContinuousTimeline result(shapes); // Don't close mouth for short pauses for_each_adjacent(shapes.begin(), shapes.end(), [&](const Timed& lhs, const Timed& pause, const Timed& rhs) { @@ -145,7 +145,7 @@ ContinuousTimeline getShapeRules(const BoundedTimeline& phones // always choosing a shape from the current set that resembles the last shape and is somewhat relaxed. // * When speaking, we anticipate vowels, trying to form their shape before the actual vowel. // So whenever we come across a one-shape vowel, we backtrack a little, spreating that shape to the left. -JoiningContinuousTimeline animate(const ContinuousTimeline& shapeRules) { +JoiningContinuousTimeline animateRough(const ContinuousTimeline& shapeRules) { JoiningContinuousTimeline shapes(shapeRules.getRange(), X); Shape referenceShape = X; @@ -192,22 +192,12 @@ JoiningContinuousTimeline animate(const ContinuousTimeline& sh JoiningContinuousTimeline animate(const BoundedTimeline &phones) { // Create timeline of shape rules - ContinuousTimeline shapeRules = getShapeRules(phones); + const ContinuousTimeline shapeRules = getShapeRules(phones); // Animate - JoiningContinuousTimeline shapes = animate(shapeRules); - - // Animate pauses - JoiningTimeline pauses = animatePauses(shapes); - for (const auto& pause : pauses) { - shapes.set(pause); - } - - // Create inbetweens for smoother animation - JoiningTimeline tweens = createTweens(shapes); - for (const auto& tween : tweens) { - shapes.set(tween); - } + JoiningContinuousTimeline shapes = animateRough(shapeRules); + shapes = animatePauses(shapes); + shapes = insertTweens(shapes); for (const auto& timedShape : shapes) { logTimedEvent("shape", timedShape);