Skip to content

Commit

Permalink
Merge pull request #1263 from rolandhill/samplerTime
Browse files Browse the repository at this point in the history
Ensure animation ends on final key frame
  • Loading branch information
robertosfield authored Aug 19, 2024
2 parents e036168 + 6360fe4 commit b64dbb2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/vsg/animation/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ bool Animation::update(double simulationTime)
{
if (!_active) return false;

bool finished = false;

auto time_within_period = [](double x, double y) -> double {
return x < 0.0 ? y + std::fmod(x, y) : std::fmod(x, y);
};
Expand All @@ -153,8 +155,8 @@ bool Animation::update(double simulationTime)
{
if (time > _maxTime)
{
stop(simulationTime);
return false;
finished = true;
samplerTime = time = _maxTime;
}
}

Expand All @@ -163,6 +165,12 @@ bool Animation::update(double simulationTime)
sampler->update(samplerTime);
}

if(finished)
{
stop(simulationTime);
return false;
}

return true;
}

Expand Down

0 comments on commit b64dbb2

Please sign in to comment.