From b96a9797199d4fa076d6516d59e9a892d744e8c2 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 6 Jan 2013 17:05:48 -0800 Subject: [PATCH] Store an MWWorld::Ptr with the Animation --- apps/openmw/mwrender/animation.cpp | 5 +++-- apps/openmw/mwrender/animation.hpp | 5 ++++- apps/openmw/mwrender/creatureanimation.cpp | 7 ++++--- apps/openmw/mwrender/npcanimation.cpp | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index d2d253b919..d7f3d52d62 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -10,8 +10,9 @@ namespace MWRender { -Animation::Animation() - : mInsert(NULL) +Animation::Animation(const MWWorld::Ptr &ptr) + : mPtr(ptr) + , mInsert(NULL) , mTime(0.0f) , mSkipFrame(false) , mAnimState(NULL) diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 633a3f9e7a..593538ea68 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -3,6 +3,8 @@ #include +#include "../mwworld/ptr.hpp" + namespace MWRender { @@ -23,6 +25,7 @@ class Animation }; protected: + MWWorld::Ptr mPtr; Ogre::SceneNode* mInsert; float mTime; @@ -40,7 +43,7 @@ protected: void createEntityList(Ogre::SceneNode *node, const std::string &model); public: - Animation(); + Animation(const MWWorld::Ptr &ptr); virtual ~Animation(); void playGroup(std::string groupname, int mode, int loops); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index 1ca897c15e..caa040d952 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -16,16 +16,17 @@ CreatureAnimation::~CreatureAnimation() { } -CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation() +CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr) + : Animation(ptr) { - MWWorld::LiveCellRef *ref = ptr.get(); + MWWorld::LiveCellRef *ref = mPtr.get(); assert (ref->mBase != NULL); if(!ref->mBase->mModel.empty()) { std::string mesh = "meshes\\" + ref->mBase->mModel; - createEntityList(ptr.getRefData().getBaseNode(), mesh); + createEntityList(mPtr.getRefData().getBaseNode(), mesh); for(size_t i = 0;i < mEntityList.mEntities.size();i++) { Ogre::Entity *ent = mEntityList.mEntities[i]; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index b7e93cef2b..5682a86cc9 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -55,7 +55,7 @@ NpcAnimation::~NpcAnimation() NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags) - : Animation(), + : Animation(ptr), mInv(inv), mStateID(-1), mTimeToChange(0), @@ -73,7 +73,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor mGloveR(mInv.end()), mSkirtIter(mInv.end()) { - mNpc = ptr.get()->mBase; + mNpc = mPtr.get()->mBase; for(size_t i = 0;i < sPartListSize;i++) {