Experimental animation regression fixes

Don't unnecessarily start movement and jump animations from loop start
Don't play movement animation until jumping animation finishes
This commit is contained in:
Capostrophic 2018-09-23 00:08:16 +03:00
parent 6ce6108eb4
commit 713330351b
2 changed files with 55 additions and 51 deletions

View File

@ -351,19 +351,20 @@ void CharacterController::refreshHitRecoilAnims(CharacterState& idle)
idle = CharState_None; idle = CharState_None;
} }
void CharacterController::refreshJumpAnims(const WeaponInfo* weap, JumpingState jump, CharacterState& idle, bool force) void CharacterController::refreshJumpAnims(const WeaponInfo* weap, JumpingState jump, CharacterState& idle, CharacterState& movement, bool force)
{ {
if(force || jump != mJumpState) if (!force && jump == mJumpState && movement == CharState_None)
{ return;
if (jump != JumpState_None)
idle = CharState_None;
bool startAtLoop = (jump == mJumpState); if (jump != JumpState_None)
mJumpState = jump; {
idle = CharState_None;
movement = CharState_None;
}
std::string jumpAnimName; std::string jumpAnimName;
MWRender::Animation::BlendMask jumpmask = MWRender::Animation::BlendMask_All; MWRender::Animation::BlendMask jumpmask = MWRender::Animation::BlendMask_All;
if(mJumpState != JumpState_None) if (jump != JumpState_None)
{ {
jumpAnimName = "jump"; jumpAnimName = "jump";
if(weap != sWeaponTypeListEnd) if(weap != sWeaponTypeListEnd)
@ -386,6 +387,11 @@ void CharacterController::refreshJumpAnims(const WeaponInfo* weap, JumpingState
} }
} }
if (!force && jump == mJumpState)
return;
mJumpState = jump;
if (!mCurrentJump.empty()) if (!mCurrentJump.empty())
{ {
mAnimation->disable(mCurrentJump); mAnimation->disable(mCurrentJump);
@ -397,7 +403,7 @@ void CharacterController::refreshJumpAnims(const WeaponInfo* weap, JumpingState
if (mAnimation->hasAnimation(jumpAnimName)) if (mAnimation->hasAnimation(jumpAnimName))
{ {
mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, false, mAnimation->play(jumpAnimName, Priority_Jump, jumpmask, false,
1.0f, (startAtLoop?"loop start":"start"), "stop", 0.0f, ~0ul); 1.0f, "start", "stop", 0.f, ~0ul);
mCurrentJump = jumpAnimName; mCurrentJump = jumpAnimName;
} }
} }
@ -411,7 +417,6 @@ void CharacterController::refreshJumpAnims(const WeaponInfo* weap, JumpingState
} }
} }
} }
}
void CharacterController::refreshMovementAnims(const WeaponInfo* weap, CharacterState movement, CharacterState& idle, bool force) void CharacterController::refreshMovementAnims(const WeaponInfo* weap, CharacterState movement, CharacterState& idle, bool force)
{ {
@ -494,10 +499,9 @@ void CharacterController::refreshMovementAnims(const WeaponInfo* weap, Character
} }
// If we're playing the same animation, start it from the point it ended // If we're playing the same animation, start it from the point it ended
bool sameAnim = (movementAnimName == mCurrentMovement); float startpoint = 0.f;
float startPoint = 0.f; if (!mCurrentMovement.empty() && movementAnimName == mCurrentMovement)
if (sameAnim) mAnimation->getInfo(mCurrentMovement, &startpoint);
mAnimation->getInfo(mCurrentMovement, &startPoint);
mMovementAnimationControlled = true; mMovementAnimationControlled = true;
@ -546,7 +550,7 @@ void CharacterController::refreshMovementAnims(const WeaponInfo* weap, Character
} }
mAnimation->play(mCurrentMovement, Priority_Movement, movemask, false, mAnimation->play(mCurrentMovement, Priority_Movement, movemask, false,
1.f, (!sameAnim ? "start" : "loop start"), "stop", startPoint, ~0ul, true); 1.f, "start", "stop", startpoint, ~0ul, true);
} }
} }
} }
@ -626,7 +630,7 @@ void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterStat
if (!mPtr.getClass().hasInventoryStore(mPtr)) if (!mPtr.getClass().hasInventoryStore(mPtr))
weap = sWeaponTypeListEnd; weap = sWeaponTypeListEnd;
refreshJumpAnims(weap, jump, idle, force); refreshJumpAnims(weap, jump, idle, movement, force);
refreshMovementAnims(weap, movement, idle, force); refreshMovementAnims(weap, movement, idle, force);
// idle handled last as it can depend on the other states // idle handled last as it can depend on the other states

View File

@ -214,7 +214,7 @@ class CharacterController : public MWRender::Animation::TextKeyListener
void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false); void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false);
void refreshHitRecoilAnims(CharacterState& idle); void refreshHitRecoilAnims(CharacterState& idle);
void refreshJumpAnims(const WeaponInfo* weap, JumpingState jump, CharacterState& idle, bool force=false); void refreshJumpAnims(const WeaponInfo* weap, JumpingState jump, CharacterState& idle, CharacterState& movement, bool force=false);
void refreshMovementAnims(const WeaponInfo* weap, CharacterState movement, CharacterState& idle, bool force=false); void refreshMovementAnims(const WeaponInfo* weap, CharacterState movement, CharacterState& idle, bool force=false);
void refreshIdleAnims(const WeaponInfo* weap, CharacterState idle, bool force=false); void refreshIdleAnims(const WeaponInfo* weap, CharacterState idle, bool force=false);