summaryrefslogtreecommitdiff
path: root/src/tile.cpp
diff options
context:
space:
mode:
authorRealBadAngel <maciej.kasatkin@o2.pl>2014-07-15 09:07:52 +0200
committersapier <Sapier at GMX dot net>2014-07-17 22:28:14 +0200
commitf0db6c4423db86203db83538704cc34152c59a09 (patch)
treeda1362d260f341898e26f7983a3b1156cce47820 /src/tile.cpp
parent625489dff4cf7d97f49035f5e490476ced42e38f (diff)
downloadminetest-f0db6c4423db86203db83538704cc34152c59a09.tar.gz
minetest-f0db6c4423db86203db83538704cc34152c59a09.tar.bz2
minetest-f0db6c4423db86203db83538704cc34152c59a09.zip
Speedup mapblock_mesh
Diffstat (limited to 'src/tile.cpp')
-rw-r--r--src/tile.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tile.cpp b/src/tile.cpp
index 17ec51614..7cb39eabf 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -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;
+}