1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Speedup mapblock_mesh

This commit is contained in:
RealBadAngel 2014-07-15 09:07:52 +02:00 committed by sapier
parent 625489dff4
commit f0db6c4423
4 changed files with 113 additions and 99 deletions

View file

@ -389,6 +389,7 @@ public:
// Shall be called from the main thread.
bool generateImage(std::string part_of_name, video::IImage *& baseimg);
video::ITexture* getNormalTexture(const std::string &name);
private:
// The id of the thread that is allowed to use irrlicht directly
@ -1872,3 +1873,24 @@ void imageTransform(u32 transform, video::IImage *src, video::IImage *dst)
dst->setPixel(dx,dy,c);
}
}
video::ITexture* TextureSource::getNormalTexture(const std::string &name)
{
u32 id;
if (isKnownSourceImage("override_normal.png"))
return getTexture("override_normal.png", &id);
std::string fname_base = name;
std::string normal_ext = "_normal.png";
size_t pos = fname_base.find(".");
std::string fname_normal = fname_base.substr(0, pos) + normal_ext;
if (isKnownSourceImage(fname_normal)) {
// look for image extension and replace it
size_t i = 0;
while ((i = fname_base.find(".", i)) != std::string::npos) {
fname_base.replace(i, 4, normal_ext);
i += normal_ext.length();
}
return getTexture(fname_base, &id);
}
return NULL;
}