forked from teamnwah/openmw-tes3coop
Force character state to update after switching view modes
This commit is contained in:
parent
e4eb4b7e30
commit
274f3c7b77
8 changed files with 48 additions and 4 deletions
|
@ -99,6 +99,9 @@ namespace MWBase
|
|||
float currentTemporaryDispositionDelta, bool& success, float& tempChange, float& permChange) = 0;
|
||||
///< Perform a persuasion action on NPC
|
||||
|
||||
virtual void forceStateUpdate(const MWWorld::Ptr &ptr) = 0;
|
||||
///< Forces an object to refresh its animation state.
|
||||
|
||||
virtual void playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number=1) = 0;
|
||||
///< Run animation for a MW-reference. Calls to this function for references that are currently not
|
||||
/// in the scene should be ignored.
|
||||
|
|
|
@ -290,6 +290,13 @@ namespace MWMechanics
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Actors::forceStateUpdate(const MWWorld::Ptr & ptr)
|
||||
{
|
||||
PtrControllerMap::iterator iter = mActors.find(ptr);
|
||||
if(iter != mActors.end())
|
||||
iter->second.forceStateUpdate();
|
||||
}
|
||||
|
||||
void Actors::playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number)
|
||||
{
|
||||
PtrControllerMap::iterator iter = mActors.find(ptr);
|
||||
|
|
|
@ -78,6 +78,8 @@ namespace MWMechanics
|
|||
int countDeaths (const std::string& id) const;
|
||||
///< Return the number of deaths for actors with the given ID.
|
||||
|
||||
void forceStateUpdate(const MWWorld::Ptr &ptr);
|
||||
|
||||
void playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number);
|
||||
void skipAnimation(const MWWorld::Ptr& ptr);
|
||||
};
|
||||
|
|
|
@ -274,6 +274,11 @@ void CharacterController::setState(CharacterState state, bool loop)
|
|||
mCharState = state;
|
||||
mLooping = loop;
|
||||
|
||||
forceStateUpdate();
|
||||
}
|
||||
|
||||
void CharacterController::forceStateUpdate()
|
||||
{
|
||||
if(!mAnimation)
|
||||
return;
|
||||
mAnimQueue.clear();
|
||||
|
|
|
@ -95,6 +95,8 @@ public:
|
|||
void setState(CharacterState state, bool loop);
|
||||
CharacterState getState() const
|
||||
{ return mCharState; }
|
||||
|
||||
void forceStateUpdate();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -654,6 +654,12 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
void MechanicsManager::forceStateUpdate(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
if(MWWorld::Class::get(ptr).isActor())
|
||||
mActors.forceStateUpdate(ptr);
|
||||
}
|
||||
|
||||
void MechanicsManager::playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number)
|
||||
{
|
||||
if(MWWorld::Class::get(ptr).isActor())
|
||||
|
|
|
@ -96,6 +96,8 @@ namespace MWMechanics
|
|||
void toLower(std::string npcFaction);
|
||||
///< Perform a persuasion action on NPC
|
||||
|
||||
virtual void forceStateUpdate(const MWWorld::Ptr &ptr);
|
||||
|
||||
virtual void playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number);
|
||||
virtual void skipAnimation(const MWWorld::Ptr& ptr);
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/mechanicsmanager.hpp"
|
||||
|
||||
#include "renderconst.hpp"
|
||||
|
||||
|
@ -97,10 +98,25 @@ 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(viewMode != VM_HeadOnly)
|
||||
setViewMode(viewMode);
|
||||
else
|
||||
forceUpdate();
|
||||
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);
|
||||
if(mViewMode == VM_FirstPerson)
|
||||
{
|
||||
/* 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);
|
||||
}
|
||||
|
||||
forceUpdate();
|
||||
}
|
||||
|
||||
void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
||||
|
@ -132,6 +148,7 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
|||
if(!mNpc->isMale() && !isBeast)
|
||||
addObjectList(node, "meshes\\base_anim_female.1st.nif", true);
|
||||
}
|
||||
MWBase::Environment::get().getMechanicsManager()->forceStateUpdate(mPtr);
|
||||
|
||||
for(size_t i = 0;i < sPartListSize;i++)
|
||||
removeIndividualPart(i);
|
||||
|
|
Loading…
Reference in a new issue