1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 03:35:27 +00:00

Consolidate refreshJumpAnims

This commit is contained in:
Alexei Kotov 2022-06-13 12:59:18 +03:00
parent ab46337c41
commit a105ba14e4

View File

@ -337,24 +337,27 @@ void CharacterController::refreshJumpAnims(const std::string& weapShortGroup, Ju
if (!force && jump == mJumpState && idle == CharState_None) if (!force && jump == mJumpState && idle == CharState_None)
return; return;
std::string jumpAnimName; if (jump == JumpState_None)
MWRender::Animation::BlendMask jumpmask = MWRender::Animation::BlendMask_All;
if (jump != JumpState_None)
{ {
jumpAnimName = "jump"; if (!mCurrentJump.empty())
if(!weapShortGroup.empty())
{ {
jumpAnimName += weapShortGroup; mAnimation->disable(mCurrentJump);
if(!mAnimation->hasAnimation(jumpAnimName)) mCurrentJump.clear();
{
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;
}
} }
mJumpState = JumpState_None;
return;
}
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 (!force && jump == mJumpState)
@ -369,24 +372,14 @@ void CharacterController::refreshJumpAnims(const std::string& weapShortGroup, Ju
mCurrentJump.clear(); mCurrentJump.clear();
} }
if (!mAnimation->hasAnimation(jumpAnimName))
return;
mCurrentJump = jumpAnimName;
if(mJumpState == JumpState_InAir) if(mJumpState == JumpState_InAir)
{ mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, false, 1.0f, startAtLoop ? "loop start" : "start", "stop", 0.f, ~0ul);
if (mAnimation->hasAnimation(jumpAnimName))
{
mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, false,
1.0f, startAtLoop ? "loop start" : "start", "stop", 0.f, ~0ul);
mCurrentJump = jumpAnimName;
}
}
else if (mJumpState == JumpState_Landing) else if (mJumpState == JumpState_Landing)
{ mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, true, 1.0f, "loop stop", "stop", 0.0f, 0);
if (mAnimation->hasAnimation(jumpAnimName))
{
mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, true,
1.0f, "loop stop", "stop", 0.0f, 0);
mCurrentJump = jumpAnimName;
}
}
} }
bool CharacterController::onOpen() const bool CharacterController::onOpen() const