1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00

Disable head animations for dead actors (Fixes #1781)

This commit is contained in:
scrawl 2014-08-11 05:00:13 +02:00
parent f8040da694
commit 34847baa54
4 changed files with 23 additions and 1 deletions

View File

@ -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());
}

View File

@ -306,6 +306,7 @@ public:
virtual void attachArrow() {}
virtual void releaseArrow() {}
void enableLights(bool enable);
virtual void enableHeadAnimation(bool enable) {}
Ogre::AxisAlignedBox getWorldBounds();

View File

@ -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);

View File

@ -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);