Merge branch 'sneakyidles' into 'master'

Fix idle swim/sneak animation fallback again

Closes #6816

See merge request OpenMW/openmw!2031
This commit is contained in:
psi29a 2022-06-19 11:21:21 +00:00
commit aa5535c9dc

View file

@ -672,38 +672,41 @@ void CharacterController::refreshIdleAnims(CharacterState idle, bool force)
return; return;
mIdleState = idle; mIdleState = idle;
size_t numLoops = ~0ul;
std::string idleGroup = idleStateToAnimGroup(mIdleState); std::string idleGroup = idleStateToAnimGroup(mIdleState);
// Only play "idleswim" or "idlesneak" if they exist. Otherwise, fallback to
// "idle"+weapon or "idle".
if ((mIdleState == CharState_IdleSwim || mIdleState == CharState_IdleSneak) && !mAnimation->hasAnimation(idleGroup))
{
mIdleState = CharState_Idle;
idleGroup = idleStateToAnimGroup(mIdleState);
}
MWRender::Animation::AnimPriority priority = getIdlePriority(mIdleState);
if (idleGroup.empty()) if (idleGroup.empty())
{ {
resetCurrentIdleState(); resetCurrentIdleState();
return; return;
} }
std::string weapShortGroup = getWeaponShortGroup(mWeaponType); MWRender::Animation::AnimPriority priority = getIdlePriority(mIdleState);
if (mIdleState != CharState_IdleSwim && mIdleState != CharState_IdleSneak && mIdleState != CharState_None && !weapShortGroup.empty()) size_t numLoops = std::numeric_limits<size_t>::max();
{
std::string weapIdleGroup = idleGroup + weapShortGroup;
if (!mAnimation->hasAnimation(weapIdleGroup))
weapIdleGroup = fallbackShortWeaponGroup(idleGroup);
idleGroup = weapIdleGroup;
// play until the Loop Stop key 2 to 5 times, then play until the Stop key // Only play "idleswim" or "idlesneak" if they exist. Otherwise, fallback to
// this replicates original engine behavior for the "Idle1h" 1st-person animation // "idle"+weapon or "idle".
auto& prng = MWBase::Environment::get().getWorld()->getPrng(); bool fallback = mIdleState != CharState_Idle && !mAnimation->hasAnimation(idleGroup);
numLoops = 1 + Misc::Rng::rollDice(4, prng); if (fallback)
{
priority = getIdlePriority(CharState_Idle);
idleGroup = idleStateToAnimGroup(CharState_Idle);
}
if (fallback || mIdleState == CharState_Idle || mIdleState == CharState_SpecialIdle)
{
std::string weapShortGroup = getWeaponShortGroup(mWeaponType);
if (!weapShortGroup.empty())
{
std::string weapIdleGroup = idleGroup + weapShortGroup;
if (!mAnimation->hasAnimation(weapIdleGroup))
weapIdleGroup = fallbackShortWeaponGroup(idleGroup);
idleGroup = weapIdleGroup;
// play until the Loop Stop key 2 to 5 times, then play until the Stop key
// this replicates original engine behavior for the "Idle1h" 1st-person animation
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
numLoops = 1 + Misc::Rng::rollDice(4, prng);
}
} }
if (!mAnimation->hasAnimation(idleGroup)) if (!mAnimation->hasAnimation(idleGroup))