From 2769adcee09fd51ede8063c4705436b485c1a167 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 25 Apr 2013 05:23:05 -0700 Subject: [PATCH] Implement switching to and from first-person animations Note that the current animation gets interrupted, so switching to first person may break movement until you stop and try to move again. This can be fixed by alerting the character controller in the mechanics manager to force a state update when switching POV. --- apps/openmw/mwrender/npcanimation.cpp | 42 +++++++++++++-------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index c0f2e7e293..563bca4c7c 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -97,14 +97,10 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif"); addObjectList(node, smodel, true); - if(mBodyPrefix.find("argonian") != std::string::npos) - addObjectList(node, "meshes\\argonian_swimkna.nif", true); - else if(!mNpc->isMale() && !isBeast) - addObjectList(node, "meshes\\base_anim_female.nif", true); - if(mNpc->mModel.length() > 0) - addObjectList(node, "meshes\\"+mNpc->mModel, true); - - forceUpdate(); + if(viewMode != VM_HeadOnly) + setViewMode(viewMode); + else + forceUpdate(); } void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode) @@ -112,28 +108,30 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode) assert(viewMode != VM_HeadOnly); mViewMode = viewMode; - /* FIXME: Enable this once first-person animations work. */ -#if 0 + Ogre::SceneNode *node = mInsert->getParentSceneNode(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Race *race = store.get().find(mNpc->mRace); - bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0; - std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif"); - std::vector skelnames(1, smodel); - if(!mNpc->isMale() && !isBeast) - skelnames.push_back("meshes\\base_anim_female.nif"); - else if(mBodyPrefix.find("argonian") != std::string::npos) - skelnames.push_back("meshes\\argonian_swimkna.nif"); + clearExtraSources(); + if(mBodyPrefix.find("argonian") != std::string::npos) + addObjectList(node, "meshes\\argonian_swimkna.nif", true); + else if(!mNpc->isMale() && !isBeast) + addObjectList(node, "meshes\\base_anim_female.nif", true); if(mNpc->mModel.length() > 0) - skelnames.push_back("meshes\\"+Misc::StringUtils::lowerCase(mNpc->mModel)); + addObjectList(node, "meshes\\"+mNpc->mModel, true); if(mViewMode == VM_FirstPerson) { - smodel = (!isBeast ? "meshes\\base_anim.1st.nif" : "meshes\\base_animkna.1st.nif"); - skelnames.push_back(smodel); + /* A bit counter-intuitive, but unlike third-person anims, it seems + * beast races get both base_anim.1st.nif and base_animkna.1st.nif. + */ + addObjectList(node, "meshes\\base_anim.1st.nif", true); + if(isBeast) + addObjectList(node, "meshes\\base_animkna.1st.nif", true); + if(!mNpc->isMale() && !isBeast) + addObjectList(node, "meshes\\base_anim_female.1st.nif", true); } - setAnimationSources(skelnames); -#endif for(size_t i = 0;i < sPartListSize;i++) removeIndividualPart(i);