1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 13:23:55 +00:00

Store the entity lists for NPC parts

This commit is contained in:
Chris Robinson 2012-07-18 10:26:25 -07:00
parent 6611b0b317
commit 04e496a6ca
2 changed files with 33 additions and 29 deletions

View file

@ -339,13 +339,13 @@ void NpcAnimation::updateParts()
} }
} }
std::vector<Ogre::Entity*> NpcAnimation::insertBoundedPart(const std::string &mesh, const std::string &bonename) NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, const std::string &bonename)
{ {
NifOgre::EntityList entities = NIFLoader::createEntities(mInsert, mesh); NifOgre::EntityList entities = NIFLoader::createEntities(mInsert, mesh);
std::vector<Ogre::Entity*> &parts = entities.mEntities; std::vector<Ogre::Entity*> &parts = entities.mEntities;
for(size_t i = 0;i < parts.size();i++) for(size_t i = 0;i < parts.size();i++)
parts[i]->setVisibilityFlags(RV_Actors); parts[i]->setVisibilityFlags(RV_Actors);
return parts; return entities;
} }
void NpcAnimation::runAnimation(float timepassed) void NpcAnimation::runAnimation(float timepassed)
@ -379,15 +379,19 @@ void NpcAnimation::runAnimation(float timepassed)
} }
} }
void NpcAnimation::removeEntities(std::vector<Ogre::Entity*> &entities) void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
{ {
assert(&entities != &mEntityList);
Ogre::SceneManager *sceneMgr = mInsert->getCreator(); Ogre::SceneManager *sceneMgr = mInsert->getCreator();
for(size_t i = 0;i < entities.size();i++) for(size_t i = 0;i < entities.mEntities.size();i++)
{ {
mEntityList.mSkelBase->detachObjectFromBone(entities[i]); mEntityList.mSkelBase->detachObjectFromBone(entities.mEntities[i]);
sceneMgr->destroyEntity(entities[i]); sceneMgr->destroyEntity(entities.mEntities[i]);
} }
entities.clear(); entities.mEntities.clear();
entities.mSkelBase = NULL;
entities.mRootNode = NULL;
} }
void NpcAnimation::removeIndividualPart(int type) void NpcAnimation::removeIndividualPart(int type)

View file

@ -19,26 +19,26 @@ private:
int mPartPriorities[27]; int mPartPriorities[27];
//Bounded Parts //Bounded Parts
std::vector<Ogre::Entity*> lclavicle; NifOgre::EntityList lclavicle;
std::vector<Ogre::Entity*> rclavicle; NifOgre::EntityList rclavicle;
std::vector<Ogre::Entity*> rupperArm; NifOgre::EntityList rupperArm;
std::vector<Ogre::Entity*> lupperArm; NifOgre::EntityList lupperArm;
std::vector<Ogre::Entity*> rUpperLeg; NifOgre::EntityList rUpperLeg;
std::vector<Ogre::Entity*> lUpperLeg; NifOgre::EntityList lUpperLeg;
std::vector<Ogre::Entity*> lForearm; NifOgre::EntityList lForearm;
std::vector<Ogre::Entity*> rForearm; NifOgre::EntityList rForearm;
std::vector<Ogre::Entity*> lWrist; NifOgre::EntityList lWrist;
std::vector<Ogre::Entity*> rWrist; NifOgre::EntityList rWrist;
std::vector<Ogre::Entity*> rKnee; NifOgre::EntityList rKnee;
std::vector<Ogre::Entity*> lKnee; NifOgre::EntityList lKnee;
std::vector<Ogre::Entity*> neck; NifOgre::EntityList neck;
std::vector<Ogre::Entity*> rAnkle; NifOgre::EntityList rAnkle;
std::vector<Ogre::Entity*> lAnkle; NifOgre::EntityList lAnkle;
std::vector<Ogre::Entity*> groin; NifOgre::EntityList groin;
std::vector<Ogre::Entity*> lfoot; NifOgre::EntityList lfoot;
std::vector<Ogre::Entity*> rfoot; NifOgre::EntityList rfoot;
std::vector<Ogre::Entity*> hair; NifOgre::EntityList hair;
std::vector<Ogre::Entity*> head; NifOgre::EntityList head;
bool isBeast; bool isBeast;
bool isFemale; bool isFemale;
@ -63,10 +63,10 @@ private:
public: public:
NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv);
virtual ~NpcAnimation(); virtual ~NpcAnimation();
std::vector<Ogre::Entity*> insertBoundedPart(const std::string &mesh, const std::string &bonename); NifOgre::EntityList insertBoundedPart(const std::string &mesh, const std::string &bonename);
virtual void runAnimation(float timepassed); virtual void runAnimation(float timepassed);
void updateParts(); void updateParts();
void removeEntities(std::vector<Ogre::Entity*> &entities); void removeEntities(NifOgre::EntityList &entities);
void removeIndividualPart(int type); void removeIndividualPart(int type);
void reserveIndividualPart(int type, int group, int priority); void reserveIndividualPart(int type, int group, int priority);