From 7e7cf51adeaacb282b2e85f687adad5b22f5e805 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 6 Oct 2024 11:30:46 +0200 Subject: [PATCH] Use normalized path in NpcAnimation --- apps/openmw/mwrender/npcanimation.cpp | 18 ++++++++++-------- apps/openmw/mwrender/npcanimation.hpp | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 2f9b9f084a..d6fdad4082 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -647,7 +647,8 @@ namespace MWRender { const ESM::Light* light = part.get()->mBase; addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, - Misc::ResourceHelpers::correctMeshPath(light->mModel), false, nullptr, true); + VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(light->mModel)), false, nullptr, + true); if (mObjectParts[ESM::PRT_Shield]) addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), SceneUtil::LightCommon(*light)); } @@ -667,7 +668,7 @@ namespace MWRender { if (const ESM::BodyPart* bodypart = parts[part]) addOrReplaceIndividualPart(static_cast(part), -1, 1, - Misc::ResourceHelpers::correctMeshPath(bodypart->mModel)); + VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(bodypart->mModel))); } } @@ -675,10 +676,10 @@ namespace MWRender attachArrow(); } - PartHolderPtr NpcAnimation::insertBoundedPart(const std::string& model, std::string_view bonename, + PartHolderPtr NpcAnimation::insertBoundedPart(VFS::Path::NormalizedView model, std::string_view bonename, std::string_view bonefilter, bool enchantedGlow, osg::Vec4f* glowColor, bool isLight) { - osg::ref_ptr attached = attach(VFS::Path::toNormalized(model), bonename, bonefilter, isLight); + osg::ref_ptr attached = attach(model, bonename, bonefilter, isLight); if (enchantedGlow) mGlowUpdater = SceneUtil::addEnchantedGlow(attached, mResourceSystem, *glowColor); @@ -748,7 +749,7 @@ namespace MWRender } bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, - const std::string& mesh, bool enchantedGlow, osg::Vec4f* glowColor, bool isLight) + VFS::Path::NormalizedView mesh, bool enchantedGlow, osg::Vec4f* glowColor, bool isLight) { if (priority <= mPartPriorities[type]) return false; @@ -897,7 +898,8 @@ namespace MWRender if (bodypart) addOrReplaceIndividualPart(static_cast(part.mPart), group, priority, - Misc::ResourceHelpers::correctMeshPath(bodypart->mModel), enchantedGlow, glowColor); + VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(bodypart->mModel)), enchantedGlow, + glowColor); else reserveIndividualPart((ESM::PartReferenceType)part.mPart, group, priority); } @@ -943,7 +945,7 @@ namespace MWRender if (weapon != inv.end()) { osg::Vec4f glowColor = weapon->getClass().getEnchantmentColor(*weapon); - std::string mesh = weapon->getClass().getCorrectedModel(*weapon); + const VFS::Path::Normalized mesh = weapon->getClass().getCorrectedModel(*weapon); addOrReplaceIndividualPart(ESM::PRT_Weapon, MWWorld::InventoryStore::Slot_CarriedRight, 1, mesh, !weapon->getClass().getEnchantment(*weapon).empty(), &glowColor); @@ -1003,7 +1005,7 @@ namespace MWRender if (show && iter != inv.end()) { osg::Vec4f glowColor = iter->getClass().getEnchantmentColor(*iter); - std::string mesh = iter->getClass().getCorrectedModel(*iter); + VFS::Path::Normalized mesh = iter->getClass().getCorrectedModel(*iter); // For shields we must try to use the body part model if (iter->getType() == ESM::Armor::sRecordId) { diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index a03ee28f3a..1f9a656d65 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -1,12 +1,13 @@ #ifndef GAME_RENDER_NPCANIMATION_H #define GAME_RENDER_NPCANIMATION_H +#include "actoranimation.hpp" #include "animation.hpp" +#include "weaponanimation.hpp" -#include "../mwworld/inventorystore.hpp" +#include -#include "actoranimation.hpp" -#include "weaponanimation.hpp" +#include "../mwworld/inventorystore.hpp" #include @@ -50,8 +51,8 @@ namespace MWRender std::array mSounds; const ESM::NPC* mNpc; - std::string mHeadModel; - std::string mHairModel; + VFS::Path::Normalized mHeadModel; + VFS::Path::Normalized mHairModel; ViewMode mViewMode; bool mShowWeapons; bool mShowCarriedLeft; @@ -83,14 +84,15 @@ namespace MWRender NpcType getNpcType() const; - PartHolderPtr insertBoundedPart(const std::string& model, std::string_view bonename, + PartHolderPtr insertBoundedPart(VFS::Path::NormalizedView model, std::string_view bonename, std::string_view bonefilter, bool enchantedGlow, osg::Vec4f* glowColor, bool isLight); void removeIndividualPart(ESM::PartReferenceType type); void reserveIndividualPart(ESM::PartReferenceType type, int group, int priority); - bool addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, const std::string& mesh, - bool enchantedGlow = false, osg::Vec4f* glowColor = nullptr, bool isLight = false); + bool addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, + VFS::Path::NormalizedView mesh, bool enchantedGlow = false, osg::Vec4f* glowColor = nullptr, + bool isLight = false); void removePartGroup(int group); void addPartGroup(int group, int priority, const std::vector& parts, bool enchantedGlow = false, osg::Vec4f* glowColor = nullptr);