mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-05 11:41:26 +00:00
Fallback for long animation groups
This commit is contained in:
parent
123ca175c8
commit
fcd6e915d4
4 changed files with 44 additions and 10 deletions
|
@ -414,6 +414,27 @@ void CharacterController::onClose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CharacterController::getWeaponAnimation(int weaponType) const
|
||||||
|
{
|
||||||
|
std::string weaponGroup = getWeaponType(weaponType)->mLongGroup;
|
||||||
|
bool isRealWeapon = weaponType != ESM::Weapon::HandToHand && weaponType != ESM::Weapon::Spell && weaponType != ESM::Weapon::None;
|
||||||
|
if (isRealWeapon && !mAnimation->hasAnimation(weaponGroup))
|
||||||
|
{
|
||||||
|
static const std::string oneHandFallback = getWeaponType(ESM::Weapon::LongBladeOneHand)->mLongGroup;
|
||||||
|
static const std::string twoHandFallback = getWeaponType(ESM::Weapon::LongBladeTwoHand)->mLongGroup;
|
||||||
|
|
||||||
|
const ESM::WeaponType* weapInfo = getWeaponType(weaponType);
|
||||||
|
|
||||||
|
// For real two-handed melee weapons use 2h swords animations as fallback, otherwise use the 1h ones
|
||||||
|
if (weapInfo->mFlags & ESM::WeaponType::TwoHanded && weapInfo->mWeaponClass == ESM::WeaponType::Melee)
|
||||||
|
weaponGroup = twoHandFallback;
|
||||||
|
else if (isRealWeapon)
|
||||||
|
weaponGroup = oneHandFallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
return weaponGroup;
|
||||||
|
}
|
||||||
|
|
||||||
std::string CharacterController::fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask)
|
std::string CharacterController::fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -838,7 +859,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
||||||
if (mWeaponType != ESM::Weapon::None)
|
if (mWeaponType != ESM::Weapon::None)
|
||||||
{
|
{
|
||||||
mUpperBodyState = UpperCharState_WeapEquiped;
|
mUpperBodyState = UpperCharState_WeapEquiped;
|
||||||
mCurrentWeapon = getWeaponType(mWeaponType)->mLongGroup;
|
mCurrentWeapon = getWeaponAnimation(mWeaponType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mWeaponType != ESM::Weapon::None && mWeaponType != ESM::Weapon::Spell && mWeaponType != ESM::Weapon::HandToHand)
|
if(mWeaponType != ESM::Weapon::None && mWeaponType != ESM::Weapon::Spell && mWeaponType != ESM::Weapon::HandToHand)
|
||||||
|
@ -1259,7 +1280,7 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
||||||
if (!weaponChanged)
|
if (!weaponChanged)
|
||||||
{
|
{
|
||||||
// Note: we do not disable unequipping animation automatically to avoid body desync
|
// Note: we do not disable unequipping animation automatically to avoid body desync
|
||||||
weapgroup = getWeaponType(mWeaponType)->mLongGroup;
|
weapgroup = getWeaponAnimation(mWeaponType);
|
||||||
mAnimation->play(weapgroup, priorityWeapon,
|
mAnimation->play(weapgroup, priorityWeapon,
|
||||||
MWRender::Animation::BlendMask_All, false,
|
MWRender::Animation::BlendMask_All, false,
|
||||||
1.0f, "unequip start", "unequip stop", 0.0f, 0);
|
1.0f, "unequip start", "unequip stop", 0.0f, 0);
|
||||||
|
@ -1287,8 +1308,8 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
||||||
{
|
{
|
||||||
forcestateupdate = true;
|
forcestateupdate = true;
|
||||||
mAnimation->showCarriedLeft(updateCarriedLeftVisible(weaptype));
|
mAnimation->showCarriedLeft(updateCarriedLeftVisible(weaptype));
|
||||||
|
weapgroup = getWeaponAnimation(weaptype);
|
||||||
|
|
||||||
weapgroup = getWeaponType(weaptype)->mLongGroup;
|
|
||||||
// Note: controllers for ranged weapon should use time for beginning of animation to play shooting properly,
|
// Note: controllers for ranged weapon should use time for beginning of animation to play shooting properly,
|
||||||
// for other weapons they should use absolute time. Some mods rely on this behaviour (to rotate throwing projectiles, for example)
|
// for other weapons they should use absolute time. Some mods rely on this behaviour (to rotate throwing projectiles, for example)
|
||||||
ESM::WeaponType::Class weaponClass = getWeaponType(weaptype)->mWeaponClass;
|
ESM::WeaponType::Class weaponClass = getWeaponType(weaptype)->mWeaponClass;
|
||||||
|
@ -1327,7 +1348,7 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
||||||
}
|
}
|
||||||
|
|
||||||
mWeaponType = weaptype;
|
mWeaponType = weaptype;
|
||||||
mCurrentWeapon = getWeaponType(mWeaponType)->mLongGroup;
|
mCurrentWeapon = getWeaponAnimation(mWeaponType);
|
||||||
|
|
||||||
if(!upSoundId.empty() && !isStillWeapon)
|
if(!upSoundId.empty() && !isStillWeapon)
|
||||||
{
|
{
|
||||||
|
@ -1342,7 +1363,7 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
||||||
mUpperBodyState = UpperCharState_Nothing;
|
mUpperBodyState = UpperCharState_Nothing;
|
||||||
mAnimation->disable(mCurrentWeapon);
|
mAnimation->disable(mCurrentWeapon);
|
||||||
mWeaponType = ESM::Weapon::None;
|
mWeaponType = ESM::Weapon::None;
|
||||||
mCurrentWeapon = getWeaponType(mWeaponType)->mLongGroup;
|
mCurrentWeapon = getWeaponAnimation(mWeaponType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,6 +232,8 @@ class CharacterController : public MWRender::Animation::TextKeyListener
|
||||||
|
|
||||||
std::string fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask = nullptr);
|
std::string fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask = nullptr);
|
||||||
|
|
||||||
|
std::string getWeaponAnimation(int weaponType) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim);
|
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim);
|
||||||
virtual ~CharacterController();
|
virtual ~CharacterController();
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace MWMechanics
|
||||||
ESM::Weapon::ShortBladeOneHand,
|
ESM::Weapon::ShortBladeOneHand,
|
||||||
{
|
{
|
||||||
/* short group */ "1s",
|
/* short group */ "1s",
|
||||||
/* long group */ "weapononehand",
|
/* long group */ "shortbladeonehand",
|
||||||
/* sound ID */ "Item Weapon Shortblade",
|
/* sound ID */ "Item Weapon Shortblade",
|
||||||
/* attach bone */ "Weapon Bone",
|
/* attach bone */ "Weapon Bone",
|
||||||
/* sheath bone */ "Bip01 ShortBladeOneHand",
|
/* sheath bone */ "Bip01 ShortBladeOneHand",
|
||||||
|
@ -97,7 +97,7 @@ namespace MWMechanics
|
||||||
ESM::Weapon::BluntOneHand,
|
ESM::Weapon::BluntOneHand,
|
||||||
{
|
{
|
||||||
/* short group */ "1b",
|
/* short group */ "1b",
|
||||||
/* long group */ "weapononehand",
|
/* long group */ "bluntonehand",
|
||||||
/* sound ID */ "Item Weapon Blunt",
|
/* sound ID */ "Item Weapon Blunt",
|
||||||
/* attach bone */ "Weapon Bone",
|
/* attach bone */ "Weapon Bone",
|
||||||
/* sheath bone */ "Bip01 BluntOneHand",
|
/* sheath bone */ "Bip01 BluntOneHand",
|
||||||
|
@ -111,7 +111,7 @@ namespace MWMechanics
|
||||||
ESM::Weapon::AxeOneHand,
|
ESM::Weapon::AxeOneHand,
|
||||||
{
|
{
|
||||||
/* short group */ "1b",
|
/* short group */ "1b",
|
||||||
/* long group */ "weapononehand",
|
/* long group */ "bluntonehand",
|
||||||
/* sound ID */ "Item Weapon Blunt",
|
/* sound ID */ "Item Weapon Blunt",
|
||||||
/* attach bone */ "Weapon Bone",
|
/* attach bone */ "Weapon Bone",
|
||||||
/* sheath bone */ "Bip01 LongBladeOneHand",
|
/* sheath bone */ "Bip01 LongBladeOneHand",
|
||||||
|
@ -139,7 +139,7 @@ namespace MWMechanics
|
||||||
ESM::Weapon::AxeTwoHand,
|
ESM::Weapon::AxeTwoHand,
|
||||||
{
|
{
|
||||||
/* short group */ "2b",
|
/* short group */ "2b",
|
||||||
/* long group */ "weapontwohand",
|
/* long group */ "bluntwohand",
|
||||||
/* sound ID */ "Item Weapon Blunt",
|
/* sound ID */ "Item Weapon Blunt",
|
||||||
/* attach bone */ "Weapon Bone",
|
/* attach bone */ "Weapon Bone",
|
||||||
/* sheath bone */ "Bip01 AxeTwoClose",
|
/* sheath bone */ "Bip01 AxeTwoClose",
|
||||||
|
@ -153,7 +153,7 @@ namespace MWMechanics
|
||||||
ESM::Weapon::BluntTwoClose,
|
ESM::Weapon::BluntTwoClose,
|
||||||
{
|
{
|
||||||
/* short group */ "2b",
|
/* short group */ "2b",
|
||||||
/* long group */ "weapontwohand",
|
/* long group */ "bluntwohand",
|
||||||
/* sound ID */ "Item Weapon Blunt",
|
/* sound ID */ "Item Weapon Blunt",
|
||||||
/* attach bone */ "Weapon Bone",
|
/* attach bone */ "Weapon Bone",
|
||||||
/* sheath bone */ "Bip01 BluntTwoClose",
|
/* sheath bone */ "Bip01 BluntTwoClose",
|
||||||
|
|
|
@ -309,6 +309,17 @@ namespace MWRender
|
||||||
// We still should use one-handed animation as fallback
|
// We still should use one-handed animation as fallback
|
||||||
if (mAnimation->hasAnimation(inventoryGroup))
|
if (mAnimation->hasAnimation(inventoryGroup))
|
||||||
groupname = inventoryGroup;
|
groupname = inventoryGroup;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
static const std::string oneHandFallback = "inventory" + MWMechanics::getWeaponType(ESM::Weapon::LongBladeOneHand)->mLongGroup;
|
||||||
|
static const std::string twoHandFallback = "inventory" + MWMechanics::getWeaponType(ESM::Weapon::LongBladeTwoHand)->mLongGroup;
|
||||||
|
|
||||||
|
// For real two-handed melee weapons use 2h swords animations as fallback, otherwise use the 1h ones
|
||||||
|
if (weaponInfo->mFlags & ESM::WeaponType::TwoHanded && weaponInfo->mWeaponClass == ESM::WeaponType::Melee)
|
||||||
|
groupname = twoHandFallback;
|
||||||
|
else
|
||||||
|
groupname = oneHandFallback;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue