Merge branch 'pregenerate_glow_textures' into 'master'

Pregenerate glow texture names

See merge request OpenMW/openmw!3768
ini_importer_tests
psi29a 12 months ago
commit 8dbadd660e

@ -1,6 +1,7 @@
#include "util.hpp"
#include <algorithm>
#include <array>
#include <iomanip>
#include <sstream>
@ -17,6 +18,26 @@
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
{
@ -197,16 +218,9 @@ namespace SceneUtil
const osg::Vec4f& glowColor, float glowDuration)
{
std::vector<osg::ref_ptr<osg::Texture2D>> textures;
for (int i = 0; i < 32; ++i)
for (const std::string& name : glowTextureNames)
{
std::stringstream stream;
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::Image> image = resourceSystem->getImageManager()->getImage(name);
osg::ref_ptr<osg::Texture2D> tex(new osg::Texture2D(image));
tex->setName("envMap");
tex->setWrap(osg::Texture::WRAP_S, osg::Texture2D::REPEAT);

Loading…
Cancel
Save