From 94f3e7a6c069cc9d4de5959a343bc06d0d66b320 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 17 Jul 2012 16:00:03 -0700 Subject: [PATCH] Store the entity list in the object --- apps/openmw/mwrender/animation.hpp | 3 ++- apps/openmw/mwrender/creatureanimation.cpp | 14 +++++++------- apps/openmw/mwrender/npcanimation.cpp | 15 ++++++--------- apps/openmw/mwrender/npcanimation.hpp | 1 - 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index ea18865da..def7f226c 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -3,6 +3,7 @@ #include +#include #include #include "../mwworld/actiontalk.hpp" #include @@ -39,7 +40,7 @@ protected: std::vector* mTransformations; std::map* mTextmappings; - std::vector mBase; + NifOgre::EntityList mEntityList; void handleAnimationTransforms(); bool timeIndex( float time, const std::vector & times, int & i, int & j, float & x ); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index 92930e8d4..fd2855154 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -26,16 +26,16 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O { std::string mesh = "meshes\\" + ref->base->model; - NifOgre::EntityList entities = NifOgre::NIFLoader::createEntities(mInsert, mesh); - mBase = entities.mEntities; - for(size_t i = 0;i < mBase.size();i++) + mEntityList = NifOgre::NIFLoader::createEntities(mInsert, mesh); + for(size_t i = 0;i < mEntityList.mEntities.size();i++) { - mBase[i]->setVisibilityFlags(RV_Actors); + Ogre::Entity *ent = mEntityList.mEntities[i]; + ent->setVisibilityFlags(RV_Actors); bool transparent = false; - for (unsigned int j=0;j < mBase[i]->getNumSubEntities() && !transparent; ++j) + for (unsigned int j=0;j < ent->getNumSubEntities() && !transparent; ++j) { - Ogre::MaterialPtr mat = mBase[i]->getSubEntity(j)->getMaterial(); + Ogre::MaterialPtr mat = ent->getSubEntity(j)->getMaterial(); Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator(); while (techIt.hasMoreElements() && !transparent) { @@ -50,7 +50,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O } } } - mBase[i]->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); + ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); } } } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 86a58c849..cdef5ce8b 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -27,8 +27,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRendere leftpauldron(mInv.end()), rightpauldron(mInv.end()), boots(mInv.end()), leftglove(mInv.end()), rightglove(mInv.end()), skirtiter(mInv.end()), - pants(mInv.end()), - mSkelBase(0) + pants(mInv.end()) { MWWorld::LiveCellRef *ref = ptr.get(); @@ -65,12 +64,10 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRendere std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif"); - NifOgre::EntityList entities = NifOgre::NIFLoader::createEntities(mInsert, smodel); - mBase = entities.mEntities; - mSkelBase = entities.mSkelBase; - for(size_t i = 0;i < mBase.size();i++) + mEntityList = NifOgre::NIFLoader::createEntities(mInsert, smodel); + for(size_t i = 0;i < mEntityList.mEntities.size();i++) { - Ogre::Entity *base = mBase[i]; + Ogre::Entity *base = mEntityList.mEntities[i]; base->setVisibilityFlags(RV_Actors); bool transparent = false; @@ -376,7 +373,7 @@ std::vector NpcAnimation::insertBoundedPart(const std::string &me Ogre::Entity *part = parts.back(); part->setVisibilityFlags(RV_Actors); - mSkelBase->attachObjectToBone(bonename, part); + mEntityList.mSkelBase->attachObjectToBone(bonename, part); } return parts; } @@ -415,7 +412,7 @@ void NpcAnimation::runAnimation(float timepassed) void NpcAnimation::removeEntities(std::vector &entities) { for(size_t i = 0;i < entities.size();i++) - mSkelBase->detachObjectFromBone(entities[i]); + mEntityList.mSkelBase->detachObjectFromBone(entities[i]); entities.clear(); } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 7830b68cc..f27642720 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -41,7 +41,6 @@ private: std::vector head; Ogre::SceneNode* mInsert; - Ogre::Entity *mSkelBase; // Entity with the base skeleton (temporary) bool isBeast; bool isFemale; std::string headModel;