mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-15 02:09:43 +00:00
Use normalized path in TextureManager
This commit is contained in:
parent
3475a166e5
commit
28faae69b0
3 changed files with 15 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
||||||
#ifndef COMPONENTS_TERRAIN_DEFS_HPP
|
#ifndef COMPONENTS_TERRAIN_DEFS_HPP
|
||||||
#define COMPONENTS_TERRAIN_DEFS_HPP
|
#define COMPONENTS_TERRAIN_DEFS_HPP
|
||||||
|
|
||||||
#include <string>
|
#include <components/vfs/pathutil.hpp>
|
||||||
|
|
||||||
namespace Terrain
|
namespace Terrain
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,8 @@ namespace Terrain
|
||||||
|
|
||||||
struct LayerInfo
|
struct LayerInfo
|
||||||
{
|
{
|
||||||
std::string mDiffuseMap;
|
VFS::Path::Normalized mDiffuseMap;
|
||||||
std::string mNormalMap;
|
VFS::Path::Normalized mNormalMap;
|
||||||
bool mParallax; // Height info in normal map alpha channel?
|
bool mParallax; // Height info in normal map alpha channel?
|
||||||
bool mSpecular; // Specular info in diffuse map alpha channel?
|
bool mSpecular; // Specular info in diffuse map alpha channel?
|
||||||
|
|
||||||
|
|
|
@ -35,23 +35,21 @@ namespace Terrain
|
||||||
mCache->call(f);
|
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
|
// 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
|
// the case is always the same
|
||||||
osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(name);
|
osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(name);
|
||||||
if (obj)
|
|
||||||
|
if (obj != nullptr)
|
||||||
return static_cast<osg::Texture2D*>(obj.get());
|
return static_cast<osg::Texture2D*>(obj.get());
|
||||||
else
|
|
||||||
{
|
osg::ref_ptr<osg::Texture2D> texture(new osg::Texture2D(mSceneManager->getImageManager()->getImage(name)));
|
||||||
osg::ref_ptr<osg::Texture2D> texture(
|
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
|
||||||
new osg::Texture2D(mSceneManager->getImageManager()->getImage(VFS::Path::toNormalized(name))));
|
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
|
||||||
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
|
mSceneManager->applyFilterSettings(texture);
|
||||||
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
|
mCache->addEntryToObjectCache(name.value(), texture.get());
|
||||||
mSceneManager->applyFilterSettings(texture);
|
return texture;
|
||||||
mCache->addEntryToObjectCache(name, texture.get());
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureManager::reportStats(unsigned int frameNumber, osg::Stats* stats) const
|
void TextureManager::reportStats(unsigned int frameNumber, osg::Stats* stats) const
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#ifndef OPENMW_COMPONENTS_TERRAIN_TEXTUREMANAGER_H
|
#ifndef OPENMW_COMPONENTS_TERRAIN_TEXTUREMANAGER_H
|
||||||
#define OPENMW_COMPONENTS_TERRAIN_TEXTUREMANAGER_H
|
#define OPENMW_COMPONENTS_TERRAIN_TEXTUREMANAGER_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <components/resource/resourcemanager.hpp>
|
#include <components/resource/resourcemanager.hpp>
|
||||||
|
#include <components/vfs/pathutil.hpp>
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
{
|
{
|
||||||
|
@ -25,7 +24,7 @@ namespace Terrain
|
||||||
|
|
||||||
void updateTextureFiltering();
|
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;
|
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue