From e2e278d06d153f5ff1c857837729e013810b38ef Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 17 Jul 2013 02:06:31 -0700 Subject: [PATCH 1/2] Fix some animations not playing properly Default movement animation speed multiplier should be 1, not 0. Only randomize death1...death5 for NPCs. --- apps/openmw/mwmechanics/character.cpp | 35 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 355a8f93d3..5a8b4b4539 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -208,11 +208,11 @@ void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterStat mCurrentMovement = movement; if(!mCurrentMovement.empty()) { - float vel, speed = 0.0f; + float vel, speedmult = 1.0f; if(mMovementSpeed > 0.0f && (vel=mAnimation->getVelocity(mCurrentMovement)) > 1.0f) - speed = mMovementSpeed / vel; + speedmult = mMovementSpeed / vel; mAnimation->play(mCurrentMovement, Priority_Movement, movegroup, false, - speed, "start", "stop", 0.0f, ~0ul); + speedmult, "start", "stop", 0.0f, ~0ul); } } } @@ -640,20 +640,29 @@ void CharacterController::forceStateUpdate() void CharacterController::kill() { - static const CharacterState deathstates[] = { - CharState_Death1, CharState_Death2, CharState_Death3, CharState_Death4, CharState_Death5 - }; - if(mDeathState != CharState_None) return; - mDeathState = deathstates[(int)(rand()/((double)RAND_MAX+1.0)*5.0)]; - const StateInfo *state = std::find_if(sStateList, sStateListEnd, FindCharState(mDeathState)); - if(state == sStateListEnd) - throw std::runtime_error("Failed to find character state "+Ogre::StringConverter::toString(mDeathState)); + if(mPtr.getTypeName() == typeid(ESM::NPC).name()) + { + static const CharacterState deathstates[] = { + CharState_Death1, CharState_Death2, CharState_Death3, CharState_Death4, CharState_Death5 + }; - mCurrentDeath = state->groupname; - if(mAnimation && !mAnimation->getInfo(mCurrentDeath)) + mDeathState = deathstates[(int)(rand()/((double)RAND_MAX+1.0)*5.0)]; + const StateInfo *state = std::find_if(sStateList, sStateListEnd, FindCharState(mDeathState)); + if(state == sStateListEnd) + throw std::runtime_error("Failed to find character state "+Ogre::StringConverter::toString(mDeathState)); + + mCurrentDeath = state->groupname; + } + else + { + mDeathState = CharState_Death1; + mCurrentDeath = "death1"; + } + + if(mAnimation) mAnimation->play(mCurrentDeath, Priority_Death, MWRender::Animation::Group_All, false, 1.0f, "start", "stop", 0.0f, 0); } From 0cd4df3edf880a4b553a5881cf706529b12a2ee6 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 17 Jul 2013 02:19:22 -0700 Subject: [PATCH 2/2] Stop playing idles on death --- apps/openmw/mwmechanics/character.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 5a8b4b4539..57ff02b8be 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -663,8 +663,14 @@ void CharacterController::kill() } if(mAnimation) + { mAnimation->play(mCurrentDeath, Priority_Death, MWRender::Animation::Group_All, false, 1.0f, "start", "stop", 0.0f, 0); + mAnimation->disable(mCurrentIdle); + } + + mIdleState = CharState_None; + mCurrentIdle.clear(); } void CharacterController::resurrect()