From 79bda2e694940a6b594fed46dd22c9022751f2ea Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Wed, 4 Oct 2023 20:46:36 +0300 Subject: [PATCH] Avoid redundant animation resets in updateIdleStormState --- apps/openmw/mwmechanics/character.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 823dd0f598..92bc2d143e 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1166,9 +1166,14 @@ namespace MWMechanics void CharacterController::updateIdleStormState(bool inwater) const { - if (!mAnimation->hasAnimation("idlestorm") || mUpperBodyState != UpperBodyState::None || inwater) + if (!mAnimation->hasAnimation("idlestorm")) + return; + + bool animPlaying = mAnimation->isPlaying("idlestorm"); + if (mUpperBodyState != UpperBodyState::None || inwater) { - mAnimation->disable("idlestorm"); + if (animPlaying) + mAnimation->disable("idlestorm"); return; } @@ -1181,7 +1186,7 @@ namespace MWMechanics characterDirection.normalize(); if (stormDirection * characterDirection < -0.5f) { - if (!mAnimation->isPlaying("idlestorm")) + if (!animPlaying) { int mask = MWRender::Animation::BlendMask_Torso | MWRender::Animation::BlendMask_RightArm; mAnimation->play("idlestorm", Priority_Storm, mask, true, 1.0f, "start", "stop", 0.0f, ~0ul); @@ -1194,7 +1199,7 @@ namespace MWMechanics } } - if (mAnimation->isPlaying("idlestorm")) + if (animPlaying) { mAnimation->setLoopingEnabled("idlestorm", false); }