Skip to content

Commit 49b65a5

Browse files
numberZerosfan5
authored andcommittedJan 30, 2018
Fix liquid bottoms not being rendered
1 parent cc40058 commit 49b65a5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
 

Diff for: ‎src/content_mapblock.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,16 @@ void MapblockMeshGenerator::prepareLiquidNodeDrawing()
385385
getSpecialTile(1, &tile_liquid);
386386

387387
MapNode ntop = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(p.X, p.Y + 1, p.Z));
388+
MapNode nbottom = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(p.X, p.Y - 1, p.Z));
388389
c_flowing = nodedef->getId(f->liquid_alternative_flowing);
389390
c_source = nodedef->getId(f->liquid_alternative_source);
390391
top_is_same_liquid = (ntop.getContent() == c_flowing) || (ntop.getContent() == c_source);
392+
draw_liquid_bottom = (nbottom.getContent() != c_flowing) && (nbottom.getContent() != c_source);
393+
if (draw_liquid_bottom) {
394+
const ContentFeatures &f2 = nodedef->get(nbottom.getContent());
395+
if (f2.solidness > 1)
396+
draw_liquid_bottom = false;
397+
}
391398

392399
if (data->m_smooth_lighting)
393400
return; // don't need to pre-compute anything in this case
@@ -595,6 +602,24 @@ void MapblockMeshGenerator::drawLiquidTop()
595602
collector->append(tile_liquid_top, vertices, 4, quad_indices, 6);
596603
}
597604

605+
void MapblockMeshGenerator::drawLiquidBottom()
606+
{
607+
video::S3DVertex vertices[4] = {
608+
video::S3DVertex(-BS / 2, -BS / 2, -BS / 2, 0, 0, 0, color_liquid_top, 0, 0),
609+
video::S3DVertex( BS / 2, -BS / 2, -BS / 2, 0, 0, 0, color_liquid_top, 1, 0),
610+
video::S3DVertex( BS / 2, -BS / 2, BS / 2, 0, 0, 0, color_liquid_top, 1, 1),
611+
video::S3DVertex(-BS / 2, -BS / 2, BS / 2, 0, 0, 0, color_liquid_top, 0, 1),
612+
};
613+
614+
for (int i = 0; i < 4; i++) {
615+
if (data->m_smooth_lighting)
616+
vertices[i].Color = blendLightColor(vertices[i].Pos);
617+
vertices[i].Pos += origin;
618+
}
619+
620+
collector->append(tile_liquid_top, vertices, 4, quad_indices, 6);
621+
}
622+
598623
void MapblockMeshGenerator::drawLiquidNode()
599624
{
600625
prepareLiquidNodeDrawing();
@@ -603,6 +628,8 @@ void MapblockMeshGenerator::drawLiquidNode()
603628
drawLiquidSides();
604629
if (!top_is_same_liquid)
605630
drawLiquidTop();
631+
if (draw_liquid_bottom)
632+
drawLiquidBottom();
606633
}
607634

608635
void MapblockMeshGenerator::drawGlasslikeNode()

Diff for: ‎src/content_mapblock.h

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class MapblockMeshGenerator
9292

9393
// liquid-specific
9494
bool top_is_same_liquid;
95+
bool draw_liquid_bottom;
9596
TileSpec tile_liquid;
9697
TileSpec tile_liquid_top;
9798
content_t c_flowing;
@@ -112,6 +113,7 @@ class MapblockMeshGenerator
112113
f32 getCornerLevel(int i, int k);
113114
void drawLiquidSides();
114115
void drawLiquidTop();
116+
void drawLiquidBottom();
115117

116118
// raillike-specific
117119
// name of the group that enables connecting to raillike nodes of different kind

0 commit comments

Comments
 (0)