mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 04:10:24 +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
3 changed files with 39 additions and 21 deletions
|
@ -158,33 +158,16 @@ bool ActorAnimation::updateCarriedLeftVisible(const int weaptype) const
|
||||||
{
|
{
|
||||||
const MWWorld::Class &cls = mPtr.getClass();
|
const MWWorld::Class &cls = mPtr.getClass();
|
||||||
MWMechanics::CreatureStats &stats = cls.getCreatureStats(mPtr);
|
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");
|
SceneUtil::FindByNameVisitor findVisitor ("Bip01 AttachShield");
|
||||||
mObjectRoot->accept(findVisitor);
|
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::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);
|
const MWWorld::ConstContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||||
if (shield != inv.end() && shield->getType() == ESM::Armor::sRecordId && !getSheathedShieldMesh(*shield).empty())
|
if (shield != inv.end() && shield->getType() == ESM::Armor::sRecordId && !getSheathedShieldMesh(*shield).empty())
|
||||||
{
|
|
||||||
if(stats.getDrawState() != MWMechanics::DrawState::Weapon)
|
|
||||||
return false;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,13 +295,23 @@ void NpcAnimation::setViewMode(NpcAnimation::ViewMode viewMode)
|
||||||
assert(viewMode != VM_HeadOnly);
|
assert(viewMode != VM_HeadOnly);
|
||||||
if(mViewMode == viewMode)
|
if(mViewMode == viewMode)
|
||||||
return;
|
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;
|
mViewMode = viewMode;
|
||||||
MWBase::Environment::get().getWorld()->scaleObject(mPtr, mPtr.getCellRef().getScale(), true); // apply race height after view change
|
MWBase::Environment::get().getWorld()->scaleObject(mPtr, mPtr.getCellRef().getScale(), true); // apply race height after view change
|
||||||
|
|
||||||
mAmmunition.reset();
|
mAmmunition.reset();
|
||||||
rebuild();
|
rebuild();
|
||||||
setRenderBin();
|
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.
|
/// @brief A RenderBin callback to clear the depth buffer before rendering.
|
||||||
|
@ -983,6 +993,30 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
||||||
updateQuiver();
|
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)
|
void NpcAnimation::showCarriedLeft(bool show)
|
||||||
{
|
{
|
||||||
mShowCarriedLeft = show;
|
mShowCarriedLeft = show;
|
||||||
|
|
|
@ -137,6 +137,7 @@ public:
|
||||||
|
|
||||||
void showWeapons(bool showWeapon) override;
|
void showWeapons(bool showWeapon) override;
|
||||||
|
|
||||||
|
bool updateCarriedLeftVisible(const int weaptype) const override;
|
||||||
bool getCarriedLeftShown() const override { return mShowCarriedLeft; }
|
bool getCarriedLeftShown() const override { return mShowCarriedLeft; }
|
||||||
void showCarriedLeft(bool show) override;
|
void showCarriedLeft(bool show) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue