mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Use normalized path for correctActorModelPath
This commit is contained in:
parent
376911f645
commit
afa769408a
10 changed files with 30 additions and 25 deletions
|
@ -121,7 +121,7 @@ namespace NavMeshTool
|
||||||
|
|
||||||
for (CellRef& cellRef : cellRefs)
|
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())
|
if (model.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace CSVRender
|
||||||
mBaseNode->removeChildren(0, mBaseNode->getNumChildren());
|
mBaseNode->removeChildren(0, mBaseNode->getNumChildren());
|
||||||
|
|
||||||
// Load skeleton
|
// Load skeleton
|
||||||
std::string skeletonModel = mActorData->getSkeleton();
|
VFS::Path::Normalized skeletonModel = mActorData->getSkeleton();
|
||||||
skeletonModel
|
skeletonModel
|
||||||
= Misc::ResourceHelpers::correctActorModelPath(skeletonModel, mData.getResourceSystem()->getVFS());
|
= Misc::ResourceHelpers::correctActorModelPath(skeletonModel, mData.getResourceSystem()->getVFS());
|
||||||
loadSkeleton(skeletonModel);
|
loadSkeleton(skeletonModel);
|
||||||
|
|
|
@ -413,8 +413,7 @@ namespace MWPhysics
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const VFS::Path::Normalized animationMesh = ptr.getClass().useAnim()
|
const VFS::Path::Normalized animationMesh = ptr.getClass().useAnim()
|
||||||
? VFS::Path::toNormalized(
|
? Misc::ResourceHelpers::correctActorModelPath(mesh, mResourceSystem->getVFS())
|
||||||
Misc::ResourceHelpers::correctActorModelPath(mesh.value(), mResourceSystem->getVFS()))
|
|
||||||
: VFS::Path::Normalized(mesh);
|
: VFS::Path::Normalized(mesh);
|
||||||
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(animationMesh);
|
osg::ref_ptr<Resource::BulletShapeInstance> shapeInstance = mShapeManager->getInstance(animationMesh);
|
||||||
if (!shapeInstance || !shapeInstance->mCollisionShape)
|
if (!shapeInstance || !shapeInstance->mCollisionShape)
|
||||||
|
@ -564,7 +563,7 @@ namespace MWPhysics
|
||||||
void PhysicsSystem::addActor(const MWWorld::Ptr& ptr, VFS::Path::NormalizedView mesh)
|
void PhysicsSystem::addActor(const MWWorld::Ptr& ptr, VFS::Path::NormalizedView mesh)
|
||||||
{
|
{
|
||||||
const VFS::Path::Normalized animationMesh
|
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);
|
osg::ref_ptr<const Resource::BulletShape> shape = mShapeManager->getShape(animationMesh);
|
||||||
|
|
||||||
// Try to get shape from basic model as fallback for creatures
|
// Try to get shape from basic model as fallback for creatures
|
||||||
|
|
|
@ -1625,7 +1625,8 @@ namespace MWRender
|
||||||
const bool werewolf = false;
|
const bool werewolf = false;
|
||||||
|
|
||||||
defaultSkeleton = Misc::ResourceHelpers::correctActorModelPath(
|
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(
|
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;
|
std::string smodel = defaultSkeleton;
|
||||||
bool isCustomModel = false;
|
bool isCustomModel = false;
|
||||||
if (!is1stPerson && !isWerewolf && !mNpc->mModel.empty())
|
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);
|
isCustomModel = !isDefaultActorSkeleton(model);
|
||||||
smodel = Misc::ResourceHelpers::correctActorModelPath(model, mResourceSystem->getVFS());
|
smodel = Misc::ResourceHelpers::correctActorModelPath(model, mResourceSystem->getVFS());
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,8 @@ namespace MWRender
|
||||||
std::string animationMesh = mesh;
|
std::string animationMesh = mesh;
|
||||||
if (animated && !mesh.empty())
|
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"))
|
if (animationMesh == mesh && Misc::StringUtils::ciEndsWith(animationMesh, ".nif"))
|
||||||
animated = false;
|
animated = false;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,8 @@ namespace MWRender
|
||||||
ptr.getRefData().getBaseNode()->setNodeMask(Mask_Actor);
|
ptr.getRefData().getBaseNode()->setNodeMask(Mask_Actor);
|
||||||
|
|
||||||
bool animated = true;
|
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"))
|
if (animationMesh == mesh && Misc::StringUtils::ciEndsWith(animationMesh, ".nif"))
|
||||||
animated = false;
|
animated = false;
|
||||||
|
|
||||||
|
|
|
@ -1437,8 +1437,8 @@ namespace MWScript
|
||||||
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
|
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
|
||||||
msg << "Coordinates: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl;
|
msg << "Coordinates: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl;
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
const VFS::Path::Normalized model(
|
const VFS::Path::Normalized model = ::Misc::ResourceHelpers::correctActorModelPath(
|
||||||
::Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getCorrectedModel(ptr), vfs));
|
VFS::Path::toNormalized(ptr.getClass().getCorrectedModel(ptr)), vfs);
|
||||||
msg << "Model: " << model.value() << std::endl;
|
msg << "Model: " << model.value() << std::endl;
|
||||||
if (!model.empty())
|
if (!model.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1126,8 +1126,9 @@ namespace MWWorld
|
||||||
void Scene::preload(const std::string& mesh, bool useAnim)
|
void Scene::preload(const std::string& mesh, bool useAnim)
|
||||||
{
|
{
|
||||||
const VFS::Path::Normalized meshPath = useAnim
|
const VFS::Path::Normalized meshPath = useAnim
|
||||||
? Misc::ResourceHelpers::correctActorModelPath(mesh, mRendering.getResourceSystem()->getVFS())
|
? Misc::ResourceHelpers::correctActorModelPath(
|
||||||
: mesh;
|
VFS::Path::toNormalized(mesh), mRendering.getResourceSystem()->getVFS())
|
||||||
|
: VFS::Path::toNormalized(mesh);
|
||||||
|
|
||||||
if (mRendering.getResourceSystem()->getSceneManager()->checkLoaded(meshPath, mRendering.getReferenceTime()))
|
if (mRendering.getResourceSystem()->getSceneManager()->checkLoaded(meshPath, mRendering.getReferenceTime()))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -142,22 +142,23 @@ std::string Misc::ResourceHelpers::correctBookartPath(
|
||||||
return image;
|
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 mdlname(resPath.value());
|
||||||
std::string::size_type p = mdlname.find_last_of("/\\");
|
std::string::size_type p = mdlname.find_last_of('/');
|
||||||
if (p != std::string::npos)
|
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
|
else
|
||||||
mdlname.insert(mdlname.begin(), 'x');
|
mdlname.insert(mdlname.begin(), 'x');
|
||||||
std::string kfname = mdlname;
|
|
||||||
if (Misc::StringUtils::ciEndsWith(kfname, ".nif"))
|
VFS::Path::Normalized kfname(mdlname);
|
||||||
kfname.replace(kfname.size() - 4, 4, ".kf");
|
if (Misc::getFileExtension(mdlname) == "nif")
|
||||||
|
kfname.changeExtension("kf");
|
||||||
|
|
||||||
if (!vfs->exists(kfname))
|
if (!vfs->exists(kfname))
|
||||||
{
|
return VFS::Path::Normalized(resPath);
|
||||||
return std::string(resPath);
|
|
||||||
}
|
|
||||||
return mdlname;
|
return mdlname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Misc
|
||||||
std::string correctBookartPath(std::string_view resPath, int width, int height, const VFS::Manager* vfs);
|
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
|
/// 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". :(
|
/// 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);
|
std::string correctMaterialPath(std::string_view resPath, const VFS::Manager* vfs);
|
||||||
|
|
||||||
// Adds "meshes\\".
|
// Adds "meshes\\".
|
||||||
|
|
Loading…
Reference in a new issue