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

Avoid passing weapon short group to refreshXAnims

This commit is contained in:
Alexei Kotov 2022-06-13 16:21:48 +03:00
parent 0a38c3ab78
commit b8018024a6
2 changed files with 22 additions and 16 deletions

View File

@ -425,7 +425,7 @@ void CharacterController::refreshHitRecoilAnims(CharacterState& idle)
idle = CharState_None; idle = CharState_None;
} }
void CharacterController::refreshJumpAnims(const std::string& weapShortGroup, JumpingState jump, CharacterState& idle, bool force) void CharacterController::refreshJumpAnims(JumpingState jump, CharacterState& idle, bool force)
{ {
if (!force && jump == mJumpState && idle == CharState_None) if (!force && jump == mJumpState && idle == CharState_None)
return; return;
@ -436,6 +436,7 @@ void CharacterController::refreshJumpAnims(const std::string& weapShortGroup, Ju
return; return;
} }
std::string weapShortGroup = getWeaponShortGroup(mWeaponType);
std::string jumpAnimName = "jump" + weapShortGroup; std::string jumpAnimName = "jump" + weapShortGroup;
MWRender::Animation::BlendMask jumpmask = MWRender::Animation::BlendMask_All; MWRender::Animation::BlendMask jumpmask = MWRender::Animation::BlendMask_All;
if (!weapShortGroup.empty() && !mAnimation->hasAnimation(jumpAnimName)) if (!weapShortGroup.empty() && !mAnimation->hasAnimation(jumpAnimName))
@ -525,6 +526,13 @@ std::string CharacterController::getWeaponAnimation(int weaponType) const
return weaponGroup; return weaponGroup;
} }
std::string CharacterController::getWeaponShortGroup(int weaponType) const
{
if (weaponType == ESM::Weapon::HandToHand && !mPtr.getClass().isBipedal(mPtr))
return {};
return getWeaponType(weaponType)->mShortGroup;
}
std::string CharacterController::fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask) const std::string CharacterController::fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask) const
{ {
bool isRealWeapon = mWeaponType != ESM::Weapon::HandToHand && mWeaponType != ESM::Weapon::Spell && mWeaponType != ESM::Weapon::None; bool isRealWeapon = mWeaponType != ESM::Weapon::HandToHand && mWeaponType != ESM::Weapon::Spell && mWeaponType != ESM::Weapon::None;
@ -536,8 +544,8 @@ std::string CharacterController::fallbackShortWeaponGroup(const std::string& bas
return baseGroupName; return baseGroupName;
} }
static const std::string oneHandFallback = getWeaponType(ESM::Weapon::LongBladeOneHand)->mShortGroup; static const std::string oneHandFallback = getWeaponShortGroup(ESM::Weapon::LongBladeOneHand);
static const std::string twoHandFallback = getWeaponType(ESM::Weapon::LongBladeTwoHand)->mShortGroup; static const std::string twoHandFallback = getWeaponShortGroup(ESM::Weapon::LongBladeTwoHand);
std::string groupName = baseGroupName; std::string groupName = baseGroupName;
const ESM::WeaponType* weapInfo = getWeaponType(mWeaponType); const ESM::WeaponType* weapInfo = getWeaponType(mWeaponType);
@ -562,7 +570,7 @@ std::string CharacterController::fallbackShortWeaponGroup(const std::string& bas
return groupName; return groupName;
} }
void CharacterController::refreshMovementAnims(const std::string& weapShortGroup, CharacterState movement, CharacterState& idle, bool force) void CharacterController::refreshMovementAnims(CharacterState movement, CharacterState& idle, bool force)
{ {
if (movement == mMovementState && idle == mIdleState && !force) if (movement == mMovementState && idle == mIdleState && !force)
return; return;
@ -587,6 +595,7 @@ void CharacterController::refreshMovementAnims(const std::string& weapShortGroup
MWRender::Animation::BlendMask movemask = MWRender::Animation::BlendMask_All; MWRender::Animation::BlendMask movemask = MWRender::Animation::BlendMask_All;
std::string weapShortGroup = getWeaponShortGroup(mWeaponType);
if (swimpos == std::string::npos && !weapShortGroup.empty()) if (swimpos == std::string::npos && !weapShortGroup.empty())
{ {
std::string weapMovementAnimName; std::string weapMovementAnimName;
@ -684,7 +693,7 @@ void CharacterController::refreshMovementAnims(const std::string& weapShortGroup
mAnimation->play(mCurrentMovement, Priority_Movement, movemask, false, 1.f, "start", "stop", startpoint, ~0ul, true); mAnimation->play(mCurrentMovement, Priority_Movement, movemask, false, 1.f, "start", "stop", startpoint, ~0ul, true);
} }
void CharacterController::refreshIdleAnims(const std::string& weapShortGroup, CharacterState idle, bool force) void CharacterController::refreshIdleAnims(CharacterState idle, bool force)
{ {
// FIXME: if one of the below states is close to their last animation frame (i.e. will be disabled in the coming update), // FIXME: if one of the below states is close to their last animation frame (i.e. will be disabled in the coming update),
// the idle animation should be displayed // the idle animation should be displayed
@ -714,6 +723,7 @@ void CharacterController::refreshIdleAnims(const std::string& weapShortGroup, Ch
return; return;
} }
std::string weapShortGroup = getWeaponShortGroup(mWeaponType);
if (mIdleState != CharState_IdleSwim && mIdleState != CharState_IdleSneak && mIdleState != CharState_None && !weapShortGroup.empty()) if (mIdleState != CharState_IdleSwim && mIdleState != CharState_IdleSneak && mIdleState != CharState_None && !weapShortGroup.empty())
{ {
std::string weapIdleGroup = idleGroup + weapShortGroup; std::string weapIdleGroup = idleGroup + weapShortGroup;
@ -751,16 +761,11 @@ void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterStat
return; return;
refreshHitRecoilAnims(idle); refreshHitRecoilAnims(idle);
refreshJumpAnims(jump, idle, force);
std::string weap; refreshMovementAnims(movement, idle, force);
if (mWeaponType != ESM::Weapon::HandToHand || mPtr.getClass().isBipedal(mPtr))
weap = getWeaponType(mWeaponType)->mShortGroup;
refreshJumpAnims(weap, jump, 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
refreshIdleAnims(weap, idle, force); refreshIdleAnims(idle, force);
} }
void CharacterController::playDeath(float startpoint, CharacterState death) void CharacterController::playDeath(float startpoint, CharacterState death)

View File

@ -207,9 +207,9 @@ 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 std::string& weapShortGroup, JumpingState jump, CharacterState& idle, bool force=false); void refreshJumpAnims(JumpingState jump, CharacterState& idle, bool force=false);
void refreshMovementAnims(const std::string& weapShortGroup, CharacterState movement, CharacterState& idle, bool force=false); void refreshMovementAnims(CharacterState movement, CharacterState& idle, bool force=false);
void refreshIdleAnims(const std::string& weapShortGroup, CharacterState idle, bool force=false); void refreshIdleAnims(CharacterState idle, bool force=false);
void clearAnimQueue(bool clearPersistAnims = false); void clearAnimQueue(bool clearPersistAnims = false);
@ -240,6 +240,7 @@ class CharacterController : public MWRender::Animation::TextKeyListener
std::string fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask = nullptr) const; std::string fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask = nullptr) const;
std::string getWeaponAnimation(int weaponType) const; std::string getWeaponAnimation(int weaponType) const;
std::string getWeaponShortGroup(int weaponType) const;
bool getAttackingOrSpell() const; bool getAttackingOrSpell() const;
void setAttackingOrSpell(bool attackingOrSpell) const; void setAttackingOrSpell(bool attackingOrSpell) const;