mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 09:53:50 +00:00
Handle controllers in the NPC's bound object parts
This commit is contained in:
parent
11b094559f
commit
45302f9e25
3 changed files with 28 additions and 0 deletions
|
@ -53,6 +53,7 @@ Animation::Animation(const MWWorld::Ptr &ptr)
|
||||||
, mNonAccumRoot(NULL)
|
, mNonAccumRoot(NULL)
|
||||||
, mNonAccumCtrl(NULL)
|
, mNonAccumCtrl(NULL)
|
||||||
, mAccumulate(0.0f)
|
, mAccumulate(0.0f)
|
||||||
|
, mNullAnimationValuePtr(OGRE_NEW NullAnimationValue)
|
||||||
{
|
{
|
||||||
for(size_t i = 0;i < sNumGroups;i++)
|
for(size_t i = 0;i < sNumGroups;i++)
|
||||||
mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this));
|
mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this));
|
||||||
|
|
|
@ -52,6 +52,15 @@ protected:
|
||||||
virtual void setValue(Ogre::Real value);
|
virtual void setValue(Ogre::Real value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NullAnimationValue : public Ogre::ControllerValue<Ogre::Real>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual Ogre::Real getValue() const
|
||||||
|
{ return 0.0f; }
|
||||||
|
virtual void setValue(Ogre::Real value)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
struct AnimSource : public Ogre::AnimationAlloc {
|
struct AnimSource : public Ogre::AnimationAlloc {
|
||||||
NifOgre::TextKeyMap mTextKeys;
|
NifOgre::TextKeyMap mTextKeys;
|
||||||
std::vector<Ogre::Controller<Ogre::Real> > mControllers[sNumGroups];
|
std::vector<Ogre::Controller<Ogre::Real> > mControllers[sNumGroups];
|
||||||
|
@ -98,6 +107,7 @@ protected:
|
||||||
AnimStateMap mStates;
|
AnimStateMap mStates;
|
||||||
|
|
||||||
Ogre::SharedPtr<AnimationValue> mAnimationValuePtr[sNumGroups];
|
Ogre::SharedPtr<AnimationValue> mAnimationValuePtr[sNumGroups];
|
||||||
|
Ogre::SharedPtr<NullAnimationValue> mNullAnimationValuePtr;
|
||||||
|
|
||||||
ObjectAttachMap mAttachedObjects;
|
ObjectAttachMap mAttachedObjects;
|
||||||
|
|
||||||
|
|
|
@ -424,6 +424,10 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
||||||
|
|
||||||
for(size_t i = 0;i < sPartListSize;i++)
|
for(size_t i = 0;i < sPartListSize;i++)
|
||||||
{
|
{
|
||||||
|
std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(mObjectParts[i].mControllers.begin());
|
||||||
|
for(;ctrl != mObjectParts[i].mControllers.end();ctrl++)
|
||||||
|
ctrl->update();
|
||||||
|
|
||||||
Ogre::Entity *ent = mObjectParts[i].mSkelBase;
|
Ogre::Entity *ent = mObjectParts[i].mSkelBase;
|
||||||
if(!ent) continue;
|
if(!ent) continue;
|
||||||
updateSkeletonInstance(baseinst, ent->getSkeleton());
|
updateSkeletonInstance(baseinst, ent->getSkeleton());
|
||||||
|
@ -481,6 +485,19 @@ bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority,
|
||||||
if(type == sPartList[i].type)
|
if(type == sPartList[i].type)
|
||||||
{
|
{
|
||||||
mObjectParts[i] = insertBoundedPart(mesh, group, sPartList[i].name);
|
mObjectParts[i] = insertBoundedPart(mesh, group, sPartList[i].name);
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// type == ESM::PRT_Head should get an animation source based on the current output of
|
||||||
|
// the actor's 'say' sound (0 = silent, 1 = loud?).
|
||||||
|
// type == ESM::PRT_Weapon should get an animation source based on the current offset
|
||||||
|
// of the weapon attack animation (from its beginning, or start marker?)
|
||||||
|
std::vector<Ogre::Controller<Ogre::Real> >::iterator ctrl(mObjectParts[i].mControllers.begin());
|
||||||
|
for(;ctrl != mObjectParts[i].mControllers.end();ctrl++)
|
||||||
|
{
|
||||||
|
if(ctrl->getSource().isNull())
|
||||||
|
ctrl->setSource(mNullAnimationValuePtr);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue