diff --git a/src/animation/tweening.cpp b/src/animation/tweening.cpp index d58e153..c487049 100644 --- a/src/animation/tweening.cpp +++ b/src/animation/tweening.cpp @@ -2,23 +2,20 @@ #include "animationRules.h" JoiningContinuousTimeline insertTweens(const JoiningContinuousTimeline& animation) { - centiseconds minTweenDuration = 4_cs; - centiseconds maxTweenDuration = 8_cs; + const centiseconds minTweenDuration = 4_cs; + const centiseconds maxTweenDuration = 8_cs; JoiningContinuousTimeline result(animation); - for (auto first = animation.begin(), second = std::next(animation.begin()); - first != animation.end() && second != animation.end(); - ++first, ++second) - { - auto pair = getTween(first->getValue(), second->getValue()); - if (!pair) continue; + for_each_adjacent(animation.begin(), animation.end(), [&](const auto& first, const auto& second) { + auto pair = getTween(first.getValue(), second.getValue()); + if (!pair) return; Shape tweenShape; TweenTiming tweenTiming; std::tie(tweenShape, tweenTiming) = *pair; - TimeRange firstTimeRange = first->getTimeRange(); - TimeRange secondTimeRange = second->getTimeRange(); + TimeRange firstTimeRange = first.getTimeRange(); + TimeRange secondTimeRange = second.getTimeRange(); centiseconds tweenStart, tweenDuration; switch (tweenTiming) { @@ -39,10 +36,10 @@ JoiningContinuousTimeline insertTweens(const JoiningContinuousTimeline #include #include +#include using std::string; @@ -62,6 +63,9 @@ ProgressBar::~ProgressBar() { void ProgressBar::reportProgress(double value) { // Make sure value is in [0..1] range value = boost::algorithm::clamp(value, 0.0, 1.0); + if (std::isnan(value)) { + value = 0.0; + } currentProgress = value; }