From e5a37543cc7932f6252a086b4b8619b5dde9ae5a Mon Sep 17 00:00:00 2001 From: Paramat Date: Thu, 15 Nov 2018 18:45:44 +0000 Subject: Framed glasslike: Don't use cuboids to draw glass faces (#7828) Previously, each glass face used drawAutoLightedCuboid() to draw a flat cuboid. This also disallowed backface culling, making the backface culling inconsistent with 'glasslike'. Use code from 'glasslike' to draw glass faces using drawQuad(). Remove long-unknown top/bottom textures feature: Makes the code simpler and cleaner. Never documented, long-unknown and not of much use. --- src/content_mapblock.cpp | 54 ++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 6572e52f2..4a0df6171 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -697,20 +697,12 @@ void MapblockMeshGenerator::drawGlasslikeFramedNode() for (int face = 0; face < 6; face++) getTile(g_6dirs[face], &tiles[face]); + if (!data->m_smooth_lighting) + color = encode_light(light, f->light_source); + TileSpec glass_tiles[6]; - if (tiles[1].layers[0].texture && - tiles[2].layers[0].texture && - tiles[3].layers[0].texture) { - glass_tiles[0] = tiles[4]; - glass_tiles[1] = tiles[2]; - glass_tiles[2] = tiles[4]; - glass_tiles[3] = tiles[4]; - glass_tiles[4] = tiles[3]; - glass_tiles[5] = tiles[4]; - } else { - for (auto &glass_tile : glass_tiles) - glass_tile = tiles[4]; - } + for (auto &glass_tile : glass_tiles) + glass_tile = tiles[4]; u8 param2 = n.getParam2(); bool H_merge = !(param2 & 128); @@ -735,14 +727,6 @@ void MapblockMeshGenerator::drawGlasslikeFramedNode() aabb3f(-a, -a, -a, a, -b, -b), // z- aabb3f(-a, b, -a, a, a, -b), // z- }; - static const aabb3f glass_faces[6] = { - aabb3f(-g, -g, g, g, g, g), // z+ - aabb3f(-g, g, -g, g, g, g), // y+ - aabb3f( g, -g, -g, g, g, g), // x+ - aabb3f(-g, -g, -g, g, g, -g), // z- - aabb3f(-g, -g, -g, g, -g, g), // y- - aabb3f(-g, -g, -g, -g, g, g), // x- - }; // tables of neighbour (connect if same type and merge allowed), // checked with g_26dirs @@ -800,8 +784,34 @@ void MapblockMeshGenerator::drawGlasslikeFramedNode() for (int face = 0; face < 6; face++) { if (nb[face]) continue; + tile = glass_tiles[face]; - drawAutoLightedCuboid(glass_faces[face]); + // Face at Z- + v3f vertices[4] = { + v3f(-a, a, -g), + v3f( a, a, -g), + v3f( a, -a, -g), + v3f(-a, -a, -g), + }; + + for (v3f &vertex : vertices) { + switch (face) { + case D6D_ZP: + vertex.rotateXZBy(180); break; + case D6D_YP: + vertex.rotateYZBy( 90); break; + case D6D_XP: + vertex.rotateXZBy( 90); break; + case D6D_ZN: + vertex.rotateXZBy( 0); break; + case D6D_YN: + vertex.rotateYZBy(-90); break; + case D6D_XN: + vertex.rotateXZBy(-90); break; + } + } + v3s16 dir = g_6dirs[face]; + drawQuad(vertices, dir); } // Optionally render internal liquid level defined by param2 -- cgit v1.2.3