Use normalized path for correctActorModelPath

pull/3236/head
elsid 2 months ago
parent 376911f645
commit afa769408a
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -121,7 +121,7 @@ namespace NavMeshTool
for (CellRef& cellRef : cellRefs)
{
std::string model(getModel(esmData, cellRef.mRefId, cellRef.mType));
VFS::Path::Normalized model(getModel(esmData, cellRef.mRefId, cellRef.mType));
if (model.empty())
continue;

@ -47,7 +47,7 @@ namespace CSVRender
mBaseNode->removeChildren(0, mBaseNode->getNumChildren());
// Load skeleton
std::string skeletonModel = mActorData->getSkeleton();
VFS::Path::Normalized skeletonModel = mActorData->getSkeleton();
skeletonModel
= Misc::ResourceHelpers::correctActorModelPath(skeletonModel, mData.getResourceSystem()->getVFS());
loadSkeleton(skeletonModel);

@ -413,8 +413,7 @@ namespace MWPhysics
return;
const VFS::Path::Normalized animationMesh = ptr.getClass().useAnim()
? VFS::Path::toNormalized(
Misc::ResourceHelpers::correctActorModelPath(mesh.value(), mResourceSystem->getVFS()))
? Misc::ResourceHelpers::correctActorModelPath(mesh, mResourceSystem->getVFS())
: VFS::Path::Normalized(mesh);
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(animationMesh);
if (!shapeInstance || !shapeInstance->mCollisionShape)
@ -564,7 +563,7 @@ namespace MWPhysics
void PhysicsSystem::addActor(const MWWorld::Ptr& ptr, VFS::Path::NormalizedView mesh)
{
const VFS::Path::Normalized animationMesh
= Misc::ResourceHelpers::correctActorModelPath(mesh.value(), mResourceSystem->getVFS());
= Misc::ResourceHelpers::correctActorModelPath(mesh, mResourceSystem->getVFS());
osg::ref_ptr<const Resource::BulletShape> shape = mShapeManager->getShape(animationMesh);
// Try to get shape from basic model as fallback for creatures

@ -1625,7 +1625,8 @@ namespace MWRender
const bool werewolf = false;
defaultSkeleton = Misc::ResourceHelpers::correctActorModelPath(
getActorSkeleton(firstPerson, isFemale, isBeast, werewolf), mResourceSystem->getVFS());
VFS::Path::toNormalized(getActorSkeleton(firstPerson, isFemale, isBeast, werewolf)),
mResourceSystem->getVFS());
}
}
}

@ -494,13 +494,14 @@ namespace MWRender
}
const std::string defaultSkeleton = Misc::ResourceHelpers::correctActorModelPath(
getActorSkeleton(is1stPerson, isFemale, isBeast, isWerewolf), mResourceSystem->getVFS());
VFS::Path::toNormalized(getActorSkeleton(is1stPerson, isFemale, isBeast, isWerewolf)),
mResourceSystem->getVFS());
std::string smodel = defaultSkeleton;
bool isCustomModel = false;
if (!is1stPerson && !isWerewolf && !mNpc->mModel.empty())
{
std::string model = Misc::ResourceHelpers::correctMeshPath(mNpc->mModel);
VFS::Path::Normalized model = Misc::ResourceHelpers::correctMeshPath(mNpc->mModel);
isCustomModel = !isDefaultActorSkeleton(model);
smodel = Misc::ResourceHelpers::correctActorModelPath(model, mResourceSystem->getVFS());
}

@ -79,7 +79,8 @@ namespace MWRender
std::string animationMesh = mesh;
if (animated && !mesh.empty())
{
animationMesh = Misc::ResourceHelpers::correctActorModelPath(mesh, mResourceSystem->getVFS());
animationMesh = Misc::ResourceHelpers::correctActorModelPath(
VFS::Path::toNormalized(mesh), mResourceSystem->getVFS());
if (animationMesh == mesh && Misc::StringUtils::ciEndsWith(animationMesh, ".nif"))
animated = false;
}
@ -96,7 +97,8 @@ namespace MWRender
ptr.getRefData().getBaseNode()->setNodeMask(Mask_Actor);
bool animated = true;
std::string animationMesh = Misc::ResourceHelpers::correctActorModelPath(mesh, mResourceSystem->getVFS());
std::string animationMesh
= Misc::ResourceHelpers::correctActorModelPath(VFS::Path::toNormalized(mesh), mResourceSystem->getVFS());
if (animationMesh == mesh && Misc::StringUtils::ciEndsWith(animationMesh, ".nif"))
animated = false;

@ -1437,8 +1437,8 @@ namespace MWScript
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
msg << "Coordinates: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl;
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const VFS::Path::Normalized model(
::Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getCorrectedModel(ptr), vfs));
const VFS::Path::Normalized model = ::Misc::ResourceHelpers::correctActorModelPath(
VFS::Path::toNormalized(ptr.getClass().getCorrectedModel(ptr)), vfs);
msg << "Model: " << model.value() << std::endl;
if (!model.empty())
{

@ -1126,8 +1126,9 @@ namespace MWWorld
void Scene::preload(const std::string& mesh, bool useAnim)
{
const VFS::Path::Normalized meshPath = useAnim
? Misc::ResourceHelpers::correctActorModelPath(mesh, mRendering.getResourceSystem()->getVFS())
: mesh;
? Misc::ResourceHelpers::correctActorModelPath(
VFS::Path::toNormalized(mesh), mRendering.getResourceSystem()->getVFS())
: VFS::Path::toNormalized(mesh);
if (mRendering.getResourceSystem()->getSceneManager()->checkLoaded(meshPath, mRendering.getReferenceTime()))
return;

@ -142,22 +142,23 @@ std::string Misc::ResourceHelpers::correctBookartPath(
return image;
}
std::string Misc::ResourceHelpers::correctActorModelPath(std::string_view resPath, const VFS::Manager* vfs)
VFS::Path::Normalized Misc::ResourceHelpers::correctActorModelPath(
VFS::Path::NormalizedView resPath, const VFS::Manager* vfs)
{
std::string mdlname(resPath);
std::string::size_type p = mdlname.find_last_of("/\\");
std::string mdlname(resPath.value());
std::string::size_type p = mdlname.find_last_of('/');
if (p != std::string::npos)
mdlname.insert(mdlname.begin() + p + 1, 'x');
mdlname.insert(mdlname.begin() + static_cast<std::string::difference_type>(p) + 1, 'x');
else
mdlname.insert(mdlname.begin(), 'x');
std::string kfname = mdlname;
if (Misc::StringUtils::ciEndsWith(kfname, ".nif"))
kfname.replace(kfname.size() - 4, 4, ".kf");
VFS::Path::Normalized kfname(mdlname);
if (Misc::getFileExtension(mdlname) == "nif")
kfname.changeExtension("kf");
if (!vfs->exists(kfname))
{
return std::string(resPath);
}
return VFS::Path::Normalized(resPath);
return mdlname;
}

@ -33,7 +33,7 @@ namespace Misc
std::string correctBookartPath(std::string_view resPath, int width, int height, const VFS::Manager* vfs);
/// Use "xfoo.nif" instead of "foo.nif" if "xfoo.kf" is available
/// Note that if "xfoo.nif" is actually unavailable, we can't fall back to "foo.nif". :(
std::string correctActorModelPath(std::string_view resPath, const VFS::Manager* vfs);
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\\".

Loading…
Cancel
Save