From 1a646374b0a39fce87fa856c29c4e4d2c5ecd127 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Mon, 13 Jun 2022 23:36:06 +0300 Subject: [PATCH] Always reset the idle animation after the landing animation ends --- apps/openmw/mwmechanics/character.cpp | 28 +++++++++++---------------- apps/openmw/mwmechanics/character.hpp | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 0c56d8c8d9..7cf4dea70d 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -416,13 +416,15 @@ void CharacterController::refreshHitRecoilAnims() mAnimation->play(mCurrentHit, priority, MWRender::Animation::BlendMask_All, true, 1, startKey, stopKey, 0.0f, ~0ul); } -void CharacterController::refreshJumpAnims(JumpingState jump, CharacterState& idle, bool force) +void CharacterController::refreshJumpAnims(JumpingState jump, bool force) { - if (!force && jump == mJumpState && idle == CharState_None) + if (!force && jump == mJumpState) return; if (jump == JumpState_None) { + if (!mCurrentJump.empty()) + resetCurrentIdleState(); resetCurrentJumpState(); return; } @@ -431,25 +433,20 @@ void CharacterController::refreshJumpAnims(JumpingState jump, CharacterState& id std::string jumpAnimName = "jump" + weapShortGroup; MWRender::Animation::BlendMask jumpmask = MWRender::Animation::BlendMask_All; if (!weapShortGroup.empty() && !mAnimation->hasAnimation(jumpAnimName)) - { jumpAnimName = fallbackShortWeaponGroup("jump", &jumpmask); - // If we apply jump only for lower body, do not reset idle animations. - // For upper body there will be idle animation. - if (jumpmask == MWRender::Animation::BlendMask_LowerBody && idle == CharState_None) - idle = CharState_Idle; - } - - if (!force && jump == mJumpState) + if (!mAnimation->hasAnimation(jumpAnimName)) + { + if (!mCurrentJump.empty()) + resetCurrentIdleState(); + resetCurrentJumpState(); return; + } bool startAtLoop = (jump == mJumpState); mJumpState = jump; clearStateAnimation(mCurrentJump); - if (!mAnimation->hasAnimation(jumpAnimName)) - return; - mCurrentJump = jumpAnimName; if(mJumpState == JumpState_InAir) mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, false, 1.0f, startAtLoop ? "loop start" : "start", "stop", 0.f, ~0ul); @@ -756,7 +753,7 @@ void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterStat return; refreshHitRecoilAnims(); - refreshJumpAnims(jump, idle, force); + refreshJumpAnims(jump, force); refreshMovementAnims(movement, idle, force); // idle handled last as it can depend on the other states @@ -2071,9 +2068,6 @@ void CharacterController::update(float duration) jumpstate = JumpState_Landing; vec.z() = 0.0f; - // We should reset idle animation during landing - clearStateAnimation(mCurrentIdle); - float height = cls.getCreatureStats(mPtr).land(isPlayer); float healthLost = getFallDamage(mPtr, height); diff --git a/apps/openmw/mwmechanics/character.hpp b/apps/openmw/mwmechanics/character.hpp index 6844f08f30..4b2bb3c72f 100644 --- a/apps/openmw/mwmechanics/character.hpp +++ b/apps/openmw/mwmechanics/character.hpp @@ -205,7 +205,7 @@ class CharacterController : public MWRender::Animation::TextKeyListener void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false); void refreshHitRecoilAnims(); - void refreshJumpAnims(JumpingState jump, CharacterState& idle, bool force=false); + void refreshJumpAnims(JumpingState jump, bool force=false); void refreshMovementAnims(CharacterState movement, CharacterState& idle, bool force=false); void refreshIdleAnims(CharacterState idle, bool force=false);