mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-28 08:37:12 +00:00
Merge branch 'sheathing' into 'master'
Avoid cosmetic view-mode dependent issues in shield sheathing Closes #6845 See merge request OpenMW/openmw!2241
This commit is contained in:
commit
9c4ca98421
apps/openmw/mwrender
@ -158,33 +158,16 @@ bool ActorAnimation::updateCarriedLeftVisible(const int weaptype) const
|
||||
{
|
||||
const MWWorld::Class &cls = mPtr.getClass();
|
||||
MWMechanics::CreatureStats &stats = cls.getCreatureStats(mPtr);
|
||||
if (cls.hasInventoryStore(mPtr) && weaptype != ESM::Weapon::Spell)
|
||||
if (cls.hasInventoryStore(mPtr) && stats.getDrawState() == MWMechanics::DrawState::Nothing)
|
||||
{
|
||||
SceneUtil::FindByNameVisitor findVisitor ("Bip01 AttachShield");
|
||||
mObjectRoot->accept(findVisitor);
|
||||
if (findVisitor.mFoundNode || (mPtr == MWMechanics::getPlayer() && mPtr.isInCell() && MWBase::Environment::get().getWorld()->isFirstPerson()))
|
||||
if (findVisitor.mFoundNode)
|
||||
{
|
||||
const MWWorld::InventoryStore& inv = cls.getInventoryStore(mPtr);
|
||||
const MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
const MWWorld::ConstContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if (shield != inv.end() && shield->getType() == ESM::Armor::sRecordId && !getSheathedShieldMesh(*shield).empty())
|
||||
{
|
||||
if(stats.getDrawState() != MWMechanics::DrawState::Weapon)
|
||||
return false;
|
||||
|
||||
if (weapon != inv.end())
|
||||
{
|
||||
auto type = weapon->getType();
|
||||
if(type == ESM::Weapon::sRecordId)
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = weapon->get<ESM::Weapon>();
|
||||
ESM::Weapon::Type weaponType = (ESM::Weapon::Type)ref->mBase->mData.mType;
|
||||
return !(MWMechanics::getWeaponType(weaponType)->mFlags & ESM::WeaponType::TwoHanded);
|
||||
}
|
||||
else if (type == ESM::Lockpick::sRecordId || type == ESM::Probe::sRecordId)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,13 +295,23 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
||||
assert(viewMode != VM_HeadOnly);
|
||||
if(mViewMode == viewMode)
|
||||
return;
|
||||
|
||||
// FIXME: sheathing state must be consistent if the third person skeleton doesn't have the necessary node, but
|
||||
// third person skeleton is unavailable in first person view. This is a hack to avoid cosmetic issues.
|
||||
bool viewChange = mViewMode == VM_FirstPerson || viewMode == VM_FirstPerson;
|
||||
mViewMode = viewMode;
|
||||
MWBase::Environment::get().getWorld()->scaleObject(mPtr, mPtr.getCellRef().getScale(), true); // apply race height after view change
|
||||
|
||||
mAmmunition.reset();
|
||||
rebuild();
|
||||
setRenderBin();
|
||||
|
||||
static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game");
|
||||
if (viewChange && shieldSheathing)
|
||||
{
|
||||
int weaptype = ESM::Weapon::None;
|
||||
MWMechanics::getActiveWeapon(mPtr, &weaptype);
|
||||
showCarriedLeft(updateCarriedLeftVisible(weaptype));
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief A RenderBin callback to clear the depth buffer before rendering.
|
||||
@ -983,6 +993,30 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
||||
updateQuiver();
|
||||
}
|
||||
|
||||
bool NpcAnimation::updateCarriedLeftVisible(const int weaptype) const
|
||||
{
|
||||
static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game");
|
||||
if (shieldSheathing)
|
||||
{
|
||||
const MWWorld::Class &cls = mPtr.getClass();
|
||||
MWMechanics::CreatureStats &stats = cls.getCreatureStats(mPtr);
|
||||
if (stats.getDrawState() == MWMechanics::DrawState::Nothing)
|
||||
{
|
||||
SceneUtil::FindByNameVisitor findVisitor ("Bip01 AttachShield");
|
||||
mObjectRoot->accept(findVisitor);
|
||||
if (findVisitor.mFoundNode || mViewMode == VM_FirstPerson)
|
||||
{
|
||||
const MWWorld::InventoryStore& inv = cls.getInventoryStore(mPtr);
|
||||
const MWWorld::ConstContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if (shield != inv.end() && shield->getType() == ESM::Armor::sRecordId && !getSheathedShieldMesh(*shield).empty())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !(MWMechanics::getWeaponType(weaptype)->mFlags & ESM::WeaponType::TwoHanded);
|
||||
}
|
||||
|
||||
void NpcAnimation::showCarriedLeft(bool show)
|
||||
{
|
||||
mShowCarriedLeft = show;
|
||||
|
@ -137,6 +137,7 @@ public:
|
||||
|
||||
void showWeapons(bool showWeapon) override;
|
||||
|
||||
bool updateCarriedLeftVisible(const int weaptype) const override;
|
||||
bool getCarriedLeftShown() const override { return mShowCarriedLeft; }
|
||||
void showCarriedLeft(bool show) override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user