From fc0f9e215909e15b5a09eb7edafdda4ce9dceada Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 17 Jan 2013 14:49:42 -0800 Subject: [PATCH] The animation state tracks the animation time for us --- apps/openmw/mwrender/animation.cpp | 28 +++++++++++----------------- apps/openmw/mwrender/animation.hpp | 1 - 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 4d9ee108c9..18aa982151 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -25,7 +25,6 @@ Animation::Animation(const MWWorld::Ptr &ptr) , mLastPosition(0.0f) , mCurrentKeys(NULL) , mAnimState(NULL) - , mTime(0.0f) { } @@ -121,10 +120,7 @@ void Animation::setController(MWMechanics::CharacterController *controller) void Animation::updatePosition(float time) { - if(time == mTime) - return; mAnimState->setTimePosition(time); - mTime = time; if(mNonAccumRoot) { @@ -152,7 +148,6 @@ void Animation::updatePosition(float time) void Animation::resetPosition(float time) { mAnimState->setTimePosition(time); - mTime = time; mNextKey = mCurrentKeys->begin(); while(mNextKey != mCurrentKeys->end() && mNextKey->first < time) @@ -216,21 +211,20 @@ void Animation::runAnimation(float timepassed) { while(mAnimState && timepassed > 0.0f) { - float targetTime = mTime + timepassed; - if(mNextKey != mCurrentKeys->end() && mNextKey->first <= targetTime) + float targetTime = mAnimState->getTimePosition() + timepassed; + if(mNextKey == mCurrentKeys->end() || mNextKey->first > targetTime) { - const std::string &evt = mNextKey->second; - updatePosition(mNextKey->first); - mNextKey++; - timepassed = targetTime - mTime; - - if(mController) - mController->markerEvent(evt); - continue; + updatePosition(targetTime); + break; } - updatePosition(targetTime); - timepassed = targetTime - mTime; + const std::string &evt = mNextKey->second; + updatePosition(mNextKey->first); + timepassed = targetTime - mNextKey->first; + mNextKey++; + + if(mController) + mController->markerEvent(evt); } } diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 722eccc30f..726d0cf388 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -30,7 +30,6 @@ protected: NifOgre::TextKeyMap *mCurrentKeys; NifOgre::TextKeyMap::const_iterator mNextKey; Ogre::AnimationState *mAnimState; - float mTime; /* Updates the animation to the specified time, and moves the mPtr object * based on the change since the last update or reset. */