1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 07:15:34 +00:00

Use normalized path for glow texture names

This commit is contained in:
elsid 2024-10-06 11:18:43 +02:00
parent f27030a87c
commit 6e0eb64538
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625

View file

@ -16,28 +16,30 @@
#include <components/resource/imagemanager.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/texturetype.hpp>
#include <components/vfs/pathutil.hpp>
namespace SceneUtil
{
namespace
{
std::array<std::string, 32> generateGlowTextureNames()
std::array<VFS::Path::Normalized, 32> generateGlowTextureNames()
{
std::array<std::string, 32> result;
constexpr VFS::Path::NormalizedView prefix("textures/magicitem");
std::array<VFS::Path::Normalized, 32> result;
for (std::size_t i = 0; i < result.size(); ++i)
{
std::stringstream stream;
stream << "textures/magicitem/caust";
stream << "caust";
stream << std::setw(2);
stream << std::setfill('0');
stream << i;
stream << ".dds";
result[i] = std::move(stream).str();
result[i] = prefix / VFS::Path::Normalized(std::move(stream).str());
}
return result;
}
const std::array<std::string, 32> glowTextureNames = generateGlowTextureNames();
const std::array<VFS::Path::Normalized, 32> glowTextureNames = generateGlowTextureNames();
struct FindLowestUnusedTexUnitVisitor : public osg::NodeVisitor
{
@ -219,9 +221,9 @@ namespace SceneUtil
const osg::Vec4f& glowColor, float glowDuration)
{
std::vector<osg::ref_ptr<osg::Texture2D>> textures;
for (const std::string& name : glowTextureNames)
for (const VFS::Path::Normalized& name : glowTextureNames)
{
osg::ref_ptr<osg::Image> image = resourceSystem->getImageManager()->getImage(VFS::Path::toNormalized(name));
osg::ref_ptr<osg::Image> image = resourceSystem->getImageManager()->getImage(name);
osg::ref_ptr<osg::Texture2D> tex(new osg::Texture2D(image));
tex->setWrap(osg::Texture::WRAP_S, osg::Texture2D::REPEAT);
tex->setWrap(osg::Texture::WRAP_T, osg::Texture2D::REPEAT);