diff --git a/components/terrain/defs.hpp b/components/terrain/defs.hpp index c2342c50d2..48e4813e65 100644 --- a/components/terrain/defs.hpp +++ b/components/terrain/defs.hpp @@ -1,7 +1,7 @@ #ifndef COMPONENTS_TERRAIN_DEFS_HPP #define COMPONENTS_TERRAIN_DEFS_HPP -#include +#include namespace Terrain { @@ -16,8 +16,8 @@ namespace Terrain struct LayerInfo { - std::string mDiffuseMap; - std::string mNormalMap; + VFS::Path::Normalized mDiffuseMap; + VFS::Path::Normalized mNormalMap; bool mParallax; // Height info in normal map alpha channel? bool mSpecular; // Specular info in diffuse map alpha channel? diff --git a/components/terrain/texturemanager.cpp b/components/terrain/texturemanager.cpp index 8df880fab0..06f3243330 100644 --- a/components/terrain/texturemanager.cpp +++ b/components/terrain/texturemanager.cpp @@ -35,23 +35,21 @@ namespace Terrain mCache->call(f); } - osg::ref_ptr TextureManager::getTexture(const std::string& name) + osg::ref_ptr TextureManager::getTexture(VFS::Path::NormalizedView name) { // don't bother with case folding, since there is only one way of referring to terrain textures we can assume // the case is always the same osg::ref_ptr obj = mCache->getRefFromObjectCache(name); - if (obj) + + if (obj != nullptr) return static_cast(obj.get()); - else - { - osg::ref_ptr texture( - new osg::Texture2D(mSceneManager->getImageManager()->getImage(VFS::Path::toNormalized(name)))); - texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT); - texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT); - mSceneManager->applyFilterSettings(texture); - mCache->addEntryToObjectCache(name, texture.get()); - return texture; - } + + osg::ref_ptr texture(new osg::Texture2D(mSceneManager->getImageManager()->getImage(name))); + texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT); + texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT); + mSceneManager->applyFilterSettings(texture); + mCache->addEntryToObjectCache(name.value(), texture.get()); + return texture; } void TextureManager::reportStats(unsigned int frameNumber, osg::Stats* stats) const diff --git a/components/terrain/texturemanager.hpp b/components/terrain/texturemanager.hpp index 96fb43abfa..a79ef53b88 100644 --- a/components/terrain/texturemanager.hpp +++ b/components/terrain/texturemanager.hpp @@ -1,9 +1,8 @@ #ifndef OPENMW_COMPONENTS_TERRAIN_TEXTUREMANAGER_H #define OPENMW_COMPONENTS_TERRAIN_TEXTUREMANAGER_H -#include - #include +#include namespace Resource { @@ -25,7 +24,7 @@ namespace Terrain void updateTextureFiltering(); - osg::ref_ptr getTexture(const std::string& name); + osg::ref_ptr getTexture(VFS::Path::NormalizedView name); void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;