forked from teamnwah/openmw-tes3coop
Remove some duplicate code
This commit is contained in:
parent
ceed2e30b8
commit
5051544144
2 changed files with 11 additions and 53 deletions
|
@ -94,57 +94,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
|
||||||
mPartPriorities[i] = 0;
|
mPartPriorities[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
updateNpcBase();
|
||||||
const ESM::Race *race = store.get<ESM::Race>().find(mNpc->mRace);
|
|
||||||
bool isWerewolf = MWWorld::Class::get(mPtr).getNpcStats(mPtr).isWerewolf();
|
|
||||||
|
|
||||||
if(!isWerewolf)
|
|
||||||
{
|
|
||||||
mHeadModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHead)->mModel;
|
|
||||||
mHairModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHair)->mModel;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mHeadModel = "meshes\\" + store.get<ESM::BodyPart>().find("WerewolfHead")->mModel;
|
|
||||||
mHairModel = "meshes\\" + store.get<ESM::BodyPart>().find("WerewolfHair")->mModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBodyPrefix = "b_n_" + mNpc->mRace;
|
|
||||||
Misc::StringUtils::toLower(mBodyPrefix);
|
|
||||||
|
|
||||||
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
|
|
||||||
std::string smodel = (viewMode != VM_FirstPerson) ?
|
|
||||||
(!isWerewolf ? (!isBeast ? "meshes\\base_anim.nif"
|
|
||||||
: "meshes\\base_animkna.nif")
|
|
||||||
: "meshes\\wolf\\skin.nif") :
|
|
||||||
(!isWerewolf ? (!isBeast ? "meshes\\base_anim.1st.nif"
|
|
||||||
: "meshes\\base_animkna.1st.nif")
|
|
||||||
: "meshes\\wolf\\skin.1st.nif");
|
|
||||||
setObjectRoot(smodel, true);
|
|
||||||
|
|
||||||
if(mViewMode != VM_FirstPerson)
|
|
||||||
{
|
|
||||||
addAnimSource(smodel);
|
|
||||||
if(mBodyPrefix.find("argonian") != std::string::npos)
|
|
||||||
addAnimSource("meshes\\argonian_swimkna.nif");
|
|
||||||
else if(!mNpc->isMale() && !isBeast)
|
|
||||||
addAnimSource("meshes\\base_anim_female.nif");
|
|
||||||
if(mNpc->mModel.length() > 0)
|
|
||||||
addAnimSource("meshes\\"+mNpc->mModel);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* A bit counter-intuitive, but unlike third-person anims, it seems
|
|
||||||
* beast races get both base_anim.1st.nif and base_animkna.1st.nif.
|
|
||||||
*/
|
|
||||||
addAnimSource("meshes\\base_anim.1st.nif");
|
|
||||||
if(isBeast)
|
|
||||||
addAnimSource("meshes\\base_animkna.1st.nif");
|
|
||||||
if(!mNpc->isMale() && !isBeast)
|
|
||||||
addAnimSource("meshes\\base_anim_female.1st.nif");
|
|
||||||
}
|
|
||||||
|
|
||||||
forceUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
||||||
|
@ -152,6 +102,13 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
||||||
assert(viewMode != VM_HeadOnly);
|
assert(viewMode != VM_HeadOnly);
|
||||||
mViewMode = viewMode;
|
mViewMode = viewMode;
|
||||||
|
|
||||||
|
updateNpcBase();
|
||||||
|
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->forceStateUpdate(mPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NpcAnimation::updateNpcBase()
|
||||||
|
{
|
||||||
clearAnimSources();
|
clearAnimSources();
|
||||||
|
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
@ -173,7 +130,7 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
||||||
Misc::StringUtils::toLower(mBodyPrefix);
|
Misc::StringUtils::toLower(mBodyPrefix);
|
||||||
|
|
||||||
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
|
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;
|
||||||
std::string smodel = (viewMode != VM_FirstPerson) ?
|
std::string smodel = (mViewMode != VM_FirstPerson) ?
|
||||||
(!isWerewolf ? !isBeast ? "meshes\\base_anim.nif"
|
(!isWerewolf ? !isBeast ? "meshes\\base_anim.nif"
|
||||||
: "meshes\\base_animkna.nif"
|
: "meshes\\base_animkna.nif"
|
||||||
: "meshes\\wolf\\skin.nif") :
|
: "meshes\\wolf\\skin.nif") :
|
||||||
|
@ -211,7 +168,6 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
||||||
addAnimSource("meshes\\base_anim_female.1st.nif");
|
addAnimSource("meshes\\base_anim_female.1st.nif");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MWBase::Environment::get().getMechanicsManager()->forceStateUpdate(mPtr);
|
|
||||||
|
|
||||||
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
||||||
removeIndividualPart((ESM::PartReferenceType)i);
|
removeIndividualPart((ESM::PartReferenceType)i);
|
||||||
|
|
|
@ -65,6 +65,8 @@ private:
|
||||||
int mPartslots[ESM::PRT_Count]; //Each part slot is taken by clothing, armor, or is empty
|
int mPartslots[ESM::PRT_Count]; //Each part slot is taken by clothing, armor, or is empty
|
||||||
int mPartPriorities[ESM::PRT_Count];
|
int mPartPriorities[ESM::PRT_Count];
|
||||||
|
|
||||||
|
void updateNpcBase();
|
||||||
|
|
||||||
NifOgre::ObjectList insertBoundedPart(const std::string &model, int group, const std::string &bonename);
|
NifOgre::ObjectList insertBoundedPart(const std::string &model, int group, const std::string &bonename);
|
||||||
|
|
||||||
void updateParts(bool forceupdate = false);
|
void updateParts(bool forceupdate = false);
|
||||||
|
|
Loading…
Reference in a new issue