Merge pull request #12176 from SamGondelman/rendering

Fix animation crash, make last frame inclusive
This commit is contained in:
Sam Gondelman 2018-01-16 10:05:48 -08:00 committed by GitHub
commit 3879626205
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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();
}