From a9dca21d052ba857b7b76b5b0877fc15801f8e38 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 6 Aug 2013 01:41:47 -0700 Subject: [PATCH] Create the Animation SceneNode in the constructor --- apps/openmw/mwrender/activatoranimation.cpp | 6 +++--- apps/openmw/mwrender/animation.cpp | 8 ++++---- apps/openmw/mwrender/animation.hpp | 4 ++-- apps/openmw/mwrender/creatureanimation.cpp | 4 ++-- apps/openmw/mwrender/npcanimation.cpp | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwrender/activatoranimation.cpp b/apps/openmw/mwrender/activatoranimation.cpp index f3d0ec3ff..7f4be9a68 100644 --- a/apps/openmw/mwrender/activatoranimation.cpp +++ b/apps/openmw/mwrender/activatoranimation.cpp @@ -12,16 +12,16 @@ ActivatorAnimation::~ActivatorAnimation() } ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr) - : Animation(ptr) + : Animation(ptr, ptr.getRefData().getBaseNode()) { MWWorld::LiveCellRef *ref = mPtr.get(); - assert (ref->mBase != NULL); + assert(ref->mBase != NULL); if(!ref->mBase->mModel.empty()) { const std::string name = "meshes\\"+ref->mBase->mModel; - setObjectRoot(mPtr.getRefData().getBaseNode(), name, false); + setObjectRoot(name, false); setRenderProperties(mObjectRoot, RV_Misc, RQG_Main, RQG_Alpha); addAnimSource(name); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 737d4da64..a91679dc6 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -58,7 +58,7 @@ void Animation::destroyObjectList(Ogre::SceneManager *sceneMgr, NifOgre::ObjectL objects.mSkelBase = NULL; } -Animation::Animation(const MWWorld::Ptr &ptr) +Animation::Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node) : mPtr(ptr) , mCamera(NULL) , mInsert(NULL) @@ -71,6 +71,8 @@ Animation::Animation(const MWWorld::Ptr &ptr) { for(size_t i = 0;i < sNumGroups;i++) mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this)); + mInsert = node ? node->createChildSceneNode() : + mPtr.getRefData().getBaseNode()->createChildSceneNode(); } Animation::~Animation() @@ -85,11 +87,9 @@ Animation::~Animation() } -void Animation::setObjectRoot(Ogre::SceneNode *node, const std::string &model, bool baseonly) +void Animation::setObjectRoot(const std::string &model, bool baseonly) { OgreAssert(mAnimSources.empty(), "Setting object root while animation sources are set!"); - if(!mInsert) - mInsert = node->createChildSceneNode(); std::string mdlname = Misc::StringUtils::lowerCase(model); std::string::size_type p = mdlname.rfind('\\'); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index ceda463ff..42f57d5f1 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -153,7 +153,7 @@ protected: * Note that you must make sure all animation sources are cleared before reseting the object * root. All nodes previously retrieved with getNode will also become invalidated. */ - void setObjectRoot(Ogre::SceneNode *node, const std::string &model, bool baseonly); + void setObjectRoot(const std::string &model, bool baseonly); /* Adds the keyframe controllers in the specified model as a new animation source. Note that * the filename portion of the provided model name will be prepended with 'x', and the .nif @@ -170,7 +170,7 @@ protected: void clearAnimSources(); public: - Animation(const MWWorld::Ptr &ptr); + Animation(const MWWorld::Ptr &ptr, Ogre::SceneNode *node); virtual ~Animation(); void updatePtr(const MWWorld::Ptr &ptr); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index 7817c23c9..c3ad512dd 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -12,7 +12,7 @@ CreatureAnimation::~CreatureAnimation() } CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr) - : Animation(ptr) + : Animation(ptr, ptr.getRefData().getBaseNode()) { MWWorld::LiveCellRef *ref = mPtr.get(); @@ -21,7 +21,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr) { std::string model = "meshes\\"+ref->mBase->mModel; - setObjectRoot(mPtr.getRefData().getBaseNode(), model, false); + setObjectRoot(model, false); setRenderProperties(mObjectRoot, RV_Actors, RQG_Main, RQG_Alpha); if((ref->mBase->mFlags&ESM::Creature::Biped)) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 971cf58fe..24f77a512 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -63,7 +63,7 @@ NpcAnimation::~NpcAnimation() NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags, ViewMode viewMode) - : Animation(ptr), + : Animation(ptr, node), mStateID(-1), mTimeToChange(0), mVisibilityFlags(visibilityFlags), @@ -106,7 +106,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor std::string smodel = (viewMode != VM_FirstPerson) ? (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif") : (!isBeast ? "meshes\\base_anim.1st.nif" : "meshes\\base_animkna.1st.nif") ; - setObjectRoot(node, smodel, true); + setObjectRoot(smodel, true); if(mViewMode != VM_FirstPerson) { @@ -147,7 +147,7 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode) std::string smodel = (viewMode != VM_FirstPerson) ? (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif") : (!isBeast ? "meshes\\base_anim.1st.nif" : "meshes\\base_animkna.1st.nif") ; - setObjectRoot(mInsert->getParentSceneNode(), smodel, true); + setObjectRoot(smodel, true); if(mViewMode != VM_FirstPerson) {