From 45302f9e25444f5a689afd915c991edf0aac9ef4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 23 Jul 2013 22:05:03 -0700 Subject: [PATCH] Handle controllers in the NPC's bound object parts --- apps/openmw/mwrender/animation.cpp | 1 + apps/openmw/mwrender/animation.hpp | 10 ++++++++++ apps/openmw/mwrender/npcanimation.cpp | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 997a59dd0..db20807e3 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -53,6 +53,7 @@ Animation::Animation(const MWWorld::Ptr &ptr) , mNonAccumRoot(NULL) , mNonAccumCtrl(NULL) , mAccumulate(0.0f) + , mNullAnimationValuePtr(OGRE_NEW NullAnimationValue) { for(size_t i = 0;i < sNumGroups;i++) mAnimationValuePtr[i].bind(OGRE_NEW AnimationValue(this)); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index bc7fd3d22..cbedfe505 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -52,6 +52,15 @@ protected: virtual void setValue(Ogre::Real value); }; + class NullAnimationValue : public Ogre::ControllerValue + { + public: + virtual Ogre::Real getValue() const + { return 0.0f; } + virtual void setValue(Ogre::Real value) + { } + }; + struct AnimSource : public Ogre::AnimationAlloc { NifOgre::TextKeyMap mTextKeys; std::vector > mControllers[sNumGroups]; @@ -98,6 +107,7 @@ protected: AnimStateMap mStates; Ogre::SharedPtr mAnimationValuePtr[sNumGroups]; + Ogre::SharedPtr mNullAnimationValuePtr; ObjectAttachMap mAttachedObjects; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index f2df5ccd5..df95e9f47 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -424,6 +424,10 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed) for(size_t i = 0;i < sPartListSize;i++) { + std::vector >::iterator ctrl(mObjectParts[i].mControllers.begin()); + for(;ctrl != mObjectParts[i].mControllers.end();ctrl++) + ctrl->update(); + Ogre::Entity *ent = mObjectParts[i].mSkelBase; if(!ent) continue; updateSkeletonInstance(baseinst, ent->getSkeleton()); @@ -481,6 +485,19 @@ bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority, if(type == sPartList[i].type) { 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 >::iterator ctrl(mObjectParts[i].mControllers.begin()); + for(;ctrl != mObjectParts[i].mControllers.end();ctrl++) + { + if(ctrl->getSource().isNull()) + ctrl->setSource(mNullAnimationValuePtr); + } + break; } }