1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-26 06:40:22 +00:00

Merge branch 'pregenerate_glow_textures' into 'master'

Pregenerate glow texture names

See merge request OpenMW/openmw!3768
This commit is contained in:
psi29a 2024-01-13 09:50:47 +00:00
commit 8dbadd660e

View File

@ -1,6 +1,7 @@
#include "util.hpp" #include "util.hpp"
#include <algorithm> #include <algorithm>
#include <array>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
@ -17,6 +18,26 @@
namespace SceneUtil namespace SceneUtil
{ {
namespace
{
std::array<std::string, 32> generateGlowTextureNames()
{
std::array<std::string, 32> result;
for (std::size_t i = 0; i < result.size(); ++i)
{
std::stringstream stream;
stream << "textures/magicitem/caust";
stream << std::setw(2);
stream << std::setfill('0');
stream << i;
stream << ".dds";
result[i] = std::move(stream).str();
}
return result;
}
const std::array<std::string, 32> glowTextureNames = generateGlowTextureNames();
}
class FindLowestUnusedTexUnitVisitor : public osg::NodeVisitor class FindLowestUnusedTexUnitVisitor : public osg::NodeVisitor
{ {
@ -197,16 +218,9 @@ namespace SceneUtil
const osg::Vec4f& glowColor, float glowDuration) const osg::Vec4f& glowColor, float glowDuration)
{ {
std::vector<osg::ref_ptr<osg::Texture2D>> textures; std::vector<osg::ref_ptr<osg::Texture2D>> textures;
for (int i = 0; i < 32; ++i) for (const std::string& name : glowTextureNames)
{ {
std::stringstream stream; osg::ref_ptr<osg::Image> image = resourceSystem->getImageManager()->getImage(name);
stream << "textures/magicitem/caust";
stream << std::setw(2);
stream << std::setfill('0');
stream << i;
stream << ".dds";
osg::ref_ptr<osg::Image> image = resourceSystem->getImageManager()->getImage(stream.str());
osg::ref_ptr<osg::Texture2D> tex(new osg::Texture2D(image)); osg::ref_ptr<osg::Texture2D> tex(new osg::Texture2D(image));
tex->setName("envMap"); tex->setName("envMap");
tex->setWrap(osg::Texture::WRAP_S, osg::Texture2D::REPEAT); tex->setWrap(osg::Texture::WRAP_S, osg::Texture2D::REPEAT);