From d7e99f988b6e8633f0bb21f12e08978b72f02760 Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 19 Sep 2024 00:07:36 +0200 Subject: [PATCH] Use normalized path in ActorAnimation::attachMesh --- apps/openmw/mwrender/actoranimation.cpp | 25 +++++++++++++------------ apps/openmw/mwrender/actoranimation.hpp | 9 ++++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwrender/actoranimation.cpp b/apps/openmw/mwrender/actoranimation.cpp index df712b43b0..123090209f 100644 --- a/apps/openmw/mwrender/actoranimation.cpp +++ b/apps/openmw/mwrender/actoranimation.cpp @@ -67,14 +67,13 @@ namespace MWRender } PartHolderPtr ActorAnimation::attachMesh( - const std::string& model, std::string_view bonename, bool enchantedGlow, osg::Vec4f* glowColor) + VFS::Path::NormalizedView model, std::string_view bonename, bool enchantedGlow, osg::Vec4f* glowColor) { osg::Group* parent = getBoneByName(bonename); if (!parent) return nullptr; - osg::ref_ptr instance - = mResourceSystem->getSceneManager()->getInstance(VFS::Path::toNormalized(model), parent); + osg::ref_ptr instance = mResourceSystem->getSceneManager()->getInstance(model, parent); const NodeMap& nodeMap = getNodeMap(); NodeMap::const_iterator found = nodeMap.find(bonename); @@ -217,13 +216,13 @@ namespace MWRender return; } - std::string mesh = getSheathedShieldMesh(*shield); + const VFS::Path::Normalized mesh = getSheathedShieldMesh(*shield); if (mesh.empty()) return; - std::string_view boneName = "Bip01 AttachShield"; + constexpr std::string_view boneName = "Bip01 AttachShield"; osg::Vec4f glowColor = shield->getClass().getEnchantmentColor(*shield); - const std::string holsteredName = addSuffixBeforeExtension(mesh, "_sh"); + const VFS::Path::Normalized holsteredName = addSuffixBeforeExtension(mesh, "_sh"); bool isEnchanted = !shield->getClass().getEnchantment(*shield).empty(); // If we have no dedicated sheath model, use basic shield model as fallback. @@ -244,8 +243,7 @@ namespace MWRender // file. if (shieldNode && !shieldNode->getNumChildren()) { - osg::ref_ptr fallbackNode - = mResourceSystem->getSceneManager()->getInstance(VFS::Path::toNormalized(mesh), shieldNode); + osg::ref_ptr fallbackNode = mResourceSystem->getSceneManager()->getInstance(mesh, shieldNode); if (isEnchanted) SceneUtil::addEnchantedGlow(shieldNode, mResourceSystem, glowColor); } @@ -340,13 +338,16 @@ namespace MWRender if (MWMechanics::getWeaponType(type)->mWeaponClass == ESM::WeaponType::Thrown) showHolsteredWeapons = false; - std::string mesh = weapon->getClass().getCorrectedModel(*weapon); - std::string_view boneName = getHolsteredWeaponBoneName(*weapon); - if (mesh.empty() || boneName.empty()) + const VFS::Path::Normalized mesh = weapon->getClass().getCorrectedModel(*weapon); + if (mesh.empty()) + return; + + const std::string_view boneName = getHolsteredWeaponBoneName(*weapon); + if (boneName.empty()) return; // If the scabbard is not found, use the weapon mesh as fallback. - const std::string scabbardName = addSuffixBeforeExtension(mesh, "_sh"); + const VFS::Path::Normalized scabbardName = addSuffixBeforeExtension(mesh, "_sh"); bool isEnchanted = !weapon->getClass().getEnchantment(*weapon).empty(); if (!mResourceSystem->getVFS()->exists(scabbardName)) { diff --git a/apps/openmw/mwrender/actoranimation.hpp b/apps/openmw/mwrender/actoranimation.hpp index 5a28c41b6c..ba10c4fc16 100644 --- a/apps/openmw/mwrender/actoranimation.hpp +++ b/apps/openmw/mwrender/actoranimation.hpp @@ -53,13 +53,16 @@ namespace MWRender std::string getShieldMesh(const MWWorld::ConstPtr& shield, bool female) const; virtual std::string getSheathedShieldMesh(const MWWorld::ConstPtr& shield) const; virtual std::string_view getHolsteredWeaponBoneName(const MWWorld::ConstPtr& weapon); - virtual PartHolderPtr attachMesh( - const std::string& model, std::string_view bonename, bool enchantedGlow, osg::Vec4f* glowColor); - virtual PartHolderPtr attachMesh(const std::string& model, std::string_view bonename) + + PartHolderPtr attachMesh( + VFS::Path::NormalizedView model, std::string_view bonename, bool enchantedGlow, osg::Vec4f* glowColor); + + PartHolderPtr attachMesh(VFS::Path::NormalizedView model, std::string_view bonename) { osg::Vec4f stubColor = osg::Vec4f(0, 0, 0, 0); return attachMesh(model, bonename, false, &stubColor); } + osg::ref_ptr attach( VFS::Path::NormalizedView model, std::string_view bonename, std::string_view bonefilter, bool isLight);