Skip to content

Commit 4d4bfb1

Browse files
authoredOct 31, 2018
Framed glasslike: Fix z-fighting, improve codestyle (#7826)
Increase inset distance of glass faces that is meant to avoid z-fighting. Note: Enabling basic shaders made the z-fighting more likely to happen.
1 parent 34a5960 commit 4d4bfb1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed
 

‎src/content_mapblock.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,9 @@ void MapblockMeshGenerator::drawGlasslikeFramedNode()
717717
bool V_merge = !(param2 & 64);
718718
param2 &= 63;
719719

720-
static const float a = BS / 2;
721-
static const float g = a - 0.003;
722-
static const float b = .876 * ( BS / 2 );
720+
static const float a = BS / 2.0f;
721+
static const float g = a - 0.03f;
722+
static const float b = 0.876f * (BS / 2.0f);
723723

724724
static const aabb3f frame_edges[FRAMED_EDGE_COUNT] = {
725725
aabb3f( b, b, -a, a, a, a), // y+
@@ -751,9 +751,12 @@ void MapblockMeshGenerator::drawGlasslikeFramedNode()
751751
bool nb[FRAMED_NEIGHBOR_COUNT] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
752752

753753
// 1 = check
754-
static const bool check_nb_vertical [FRAMED_NEIGHBOR_COUNT] = {0,1,0,0,1,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
755-
static const bool check_nb_horizontal [FRAMED_NEIGHBOR_COUNT] = {1,0,1,1,0,1, 0,0,0,0, 1,1,1,1, 0,0,0,0};
756-
static const bool check_nb_all [FRAMED_NEIGHBOR_COUNT] = {1,1,1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1};
754+
static const bool check_nb_vertical [FRAMED_NEIGHBOR_COUNT] =
755+
{0,1,0,0,1,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
756+
static const bool check_nb_horizontal [FRAMED_NEIGHBOR_COUNT] =
757+
{1,0,1,1,0,1, 0,0,0,0, 1,1,1,1, 0,0,0,0};
758+
static const bool check_nb_all [FRAMED_NEIGHBOR_COUNT] =
759+
{1,1,1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1};
757760
const bool *check_nb = check_nb_all;
758761

759762
// neighbours checks for frames visibility
@@ -807,7 +810,7 @@ void MapblockMeshGenerator::drawGlasslikeFramedNode()
807810
f->special_tiles[0].layers[0].texture) {
808811
// Internal liquid level has param2 range 0 .. 63,
809812
// convert it to -0.5 .. 0.5
810-
float vlev = (param2 / 63.0) * 2.0 - 1.0;
813+
float vlev = (param2 / 63.0f) * 2.0f - 1.0f;
811814
getSpecialTile(0, &tile);
812815
drawAutoLightedCuboid(aabb3f(-(nb[5] ? g : b),
813816
-(nb[4] ? g : b),

0 commit comments

Comments
 (0)
Please sign in to comment.