mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Avoiding holding the InventoryStore in the NpcAnimation class
This commit is contained in:
parent
0d0e75fe0b
commit
a2eaec7878
@ -167,11 +167,7 @@ void Actors::updateObjectCell(const MWWorld::Ptr &ptr)
|
|||||||
PtrAnimationMap::iterator iter = mAllActors.find(ptr);
|
PtrAnimationMap::iterator iter = mAllActors.find(ptr);
|
||||||
if(iter != mAllActors.end())
|
if(iter != mAllActors.end())
|
||||||
{
|
{
|
||||||
/// \note Update key (Ptr's are compared only with refdata so mCell
|
Animation *anim = iter->second;
|
||||||
/// on key is outdated), maybe redundant
|
|
||||||
NpcAnimation *anim = static_cast<NpcAnimation *>(iter->second);
|
|
||||||
anim->updateParts(MWWorld::Class::get(ptr).getInventoryStore(ptr));
|
|
||||||
|
|
||||||
mAllActors.erase(iter);
|
mAllActors.erase(iter);
|
||||||
mAllActors[ptr] = anim;
|
mAllActors[ptr] = anim;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <OgreSubEntity.h>
|
#include <OgreSubEntity.h>
|
||||||
|
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.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)
|
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags)
|
||||||
: Animation(ptr),
|
: Animation(ptr),
|
||||||
mInv(&inv),
|
|
||||||
mStateID(-1),
|
mStateID(-1),
|
||||||
mTimeToChange(0),
|
mTimeToChange(0),
|
||||||
mVisibilityFlags(visibilityFlags),
|
mVisibilityFlags(visibilityFlags),
|
||||||
mRobe(mInv->end()),
|
mRobe(inv.end()),
|
||||||
mHelmet(mInv->end()),
|
mHelmet(inv.end()),
|
||||||
mShirt(mInv->end()),
|
mShirt(inv.end()),
|
||||||
mCuirass(mInv->end()),
|
mCuirass(inv.end()),
|
||||||
mGreaves(mInv->end()),
|
mGreaves(inv.end()),
|
||||||
mPauldronL(mInv->end()),
|
mPauldronL(inv.end()),
|
||||||
mPauldronR(mInv->end()),
|
mPauldronR(inv.end()),
|
||||||
mBoots(mInv->end()),
|
mBoots(inv.end()),
|
||||||
mPants(mInv->end()),
|
mPants(inv.end()),
|
||||||
mGloveL(mInv->end()),
|
mGloveL(inv.end()),
|
||||||
mGloveR(mInv->end()),
|
mGloveR(inv.end()),
|
||||||
mSkirtIter(mInv->end())
|
mSkirtIter(inv.end())
|
||||||
{
|
{
|
||||||
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
@ -213,9 +214,10 @@ void NpcAnimation::updateParts(bool forceupdate)
|
|||||||
};
|
};
|
||||||
static const size_t slotlistsize = sizeof(slotlist)/sizeof(slotlist[0]);
|
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++)
|
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)
|
if(this->*slotlist[i].part != iter)
|
||||||
{
|
{
|
||||||
forceupdate = true;
|
forceupdate = true;
|
||||||
@ -227,12 +229,12 @@ void NpcAnimation::updateParts(bool forceupdate)
|
|||||||
|
|
||||||
for(size_t i = 0;i < slotlistsize;i++)
|
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;
|
this->*slotlist[i].part = iter;
|
||||||
removePartGroup(slotlist[i].slot);
|
removePartGroup(slotlist[i].slot);
|
||||||
|
|
||||||
if(this->*slotlist[i].part == mInv->end())
|
if(this->*slotlist[i].part == inv.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for(int rem = 0;rem < slotlist[i].numRemoveParts;rem++)
|
for(int rem = 0;rem < slotlist[i].numRemoveParts;rem++)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
|
|
||||||
#include "../mwworld/inventorystore.hpp"
|
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
@ -11,6 +10,11 @@ namespace ESM
|
|||||||
struct NPC;
|
struct NPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class InventoryStore;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -26,7 +30,6 @@ private:
|
|||||||
static const size_t sPartListSize = 27;
|
static const size_t sPartListSize = 27;
|
||||||
static const PartInfo sPartList[sPartListSize];
|
static const PartInfo sPartList[sPartListSize];
|
||||||
|
|
||||||
MWWorld::InventoryStore *mInv;
|
|
||||||
int mStateID;
|
int mStateID;
|
||||||
|
|
||||||
// Bounded Parts
|
// Bounded Parts
|
||||||
@ -75,11 +78,6 @@ public:
|
|||||||
|
|
||||||
virtual Ogre::Vector3 runAnimation(float timepassed);
|
virtual Ogre::Vector3 runAnimation(float timepassed);
|
||||||
|
|
||||||
void updateParts(MWWorld::InventoryStore &inventory)
|
|
||||||
{
|
|
||||||
mInv = &inventory;
|
|
||||||
updateParts(true);
|
|
||||||
}
|
|
||||||
void forceUpdate()
|
void forceUpdate()
|
||||||
{ updateParts(true); }
|
{ updateParts(true); }
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user