diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 345d66534..99623e1ea 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -55,7 +55,6 @@ Animation::Animation(const MWWorld::Ptr &ptr) , mAnimVelocity(0.0f) , mAnimSpeedMult(1.0f) { - mSource = NULL; mAnimationValuePtr.bind(OGRE_NEW AnimationValue(this)); } @@ -196,7 +195,6 @@ void Animation::clearAnimSources() { mStates.clear(); - mSource = NULL; mAnimationName.empty(); mNonAccumCtrl = NULL; @@ -506,12 +504,12 @@ bool Animation::play(const std::string &groupname, const std::string &start, con continue; foundanim = true; + state.mSource = &*iter; state.mLoopCount = loops; state.mPlaying = true; mStates[groupname] = state; // FIXME - mSource = &*iter; mAnimationName = groupname; mNonAccumCtrl = nonaccumctrl; @@ -592,10 +590,11 @@ Ogre::Vector3 Animation::runAnimation(float duration) for(size_t i = 0;i < mObjectRoot.mControllers.size();i++) mObjectRoot.mControllers[i].update(); - if(mSource) + if(!mAnimationName.empty() && (stateiter=mStates.find(mAnimationName)) != mStates.end()) { - for(size_t i = 0;i < mSource->mControllers.size();i++) - mSource->mControllers[i].update(); + AnimSource *src = stateiter->second.mSource; + for(size_t i = 0;i < src->mControllers.size();i++) + src->mControllers[i].update(); } if(mSkelBase) diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 31ae919e7..1721849b0 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -36,6 +36,7 @@ protected: typedef std::vector AnimSourceList; struct AnimState { + AnimSource *mSource; NifOgre::TextKeyMap::const_iterator mStartKey; NifOgre::TextKeyMap::const_iterator mLoopStartKey; NifOgre::TextKeyMap::const_iterator mStopKey; @@ -46,7 +47,7 @@ protected: bool mPlaying; size_t mLoopCount; - AnimState() : mTime(0.0f), mPlaying(false), mLoopCount(0) + AnimState() : mSource(NULL), mTime(0.0f), mPlaying(false), mLoopCount(0) { } }; typedef std::map AnimStateMap; @@ -69,7 +70,6 @@ protected: AnimStateMap mStates; // Note: One per animation group (lower body, upper body, left arm, etc). - AnimSource *mSource; std::string mAnimationName; Ogre::SharedPtr mAnimationValuePtr;