Use normalized path for correctMeshPath

master
elsid 1 month ago
parent 5b2764e75a
commit 22817dd6a1
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadacti.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -49,9 +51,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
});
addModelProperty(record);
record["mwscript"] = sol::readonly_property([](const ESM::Activator& rec) -> sol::optional<std::string> {
return LuaUtil::serializeRefId(rec.mScript);
});

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadappa.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -39,9 +41,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
});
addModelProperty(record);
record["mwscript"] = sol::readonly_property([](const ESM::Apparatus& rec) -> sol::optional<std::string> {
return LuaUtil::serializeRefId(rec.mScript);
});

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadarmo.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -96,8 +98,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Armor& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["icon"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -1,13 +1,14 @@
#include "types.hpp"
#include <components/misc/strings/algorithm.hpp>
#include <components/misc/strings/lower.hpp>
#include "modelproperty.hpp"
#include <components/esm3/loadbook.hpp>
#include <components/esm3/loadskil.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/misc/strings/algorithm.hpp>
#include <components/misc/strings/lower.hpp>
#include <components/resource/resourcesystem.hpp>
#include "apps/openmw/mwbase/environment.hpp"
@ -104,8 +105,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Book& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["mwscript"] = sol::readonly_property(
[](const ESM::Book& rec) -> sol::optional<std::string> { return LuaUtil::serializeRefId(rec.mScript); });
record["icon"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string {

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadclot.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -91,8 +93,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Clothing& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Clothing& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Clothing& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["icon"] = sol::readonly_property([vfs](const ESM::Clothing& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadcont.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -49,9 +51,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Container& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
});
addModelProperty(record);
record["mwscript"] = sol::readonly_property([](const ESM::Container& rec) -> sol::optional<std::string> {
return LuaUtil::serializeRefId(rec.mScript);
});

@ -1,6 +1,8 @@
#include "types.hpp"
#include "../stats.hpp"
#include "actor.hpp"
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadcrea.hpp>
#include <components/lua/luastate.hpp>
@ -37,8 +39,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Creature& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["mwscript"] = sol::readonly_property([](const ESM::Creature& rec) -> sol::optional<std::string> {
return LuaUtil::serializeRefId(rec.mScript);
});

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include "../localscripts.hpp"
#include <components/esm3/loaddoor.hpp>
@ -107,8 +109,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Door& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["mwscript"] = sol::readonly_property(
[](const ESM::Door& rec) -> sol::optional<std::string> { return LuaUtil::serializeRefId(rec.mScript); });
record["openSound"] = sol::readonly_property(
@ -145,8 +146,7 @@ namespace MWLua
record["id"] = sol::readonly_property(
[](const ESM4::Door& rec) -> std::string { return ESM::RefId(rec.mId).serializeText(); });
record["name"] = sol::readonly_property([](const ESM4::Door& rec) -> std::string { return rec.mFullName; });
record["model"] = sol::readonly_property(
[](const ESM4::Door& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["isAutomatic"] = sol::readonly_property(
[](const ESM4::Door& rec) -> bool { return rec.mDoorFlags & ESM4::Door::Flag_AutomaticDoor; });
}

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadalch.hpp>
#include <components/esm3/loadingr.hpp>
#include <components/lua/luastate.hpp>
@ -31,9 +33,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
});
addModelProperty(record);
record["mwscript"] = sol::readonly_property([](const ESM::Ingredient& rec) -> sol::optional<std::string> {
return LuaUtil::serializeRefId(rec.mScript);
});

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadligh.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -90,8 +92,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Light& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["icon"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadlock.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -30,8 +32,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Lockpick& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["mwscript"] = sol::readonly_property([](const ESM::Lockpick& rec) -> sol::optional<std::string> {
return LuaUtil::serializeRefId(rec.mScript);
});

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadmisc.hpp>
#include <components/lua/luastate.hpp>
@ -81,9 +83,7 @@ namespace MWLua
record["id"] = sol::readonly_property(
[](const ESM::Miscellaneous& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
});
addModelProperty(record);
record["mwscript"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> sol::optional<std::string> {
return LuaUtil::serializeRefId(rec.mScript);
});

@ -0,0 +1,21 @@
#ifndef OPENMW_APPS_OPENMW_MWLUA_TYPES_MODELPROPERTY_H
#define OPENMW_APPS_OPENMW_MWLUA_TYPES_MODELPROPERTY_H
#include <components/misc/resourcehelpers.hpp>
#include <components/vfs/pathutil.hpp>
#include <sol/property.hpp>
#include <sol/usertype.hpp>
namespace MWLua
{
template <class T>
void addModelProperty(sol::usertype<T>& recordType)
{
recordType["model"] = sol::readonly_property([](const T& recordValue) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(recordValue.mModel)).value();
});
}
}
#endif

@ -1,6 +1,8 @@
#include "actor.hpp"
#include "types.hpp"
#include "actor.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadfact.hpp>
#include <components/esm3/loadnpc.hpp>
#include <components/lua/luastate.hpp>
@ -93,8 +95,7 @@ namespace MWLua
= sol::readonly_property([](const ESM::NPC& rec) -> int { return (int)rec.mNpdt.mDisposition; });
record["head"]
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.serializeText(); });
record["model"] = sol::readonly_property(
[](const ESM::NPC& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["isEssential"]
= sol::readonly_property([](const ESM::NPC& rec) -> bool { return rec.mFlags & ESM::NPC::Essential; });
record["isMale"] = sol::readonly_property([](const ESM::NPC& rec) -> bool { return rec.isMale(); });

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadalch.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -76,8 +78,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Potion& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["icon"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadprob.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -30,8 +32,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Probe& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["mwscript"] = sol::readonly_property(
[](const ESM::Probe& rec) -> sol::optional<std::string> { return LuaUtil::serializeRefId(rec.mScript); });
record["icon"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string {

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadrepa.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -30,8 +32,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Repair& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["mwscript"] = sol::readonly_property(
[](const ESM::Repair& rec) -> sol::optional<std::string> { return LuaUtil::serializeRefId(rec.mScript); });
record["icon"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string {

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadstat.hpp>
#include <components/lua/luastate.hpp>
#include <components/misc/resourcehelpers.hpp>
@ -24,7 +26,6 @@ namespace MWLua
= [](const ESM::Static& rec) -> std::string { return "ESM3_Static[" + rec.mId.toDebugString() + "]"; };
record["id"]
= sol::readonly_property([](const ESM::Static& rec) -> std::string { return rec.mId.serializeText(); });
record["model"] = sol::readonly_property(
[](const ESM::Static& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
}
}

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm4/loadterm.hpp>
#include <components/lua/utilpackage.hpp>
#include <components/misc/convert.hpp>
@ -33,8 +35,6 @@ namespace MWLua
record["resultText"]
= sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mResultText; });
record["name"] = sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mFullName; });
record["model"] = sol::readonly_property([](const ESM4::Terminal& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
});
addModelProperty(record);
}
}

@ -1,5 +1,7 @@
#include "types.hpp"
#include "modelproperty.hpp"
#include <components/esm3/loadweap.hpp>
#include <components/lua/luastate.hpp>
#include <components/lua/util.hpp>
@ -129,8 +131,7 @@ namespace MWLua
record["id"]
= sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property(
[](const ESM::Weapon& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
addModelProperty(record);
record["icon"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});

@ -367,8 +367,12 @@ namespace MWMechanics
ESM::RefId::stringRefId("VFX_Reflect"));
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr);
if (animation && !reflectStatic->mModel.empty())
animation->addEffect(Misc::ResourceHelpers::correctMeshPath(reflectStatic->mModel),
ESM::MagicEffect::indexToName(ESM::MagicEffect::Reflect), false);
{
const VFS::Path::Normalized reflectStaticModel
= Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(reflectStatic->mModel));
animation->addEffect(
reflectStaticModel, ESM::MagicEffect::indexToName(ESM::MagicEffect::Reflect), false);
}
caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell(*reflected);
}
if (removedSpell)

@ -214,7 +214,7 @@ namespace
const ESM::Static* const fx
= world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Soul_Trap"));
if (fx != nullptr)
world->spawnEffect(VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(fx->mModel)), "",
world->spawnEffect(Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(fx->mModel)), "",
creature.getRefData().getPosition().asVec3());
MWBase::Environment::get().getSoundManager()->playSound3D(
@ -1806,7 +1806,7 @@ namespace MWMechanics
ESM::RefId::stringRefId("VFX_Summon_End"));
if (fx)
MWBase::Environment::get().getWorld()->spawnEffect(
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(fx->mModel)), "",
Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(fx->mModel)), "",
ptr.getRefData().getPosition().asVec3());
// Remove the summoned creature's summoned creatures as well

@ -1590,13 +1590,16 @@ namespace MWMechanics
const ESM::Static* castStatic
= world->getStore().get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Hands"));
const VFS::Path::Normalized castStaticModel
= Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(castStatic->mModel));
if (mAnimation->getNode("Bip01 L Hand"))
mAnimation->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel),
"", false, "Bip01 L Hand", effect->mParticle);
mAnimation->addEffect(
castStaticModel.value(), "", false, "Bip01 L Hand", effect->mParticle);
if (mAnimation->getNode("Bip01 R Hand"))
mAnimation->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel),
"", false, "Bip01 R Hand", effect->mParticle);
mAnimation->addEffect(
castStaticModel.value(), "", false, "Bip01 R Hand", effect->mParticle);
}
// first effect used for casting animation
const ESM::ENAMstruct& firstEffect = effects->front().mData;

@ -72,12 +72,12 @@ namespace MWMechanics
{
if (effectInfo.mData.mRange == ESM::RT_Target)
world->spawnEffect(
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel)), texture,
Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(areaStatic->mModel)), texture,
mHitPosition, 1.0f);
continue;
}
else
world->spawnEffect(VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel)),
world->spawnEffect(Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(areaStatic->mModel)),
texture, mHitPosition, static_cast<float>(effectInfo.mData.mArea * 2));
// Play explosion sound (make sure to use NoTrack, since we will delete the projectile now)
@ -487,7 +487,7 @@ namespace MWMechanics
void CastSpell::playSpellCastingEffects(const std::vector<ESM::IndexedENAMstruct>& effects) const
{
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
std::vector<std::string> addedEffects;
std::vector<VFS::Path::Normalized> addedEffects;
for (const ESM::IndexedENAMstruct& effectData : effects)
{
@ -500,17 +500,18 @@ namespace MWMechanics
else
castStatic = store.get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_DefaultCast"));
VFS::Path::Normalized castStaticModel
= Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(castStatic->mModel));
// check if the effect was already added
if (std::find(addedEffects.begin(), addedEffects.end(),
Misc::ResourceHelpers::correctMeshPath(castStatic->mModel))
!= addedEffects.end())
if (std::find(addedEffects.begin(), addedEffects.end(), castStaticModel) != addedEffects.end())
continue;
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(mCaster);
if (animation)
{
animation->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel),
ESM::MagicEffect::indexToName(effect->mIndex), false, {}, effect->mParticle);
animation->addEffect(castStaticModel.value(), ESM::MagicEffect::indexToName(effect->mIndex), false, {},
effect->mParticle);
}
else
{
@ -539,15 +540,13 @@ namespace MWMechanics
scale *= npcScaleVec.z();
}
scale = std::max(scale, 1.f);
MWBase::Environment::get().getWorld()->spawnEffect(
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel)),
effect->mParticle, pos, scale);
MWBase::Environment::get().getWorld()->spawnEffect(castStaticModel, effect->mParticle, pos, scale);
}
if (animation && !mCaster.getClass().isActor())
animation->addSpellCastGlow(effect->getColor());
addedEffects.push_back(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel));
addedEffects.push_back(std::move(castStaticModel));
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
if (!effect->mCastSound.empty())
@ -584,8 +583,12 @@ namespace MWMechanics
{
// Don't play particle VFX unless the effect is new or it should be looping.
if (playNonLooping || loop)
anim->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel),
ESM::MagicEffect::indexToName(magicEffect.mIndex), loop, {}, magicEffect.mParticle);
{
const VFS::Path::Normalized castStaticModel
= Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(castStatic->mModel));
anim->addEffect(castStaticModel.value(), ESM::MagicEffect::indexToName(magicEffect.mIndex), loop, {},
magicEffect.mParticle);
}
}
}
}

@ -286,8 +286,13 @@ namespace
const ESM::Static* absorbStatic = esmStore.get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Absorb"));
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target);
if (animation && !absorbStatic->mModel.empty())
animation->addEffect(Misc::ResourceHelpers::correctMeshPath(absorbStatic->mModel),
ESM::MagicEffect::indexToName(ESM::MagicEffect::SpellAbsorption), false);
{
const VFS::Path::Normalized absorbStaticModel
= Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(absorbStatic->mModel));
animation->addEffect(
absorbStaticModel.value(), ESM::MagicEffect::indexToName(ESM::MagicEffect::SpellAbsorption), false);
}
int spellCost = 0;
if (const ESM::Spell* spell = esmStore.get<ESM::Spell>().search(spellParams.getSourceSpellId()))
{
@ -455,8 +460,12 @@ namespace MWMechanics
anim->removeEffect(ESM::MagicEffect::indexToName(effect.mEffectId));
const ESM::Static* fx
= world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_end"));
if (fx)
anim->addEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel), "");
if (fx != nullptr)
{
const VFS::Path::Normalized fxModel
= Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(fx->mModel));
anim->addEffect(fxModel.value(), "");
}
}
}
else if (caster == getPlayer())

@ -105,7 +105,9 @@ namespace MWMechanics
const ESM::Static* fx
= world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_Start"));
if (fx)
anim->addEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel), "", false);
anim->addEffect(
Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(fx->mModel)).value(), "",
false);
}
}
catch (std::exception& e)

@ -131,7 +131,7 @@ namespace MWRender
if (bodypart == nullptr || bodypart->mData.mType != ESM::BodyPart::MT_Armor)
return std::string();
if (!bodypart->mModel.empty())
return Misc::ResourceHelpers::correctMeshPath(bodypart->mModel);
return Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(bodypart->mModel)).value();
}
}
}

@ -53,7 +53,7 @@ namespace MWRender
if (model.empty())
return;
mResourceSystem->getSceneManager()->getInstance(
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(model)), mObjectRoot.get());
Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(model)), mObjectRoot.get());
}
template <class Record>

@ -78,7 +78,7 @@ namespace
const ESM::BodyPart* bodyPart = sVampireMapping[thisCombination];
if (!bodyPart)
return std::string();
return Misc::ResourceHelpers::correctMeshPath(bodyPart->mModel);
return Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(bodyPart->mModel)).value();
}
}
@ -463,7 +463,7 @@ namespace MWRender
{
const ESM::BodyPart* bp = store.get<ESM::BodyPart>().search(headName);
if (bp)
mHeadModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel);
mHeadModel = Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(bp->mModel));
else
Log(Debug::Warning) << "Warning: Failed to load body part '" << headName << "'";
}
@ -472,7 +472,7 @@ namespace MWRender
{
const ESM::BodyPart* bp = store.get<ESM::BodyPart>().search(hairName);
if (bp)
mHairModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel);
mHairModel = Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(bp->mModel));
else
Log(Debug::Warning) << "Warning: Failed to load body part '" << hairName << "'";
}
@ -501,7 +501,7 @@ namespace MWRender
bool isCustomModel = false;
if (!is1stPerson && !isWerewolf && !mNpc->mModel.empty())
{
VFS::Path::Normalized model = Misc::ResourceHelpers::correctMeshPath(mNpc->mModel);
VFS::Path::Normalized model = Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(mNpc->mModel));
isCustomModel = !isDefaultActorSkeleton(model);
smodel = Misc::ResourceHelpers::correctActorModelPath(model, mResourceSystem->getVFS());
}
@ -648,8 +648,7 @@ namespace MWRender
{
const ESM::Light* light = part.get<ESM::Light>()->mBase;
addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1,
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(light->mModel)), false, nullptr,
true);
Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(light->mModel)), false, nullptr, true);
if (mObjectParts[ESM::PRT_Shield])
addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), SceneUtil::LightCommon(*light));
}
@ -669,7 +668,7 @@ namespace MWRender
{
if (const ESM::BodyPart* bodypart = parts[part])
addOrReplaceIndividualPart(static_cast<ESM::PartReferenceType>(part), -1, 1,
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(bodypart->mModel)));
Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(bodypart->mModel)));
}
}
@ -899,7 +898,7 @@ namespace MWRender
if (bodypart)
addOrReplaceIndividualPart(static_cast<ESM::PartReferenceType>(part.mPart), group, priority,
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(bodypart->mModel)), enchantedGlow,
Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(bodypart->mModel)), enchantedGlow,
glowColor);
else
reserveIndividualPart((ESM::PartReferenceType)part.mPart, group, priority);

@ -116,7 +116,7 @@ namespace MWWorld
try
{
const VFS::Manager& vfs = *mSceneManager->getVFS();
mesh = Misc::ResourceHelpers::correctMeshPath(path);
mesh = Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(path));
mesh = Misc::ResourceHelpers::correctActorModelPath(mesh, &vfs);
if (!vfs.exists(mesh))

@ -315,7 +315,7 @@ namespace MWWorld
{
std::string_view model = getModel(ptr);
if (!model.empty())
return Misc::ResourceHelpers::correctMeshPath(model);
return Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(model));
return {};
}

@ -222,7 +222,7 @@ namespace MWWorld
attachTo->accept(findVisitor);
if (findVisitor.mFoundNode)
mResourceSystem->getSceneManager()->getInstance(
VFS::Path::toNormalized(Misc::ResourceHelpers::correctMeshPath(weapon->mModel)),
Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(weapon->mModel)),
findVisitor.mFoundNode);
}
}
@ -330,8 +330,8 @@ namespace MWWorld
// shape
if (state.mIdMagic.size() > 1)
{
model = Misc::ResourceHelpers::correctMeshPath(
MWBase::Environment::get().getESMStore()->get<ESM::Weapon>().find(state.mIdMagic[1])->mModel);
model = Misc::ResourceHelpers::correctMeshPath(VFS::Path::Normalized(
MWBase::Environment::get().getESMStore()->get<ESM::Weapon>().find(state.mIdMagic[1])->mModel));
}
state.mProjectileId = mPhysics->addProjectile(caster, pos, model, true);
state.mToDelete = false;

@ -3682,8 +3682,10 @@ namespace MWWorld
if (texture.empty())
texture = Fallback::Map::getString("Blood_Texture_0");
VFS::Path::Normalized model(Misc::ResourceHelpers::correctMeshPath(std::string{
Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3))) } /*[0, 2]*/));
// [0, 2]
const int number = Misc::Rng::rollDice(3);
const VFS::Path::Normalized model = Misc::ResourceHelpers::correctMeshPath(
VFS::Path::Normalized(Fallback::Map::getString("Blood_Model_" + std::to_string(number))));
mRendering->spawnEffect(model, texture, worldPosition, 1.0f, false);
}

@ -167,11 +167,10 @@ std::string Misc::ResourceHelpers::correctMaterialPath(std::string_view resPath,
return correctResourcePath({ { "materials" } }, resPath, vfs);
}
std::string Misc::ResourceHelpers::correctMeshPath(std::string_view resPath)
VFS::Path::Normalized Misc::ResourceHelpers::correctMeshPath(VFS::Path::NormalizedView resPath)
{
std::string res = "meshes\\";
res.append(resPath);
return res;
static constexpr VFS::Path::NormalizedView prefix("meshes");
return prefix / resPath;
}
VFS::Path::Normalized Misc::ResourceHelpers::correctSoundPath(VFS::Path::NormalizedView resPath)

@ -36,8 +36,8 @@ namespace Misc
VFS::Path::Normalized correctActorModelPath(VFS::Path::NormalizedView resPath, const VFS::Manager* vfs);
std::string correctMaterialPath(std::string_view resPath, const VFS::Manager* vfs);
// Adds "meshes\\".
std::string correctMeshPath(std::string_view resPath);
// Prepends "meshes/".
VFS::Path::Normalized correctMeshPath(VFS::Path::NormalizedView resPath);
// Prepends "sound/".
VFS::Path::Normalized correctSoundPath(VFS::Path::NormalizedView resPath);

@ -158,7 +158,7 @@ local function testRecordCreation()
radius = 30,
color = 5,
name = "TestLight",
model = "meshes\\marker_door.dae"
model = "meshes/marker_door.dae"
}
local draft = types.Light.createRecordDraft(newLight)
local record = world.createRecord(draft)
@ -287,7 +287,7 @@ end
local function testRecordModelProperty()
initPlayer()
local player = world.players[1]
testing.expectEqual(types.NPC.record(player).model, 'meshes\\basicplayer.dae')
testing.expectEqual(types.NPC.record(player).model, 'meshes/basicplayer.dae')
end
tests = {

Loading…
Cancel
Save