diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 81701c65e..b4a219e38 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -187,6 +187,36 @@ void Animation::setRenderProperties(const NifOgre::ObjectList &objlist, Ogre::ui } +void Animation::clearExtraSources() +{ + for(size_t layer = 0;layer < sMaxLayers;layer++) + { + mLayer[layer].mGroupName.clear(); + mLayer[layer].mTextKeys = NULL; + mLayer[layer].mControllers = NULL; + mLayer[layer].mTime = 0.0f; + mLayer[layer].mLoopCount = 0; + mLayer[layer].mPlaying = false; + } + mNonAccumCtrl = NULL; + mAnimVelocity = 0.0f; + + mLastPosition = Ogre::Vector3(0.0f); + if(mAccumRoot) + mAccumRoot->setPosition(mLastPosition); + + if(mObjects.size() > 1) + { + mObjects.resize(1); + mObjects[0].mActiveLayers = 0; + + NifOgre::ObjectList &objlist = mObjects[0].mObjectList; + mActiveCtrls.clear(); + mActiveCtrls.insert(mActiveCtrls.end(), objlist.mControllers.begin(), objlist.mControllers.end()); + } +} + + void Animation::updateActiveControllers() { mActiveCtrls.clear(); @@ -538,6 +568,7 @@ bool Animation::play(const std::string &groupname, const std::string &start, con mLayer[layeridx].mGroupName.clear(); mLayer[layeridx].mTextKeys = NULL; mLayer[layeridx].mControllers = NULL; + mLayer[layeridx].mTime = 0.0f; mLayer[layeridx].mLoopCount = 0; mLayer[layeridx].mPlaying = false; @@ -571,6 +602,7 @@ bool Animation::play(const std::string &groupname, const std::string &start, con { if(!reset(layeridx, keys, nonaccumctrl, groupname, start, stop, startpoint)) continue; + mLayer[layeridx].mGroupName = groupname; mLayer[layeridx].mTextKeys = &keys; mLayer[layeridx].mControllers = &objlist.mControllers; @@ -619,6 +651,7 @@ void Animation::disable(size_t layeridx) mLayer[layeridx].mGroupName.clear(); mLayer[layeridx].mTextKeys = NULL; mLayer[layeridx].mControllers = NULL; + mLayer[layeridx].mTime = 0.0f; mLayer[layeridx].mLoopCount = 0; mLayer[layeridx].mPlaying = false; diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 4d342e0b1..3b6cc4abf 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -116,6 +116,11 @@ public: Animation(const MWWorld::Ptr &ptr); virtual ~Animation(); + /** Clears all ObjectLists except the first one. As a consequence, any + * playing animations are stopped. + */ + void clearExtraSources(); + void updatePtr(const MWWorld::Ptr &ptr); bool hasAnimation(const std::string &anim);