diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 9562b7cc9f..9bfe771bce 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1511,6 +1511,8 @@ void CharacterController::update(float duration) else if (mAnimation) mAnimation->updateEffects(duration); mSkipAnim = false; + + mAnimation->enableHeadAnimation(cls.isActor() && !cls.getCreatureStats(mPtr).isDead()); } diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index e15bd6ecbe..a282e34ed2 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -306,6 +306,7 @@ public: virtual void attachArrow() {} virtual void releaseArrow() {} void enableLights(bool enable); + virtual void enableHeadAnimation(bool enable) {} Ogre::AxisAlignedBox getWorldBounds(); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 0a9b56b33d..23b7616460 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -67,11 +67,16 @@ namespace MWRender { HeadAnimationTime::HeadAnimationTime(MWWorld::Ptr reference) - : mReference(reference), mTalkStart(0), mTalkStop(0), mBlinkStart(0), mBlinkStop(0), mValue(0) + : mReference(reference), mTalkStart(0), mTalkStop(0), mBlinkStart(0), mBlinkStop(0), mValue(0), mEnabled(true) { resetBlinkTimer(); } +void HeadAnimationTime::setEnabled(bool enabled) +{ + mEnabled = enabled; +} + void HeadAnimationTime::resetBlinkTimer() { mBlinkTimer = -(2 + (std::rand() / double(RAND_MAX*1.0)) * 6); @@ -79,6 +84,9 @@ void HeadAnimationTime::resetBlinkTimer() void HeadAnimationTime::update(float dt) { + if (!mEnabled) + return; + if (MWBase::Environment::get().getSoundManager()->sayDone(mReference)) { mBlinkTimer += dt; @@ -864,6 +872,11 @@ void NpcAnimation::setAlpha(float alpha) } } +void NpcAnimation::enableHeadAnimation(bool enable) +{ + mHeadAnimationTime->setEnabled(enable); +} + void NpcAnimation::preRender(Ogre::Camera *camera) { Animation::preRender(camera); diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 95cd35ddb0..979210591c 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -26,6 +26,8 @@ private: float mBlinkTimer; + bool mEnabled; + float mValue; private: void resetBlinkTimer(); @@ -34,6 +36,8 @@ public: void update(float dt); + void setEnabled(bool enabled); + void setTalkStart(float value); void setTalkStop(float value); void setBlinkStart(float value); @@ -125,6 +129,8 @@ public: ViewMode viewMode=VM_Normal); virtual ~NpcAnimation(); + virtual void enableHeadAnimation(bool enable); + virtual void setWeaponGroup(const std::string& group) { mWeaponAnimationTime->setGroup(group); } virtual Ogre::Vector3 runAnimation(float timepassed);