1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00

Store an MWWorld::Ptr with the Animation

This commit is contained in:
Chris Robinson 2013-01-06 17:05:48 -08:00
parent 2b1fe7dc44
commit b96a979719
4 changed files with 13 additions and 8 deletions

View File

@ -10,8 +10,9 @@
namespace MWRender namespace MWRender
{ {
Animation::Animation() Animation::Animation(const MWWorld::Ptr &ptr)
: mInsert(NULL) : mPtr(ptr)
, mInsert(NULL)
, mTime(0.0f) , mTime(0.0f)
, mSkipFrame(false) , mSkipFrame(false)
, mAnimState(NULL) , mAnimState(NULL)

View File

@ -3,6 +3,8 @@
#include <components/nifogre/ogre_nif_loader.hpp> #include <components/nifogre/ogre_nif_loader.hpp>
#include "../mwworld/ptr.hpp"
namespace MWRender namespace MWRender
{ {
@ -23,6 +25,7 @@ class Animation
}; };
protected: protected:
MWWorld::Ptr mPtr;
Ogre::SceneNode* mInsert; Ogre::SceneNode* mInsert;
float mTime; float mTime;
@ -40,7 +43,7 @@ protected:
void createEntityList(Ogre::SceneNode *node, const std::string &model); void createEntityList(Ogre::SceneNode *node, const std::string &model);
public: public:
Animation(); Animation(const MWWorld::Ptr &ptr);
virtual ~Animation(); virtual ~Animation();
void playGroup(std::string groupname, int mode, int loops); void playGroup(std::string groupname, int mode, int loops);

View File

@ -16,16 +16,17 @@ CreatureAnimation::~CreatureAnimation()
{ {
} }
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation() CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr)
: Animation(ptr)
{ {
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature> *ref = mPtr.get<ESM::Creature>();
assert (ref->mBase != NULL); assert (ref->mBase != NULL);
if(!ref->mBase->mModel.empty()) if(!ref->mBase->mModel.empty())
{ {
std::string mesh = "meshes\\" + ref->mBase->mModel; 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++) for(size_t i = 0;i < mEntityList.mEntities.size();i++)
{ {
Ogre::Entity *ent = mEntityList.mEntities[i]; Ogre::Entity *ent = mEntityList.mEntities[i];

View File

@ -55,7 +55,7 @@ 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(), : Animation(ptr),
mInv(inv), mInv(inv),
mStateID(-1), mStateID(-1),
mTimeToChange(0), mTimeToChange(0),
@ -73,7 +73,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
mGloveR(mInv.end()), mGloveR(mInv.end()),
mSkirtIter(mInv.end()) mSkirtIter(mInv.end())
{ {
mNpc = ptr.get<ESM::NPC>()->mBase; mNpc = mPtr.get<ESM::NPC>()->mBase;
for(size_t i = 0;i < sPartListSize;i++) for(size_t i = 0;i < sPartListSize;i++)
{ {