fix crash on last frame = first frame, make last frame inclusive

(cherry picked from commit f1253e3c6c)
This commit is contained in:
SamGondelman 2018-01-15 15:01:17 -08:00
parent c3648fb04c
commit 9d721ba605

View file

@ -267,9 +267,9 @@ void ModelEntityItem::updateFrameCount() {
if (!getAnimationHold() && getAnimationIsPlaying()) {
float deltaTime = (float)interval / (float)USECS_PER_SECOND;
_currentFrame += (deltaTime * getAnimationFPS());
if (_currentFrame > getAnimationLastFrame()) {
if (getAnimationLoop()) {
_currentFrame = getAnimationFirstFrame() + (int)(glm::floor(_currentFrame - getAnimationFirstFrame())) % (updatedFrameCount - 1);
if (_currentFrame > getAnimationLastFrame() + 1) {
if (getAnimationLoop() && getAnimationFirstFrame() != getAnimationLastFrame()) {
_currentFrame = getAnimationFirstFrame() + (int)(_currentFrame - getAnimationFirstFrame()) % updatedFrameCount;
} else {
_currentFrame = getAnimationLastFrame();
}