aboutsummaryrefslogtreecommitdiff
path: root/src/clientmap.cpp
diff options
context:
space:
mode:
authorDániel Juhász <juhdanad@gmail.com>2017-04-21 15:34:59 +0200
committerZeno- <kde.psych@gmail.com>2017-04-21 23:34:59 +1000
commit1ffb180868ffcec6812cd3aac8f56ffefb91c8bc (patch)
tree2b7dc1d209bda384fbd995dc7f13ffdd3587818f /src/clientmap.cpp
parent2ad74a9e8b9da48aef62346de6cd55f304c6440d (diff)
downloadminetest-1ffb180868ffcec6812cd3aac8f56ffefb91c8bc.tar.gz
minetest-1ffb180868ffcec6812cd3aac8f56ffefb91c8bc.tar.bz2
minetest-1ffb180868ffcec6812cd3aac8f56ffefb91c8bc.zip
Soft node overlay (#5186)
This commit adds node overlays, which are tiles that are drawn on top of other tiles.
Diffstat (limited to 'src/clientmap.cpp')
-rw-r--r--src/clientmap.cpp56
1 files changed, 35 insertions, 21 deletions
diff --git a/src/clientmap.cpp b/src/clientmap.cpp
index 4cae03bf2..6cd24ffc6 100644
--- a/src/clientmap.cpp
+++ b/src/clientmap.cpp
@@ -290,6 +290,11 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
struct MeshBufList
{
+ /*!
+ * Specifies in which layer the list is.
+ * All lists which are in a lower layer are rendered before this list.
+ */
+ u8 layer;
video::SMaterial m;
std::vector<scene::IMeshBuffer*> bufs;
};
@@ -303,7 +308,7 @@ struct MeshBufListList
lists.clear();
}
- void add(scene::IMeshBuffer *buf)
+ void add(scene::IMeshBuffer *buf, u8 layer)
{
const video::SMaterial &m = buf->getMaterial();
for(std::vector<MeshBufList>::iterator i = lists.begin();
@@ -315,12 +320,16 @@ struct MeshBufListList
if (l.m.TextureLayer[0].Texture != m.TextureLayer[0].Texture)
continue;
+ if(l.layer != layer)
+ continue;
+
if (l.m == m) {
l.bufs.push_back(buf);
return;
}
}
MeshBufList l;
+ l.layer = layer;
l.m = m;
l.bufs.push_back(buf);
lists.push_back(l);
@@ -434,29 +443,34 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
MapBlockMesh *mapBlockMesh = block->mesh;
assert(mapBlockMesh);
- scene::IMesh *mesh = mapBlockMesh->getMesh();
- assert(mesh);
+ for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
+ scene::IMesh *mesh = mapBlockMesh->getMesh(layer);
+ assert(mesh);
- u32 c = mesh->getMeshBufferCount();
- for (u32 i = 0; i < c; i++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
+ u32 c = mesh->getMeshBufferCount();
+ for (u32 i = 0; i < c; i++) {
+ scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
- video::SMaterial& material = buf->getMaterial();
- video::IMaterialRenderer* rnd =
+ video::SMaterial& material = buf->getMaterial();
+ video::IMaterialRenderer* rnd =
driver->getMaterialRenderer(material.MaterialType);
- bool transparent = (rnd && rnd->isTransparent());
- if (transparent == is_transparent_pass) {
- if (buf->getVertexCount() == 0)
- errorstream << "Block [" << analyze_block(block)
- << "] contains an empty meshbuf" << std::endl;
-
- material.setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
- material.setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
- material.setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
- material.setFlag(video::EMF_WIREFRAME, m_control.show_wireframe);
-
- drawbufs.add(buf);
+ bool transparent = (rnd && rnd->isTransparent());
+ if (transparent == is_transparent_pass) {
+ if (buf->getVertexCount() == 0)
+ errorstream << "Block [" << analyze_block(block)
+ << "] contains an empty meshbuf" << std::endl;
+
+ material.setFlag(video::EMF_TRILINEAR_FILTER,
+ m_cache_trilinear_filter);
+ material.setFlag(video::EMF_BILINEAR_FILTER,
+ m_cache_bilinear_filter);
+ material.setFlag(video::EMF_ANISOTROPIC_FILTER,
+ m_cache_anistropic_filter);
+ material.setFlag(video::EMF_WIREFRAME,
+ m_control.show_wireframe);
+
+ drawbufs.add(buf, layer);
+ }
}
}
}