diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 3f3145900..d356d922e 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -167,11 +167,7 @@ void Actors::updateObjectCell(const MWWorld::Ptr &ptr) PtrAnimationMap::iterator iter = mAllActors.find(ptr); if(iter != mAllActors.end()) { - /// \note Update key (Ptr's are compared only with refdata so mCell - /// on key is outdated), maybe redundant - NpcAnimation *anim = static_cast(iter->second); - anim->updateParts(MWWorld::Class::get(ptr).getInventoryStore(ptr)); - + Animation *anim = iter->second; mAllActors.erase(iter); mAllActors[ptr] = anim; } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index dcaee55f9..809e3f6d2 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -5,6 +5,8 @@ #include #include "../mwworld/esmstore.hpp" +#include "../mwworld/inventorystore.hpp" +#include "../mwworld/class.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -54,22 +56,21 @@ NpcAnimation::~NpcAnimation() NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags) : Animation(ptr), - mInv(&inv), mStateID(-1), mTimeToChange(0), mVisibilityFlags(visibilityFlags), - mRobe(mInv->end()), - mHelmet(mInv->end()), - mShirt(mInv->end()), - mCuirass(mInv->end()), - mGreaves(mInv->end()), - mPauldronL(mInv->end()), - mPauldronR(mInv->end()), - mBoots(mInv->end()), - mPants(mInv->end()), - mGloveL(mInv->end()), - mGloveR(mInv->end()), - mSkirtIter(mInv->end()) + mRobe(inv.end()), + mHelmet(inv.end()), + mShirt(inv.end()), + mCuirass(inv.end()), + mGreaves(inv.end()), + mPauldronL(inv.end()), + mPauldronR(inv.end()), + mBoots(inv.end()), + mPants(inv.end()), + mGloveL(inv.end()), + mGloveR(inv.end()), + mSkirtIter(inv.end()) { mNpc = mPtr.get()->mBase; @@ -213,9 +214,10 @@ void NpcAnimation::updateParts(bool forceupdate) }; static const size_t slotlistsize = sizeof(slotlist)/sizeof(slotlist[0]); + MWWorld::InventoryStore &inv = MWWorld::Class::get(mPtr).getInventoryStore(mPtr); for(size_t i = 0;!forceupdate && i < slotlistsize;i++) { - MWWorld::ContainerStoreIterator iter = mInv->getSlot(slotlist[i].slot); + MWWorld::ContainerStoreIterator iter = inv.getSlot(slotlist[i].slot); if(this->*slotlist[i].part != iter) { forceupdate = true; @@ -227,12 +229,12 @@ void NpcAnimation::updateParts(bool forceupdate) for(size_t i = 0;i < slotlistsize;i++) { - MWWorld::ContainerStoreIterator iter = mInv->getSlot(slotlist[i].slot); + MWWorld::ContainerStoreIterator iter = inv.getSlot(slotlist[i].slot); this->*slotlist[i].part = iter; removePartGroup(slotlist[i].slot); - if(this->*slotlist[i].part == mInv->end()) + if(this->*slotlist[i].part == inv.end()) continue; for(int rem = 0;rem < slotlist[i].numRemoveParts;rem++) diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index c5d5b7461..aed4868bd 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -3,7 +3,6 @@ #include "animation.hpp" -#include "../mwworld/inventorystore.hpp" #include "../mwworld/containerstore.hpp" namespace ESM @@ -11,6 +10,11 @@ namespace ESM struct NPC; } +namespace MWWorld +{ + class InventoryStore; +} + namespace MWRender { @@ -26,7 +30,6 @@ private: static const size_t sPartListSize = 27; static const PartInfo sPartList[sPartListSize]; - MWWorld::InventoryStore *mInv; int mStateID; // Bounded Parts @@ -75,11 +78,6 @@ public: virtual Ogre::Vector3 runAnimation(float timepassed); - void updateParts(MWWorld::InventoryStore &inventory) - { - mInv = &inventory; - updateParts(true); - } void forceUpdate() { updateParts(true); } };