1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 22:15:32 +00:00

Don't restart the jump animation when equipping a different weapon (Fixes #2286)

This commit is contained in:
scrawl 2015-07-16 20:03:16 +02:00
parent b5c79738f1
commit cc59493cb2
2 changed files with 22 additions and 19 deletions

View file

@ -237,7 +237,7 @@ std::string CharacterController::chooseRandomGroup (const std::string& prefix, i
return prefix + toString(roll); return prefix + toString(roll);
} }
void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force) void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force)
{ {
// hit recoils/knockdown animations handling // hit recoils/knockdown animations handling
if(mPtr.getClass().isActor()) if(mPtr.getClass().isActor())
@ -314,40 +314,41 @@ void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterStat
if (!mPtr.getClass().isBipedal(mPtr)) if (!mPtr.getClass().isBipedal(mPtr))
weap = sWeaponTypeListEnd; weap = sWeaponTypeListEnd;
if(force && mJumpState != JumpState_None) if(force || jump != mJumpState)
{ {
std::string jump; bool startAtLoop = (jump == mJumpState);
mJumpState = jump;
std::string jumpAnimName;
MWRender::Animation::BlendMask jumpmask = MWRender::Animation::BlendMask_All; MWRender::Animation::BlendMask jumpmask = MWRender::Animation::BlendMask_All;
if(mJumpState != JumpState_None) if(mJumpState != JumpState_None)
{ {
jump = "jump"; jumpAnimName = "jump";
if(weap != sWeaponTypeListEnd) if(weap != sWeaponTypeListEnd)
{ {
jump += weap->shortgroup; jumpAnimName += weap->shortgroup;
if(!mAnimation->hasAnimation(jump)) if(!mAnimation->hasAnimation(jumpAnimName))
{ {
jumpmask = MWRender::Animation::BlendMask_LowerBody; jumpmask = MWRender::Animation::BlendMask_LowerBody;
jump = "jump"; jumpAnimName = "jump";
} }
} }
} }
if(mJumpState == JumpState_InAir) if(mJumpState == JumpState_InAir)
{ {
int mode = ((jump == mCurrentJump) ? 2 : 1);
mAnimation->disable(mCurrentJump); mAnimation->disable(mCurrentJump);
mCurrentJump = jump; mCurrentJump = jumpAnimName;
if (mAnimation->hasAnimation("jump")) if (mAnimation->hasAnimation("jump"))
mAnimation->play(mCurrentJump, Priority_Jump, jumpmask, false, mAnimation->play(mCurrentJump, Priority_Jump, jumpmask, false,
1.0f, ((mode!=2)?"start":"loop start"), "stop", 0.0f, ~0ul); 1.0f, (startAtLoop?"loop start":"start"), "stop", 0.0f, ~0ul);
} }
else else
{ {
mAnimation->disable(mCurrentJump); mAnimation->disable(mCurrentJump);
mCurrentJump.clear(); mCurrentJump.clear();
if (mAnimation->hasAnimation("jump")) if (mAnimation->hasAnimation("jump"))
mAnimation->play(jump, Priority_Jump, jumpmask, true, mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, true,
1.0f, "loop stop", "stop", 0.0f, 0); 1.0f, "loop stop", "stop", 0.0f, 0);
} }
} }
@ -717,7 +718,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
if(mDeathState == CharState_None) if(mDeathState == CharState_None)
refreshCurrentAnims(mIdleState, mMovementState, true); refreshCurrentAnims(mIdleState, mMovementState, mJumpState, true);
mAnimation->runAnimation(0.f); mAnimation->runAnimation(0.f);
} }
@ -1556,6 +1557,8 @@ void CharacterController::update(float duration)
CharacterState movestate = CharState_None; CharacterState movestate = CharState_None;
CharacterState idlestate = CharState_SpecialIdle; CharacterState idlestate = CharState_SpecialIdle;
JumpingState jumpstate = JumpState_None;
bool forcestateupdate = false; bool forcestateupdate = false;
mHasMovedInXY = std::abs(vec.x())+std::abs(vec.y()) > 0.0f; mHasMovedInXY = std::abs(vec.x())+std::abs(vec.y()) > 0.0f;
@ -1638,7 +1641,7 @@ void CharacterController::update(float duration)
} }
forcestateupdate = (mJumpState != JumpState_InAir); forcestateupdate = (mJumpState != JumpState_InAir);
mJumpState = JumpState_InAir; jumpstate = JumpState_InAir;
static const float fJumpMoveBase = gmst.find("fJumpMoveBase")->getFloat(); static const float fJumpMoveBase = gmst.find("fJumpMoveBase")->getFloat();
static const float fJumpMoveMult = gmst.find("fJumpMoveMult")->getFloat(); static const float fJumpMoveMult = gmst.find("fJumpMoveMult")->getFloat();
@ -1683,7 +1686,7 @@ void CharacterController::update(float duration)
else if(mJumpState == JumpState_InAir) else if(mJumpState == JumpState_InAir)
{ {
forcestateupdate = true; forcestateupdate = true;
mJumpState = JumpState_Landing; jumpstate = JumpState_Landing;
vec.z() = 0.0f; vec.z() = 0.0f;
float height = cls.getCreatureStats(mPtr).land(); float height = cls.getCreatureStats(mPtr).land();
@ -1714,7 +1717,7 @@ void CharacterController::update(float duration)
} }
else else
{ {
mJumpState = JumpState_None; jumpstate = JumpState_None;
vec.z() = 0.0f; vec.z() = 0.0f;
inJump = false; inJump = false;
@ -1792,7 +1795,7 @@ void CharacterController::update(float duration)
forcestateupdate = updateCreatureState() || forcestateupdate; forcestateupdate = updateCreatureState() || forcestateupdate;
if (!mSkipAnim) if (!mSkipAnim)
refreshCurrentAnims(idlestate, movestate, forcestateupdate); refreshCurrentAnims(idlestate, movestate, jumpstate, forcestateupdate);
if (inJump) if (inJump)
mMovementAnimationControlled = false; mMovementAnimationControlled = false;
@ -1928,7 +1931,7 @@ void CharacterController::forceStateUpdate()
return; return;
clearAnimQueue(); clearAnimQueue();
refreshCurrentAnims(mIdleState, mMovementState, true); refreshCurrentAnims(mIdleState, mMovementState, mJumpState, true);
if(mDeathState != CharState_None) if(mDeathState != CharState_None)
{ {
playRandomDeath(); playRandomDeath();

View file

@ -186,7 +186,7 @@ class CharacterController : public MWRender::Animation::TextKeyListener
void determineAttackType(); void determineAttackType();
void refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force=false); void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false);
void clearAnimQueue(); void clearAnimQueue();