mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-28 14:53:58 +00:00
Use normalized path in TextureManager
This commit is contained in:
parent
3475a166e5
commit
28faae69b0
@ -1,7 +1,7 @@
|
||||
#ifndef COMPONENTS_TERRAIN_DEFS_HPP
|
||||
#define COMPONENTS_TERRAIN_DEFS_HPP
|
||||
|
||||
#include <string>
|
||||
#include <components/vfs/pathutil.hpp>
|
||||
|
||||
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?
|
||||
|
||||
|
@ -35,23 +35,21 @@ namespace Terrain
|
||||
mCache->call(f);
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> TextureManager::getTexture(const std::string& name)
|
||||
osg::ref_ptr<osg::Texture2D> 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<osg::Object> obj = mCache->getRefFromObjectCache(name);
|
||||
if (obj)
|
||||
|
||||
if (obj != nullptr)
|
||||
return static_cast<osg::Texture2D*>(obj.get());
|
||||
else
|
||||
{
|
||||
osg::ref_ptr<osg::Texture2D> 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<osg::Texture2D> 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
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef OPENMW_COMPONENTS_TERRAIN_TEXTUREMANAGER_H
|
||||
#define OPENMW_COMPONENTS_TERRAIN_TEXTUREMANAGER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <components/resource/resourcemanager.hpp>
|
||||
#include <components/vfs/pathutil.hpp>
|
||||
|
||||
namespace Resource
|
||||
{
|
||||
@ -25,7 +24,7 @@ namespace Terrain
|
||||
|
||||
void updateTextureFiltering();
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> getTexture(const std::string& name);
|
||||
osg::ref_ptr<osg::Texture2D> getTexture(VFS::Path::NormalizedView name);
|
||||
|
||||
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user