Use normalized path in ImageManager

This commit is contained in:
elsid 2024-09-15 14:19:32 +02:00
parent b9cb028809
commit 1fd6ac6438
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
16 changed files with 74 additions and 56 deletions

View file

@ -404,17 +404,19 @@ namespace Shader
bool normalHeight = false;
std::string normalHeightMap = normalMapFileName;
Misc::StringUtils::replaceLast(normalHeightMap, ".", mNormalHeightMapPattern + ".");
if (mImageManager.getVFS()->exists(normalHeightMap))
const VFS::Path::Normalized normalHeightMapPath(normalHeightMap);
if (mImageManager.getVFS()->exists(normalHeightMapPath))
{
image = mImageManager.getImage(normalHeightMap);
image = mImageManager.getImage(normalHeightMapPath);
normalHeight = true;
}
else
{
Misc::StringUtils::replaceLast(normalMapFileName, ".", mNormalMapPattern + ".");
if (mImageManager.getVFS()->exists(normalMapFileName))
const VFS::Path::Normalized normalMapPath(normalMapFileName);
if (mImageManager.getVFS()->exists(normalMapPath))
{
image = mImageManager.getImage(normalMapFileName);
image = mImageManager.getImage(normalMapPath);
}
}
// Avoid using the auto-detected normal map if it's already being used as a bump map.
@ -464,9 +466,10 @@ namespace Shader
{
std::string specularMapFileName = diffuseMap->getImage(0)->getFileName();
Misc::StringUtils::replaceLast(specularMapFileName, ".", mSpecularMapPattern + ".");
if (mImageManager.getVFS()->exists(specularMapFileName))
const VFS::Path::Normalized specularMapPath(specularMapFileName);
if (mImageManager.getVFS()->exists(specularMapPath))
{
osg::ref_ptr<osg::Image> image(mImageManager.getImage(specularMapFileName));
osg::ref_ptr<osg::Image> image(mImageManager.getImage(specularMapPath));
osg::ref_ptr<osg::Texture2D> specularMapTex(new osg::Texture2D(image));
specularMapTex->setTextureSize(image->s(), image->t());
specularMapTex->setWrap(osg::Texture::WRAP_S, diffuseMap->getWrap(osg::Texture::WRAP_S));