diff options
author | sfan5 <sfan5@live.de> | 2022-05-09 19:28:27 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-05-26 15:49:12 +0200 |
commit | 5d26ac00883eed2f522e6e0fa3adcd7081814c9b (patch) | |
tree | e93167b0b755aaacf2aa6ea838b86c7027e08277 /src | |
parent | ed26ed5a1f49fc66facd4a745d29441aba5a92c3 (diff) | |
download | minetest-5d26ac00883eed2f522e6e0fa3adcd7081814c9b.tar.gz minetest-5d26ac00883eed2f522e6e0fa3adcd7081814c9b.tar.bz2 minetest-5d26ac00883eed2f522e6e0fa3adcd7081814c9b.zip |
Improve code in mapblock_mesh.cpp a bit
Diffstat (limited to 'src')
-rw-r--r-- | src/client/mapblock_mesh.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 965dd5e29..3be9e13b8 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -1349,30 +1349,22 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): scene::SMeshBuffer *buf = new scene::SMeshBuffer(); buf->Material = material; - switch (p.layer.material_type) { - // list of transparent materials taken from tile.h - case TILE_MATERIAL_ALPHA: - case TILE_MATERIAL_LIQUID_TRANSPARENT: - case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT: - { - buf->append(&p.vertices[0], p.vertices.size(), - &p.indices[0], 0); - - MeshTriangle t; - t.buffer = buf; - for (u32 i = 0; i < p.indices.size(); i += 3) { - t.p1 = p.indices[i]; - t.p2 = p.indices[i + 1]; - t.p3 = p.indices[i + 2]; - t.updateAttributes(); - m_transparent_triangles.push_back(t); - } + if (p.layer.isTransparent()) { + buf->append(&p.vertices[0], p.vertices.size(), nullptr, 0); + + MeshTriangle t; + t.buffer = buf; + m_transparent_triangles.reserve(p.indices.size() / 3); + for (u32 i = 0; i < p.indices.size(); i += 3) { + t.p1 = p.indices[i]; + t.p2 = p.indices[i + 1]; + t.p3 = p.indices[i + 2]; + t.updateAttributes(); + m_transparent_triangles.push_back(t); } - break; - default: + } else { buf->append(&p.vertices[0], p.vertices.size(), &p.indices[0], p.indices.size()); - break; } mesh->addMeshBuffer(buf); buf->drop(); |