Fix liquid bottoms not being rendered

This commit is contained in:
number Zero 2018-01-29 20:24:15 +03:00 committed by sfan5
parent cc400581e2
commit 49b65a5593
2 changed files with 29 additions and 0 deletions

@ -385,9 +385,16 @@ void MapblockMeshGenerator::prepareLiquidNodeDrawing()
getSpecialTile(1, &tile_liquid); getSpecialTile(1, &tile_liquid);
MapNode ntop = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(p.X, p.Y + 1, p.Z)); MapNode ntop = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(p.X, p.Y + 1, p.Z));
MapNode nbottom = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(p.X, p.Y - 1, p.Z));
c_flowing = nodedef->getId(f->liquid_alternative_flowing); c_flowing = nodedef->getId(f->liquid_alternative_flowing);
c_source = nodedef->getId(f->liquid_alternative_source); c_source = nodedef->getId(f->liquid_alternative_source);
top_is_same_liquid = (ntop.getContent() == c_flowing) || (ntop.getContent() == c_source); top_is_same_liquid = (ntop.getContent() == c_flowing) || (ntop.getContent() == c_source);
draw_liquid_bottom = (nbottom.getContent() != c_flowing) && (nbottom.getContent() != c_source);
if (draw_liquid_bottom) {
const ContentFeatures &f2 = nodedef->get(nbottom.getContent());
if (f2.solidness > 1)
draw_liquid_bottom = false;
}
if (data->m_smooth_lighting) if (data->m_smooth_lighting)
return; // don't need to pre-compute anything in this case return; // don't need to pre-compute anything in this case
@ -595,6 +602,24 @@ void MapblockMeshGenerator::drawLiquidTop()
collector->append(tile_liquid_top, vertices, 4, quad_indices, 6); collector->append(tile_liquid_top, vertices, 4, quad_indices, 6);
} }
void MapblockMeshGenerator::drawLiquidBottom()
{
video::S3DVertex vertices[4] = {
video::S3DVertex(-BS / 2, -BS / 2, -BS / 2, 0, 0, 0, color_liquid_top, 0, 0),
video::S3DVertex( BS / 2, -BS / 2, -BS / 2, 0, 0, 0, color_liquid_top, 1, 0),
video::S3DVertex( BS / 2, -BS / 2, BS / 2, 0, 0, 0, color_liquid_top, 1, 1),
video::S3DVertex(-BS / 2, -BS / 2, BS / 2, 0, 0, 0, color_liquid_top, 0, 1),
};
for (int i = 0; i < 4; i++) {
if (data->m_smooth_lighting)
vertices[i].Color = blendLightColor(vertices[i].Pos);
vertices[i].Pos += origin;
}
collector->append(tile_liquid_top, vertices, 4, quad_indices, 6);
}
void MapblockMeshGenerator::drawLiquidNode() void MapblockMeshGenerator::drawLiquidNode()
{ {
prepareLiquidNodeDrawing(); prepareLiquidNodeDrawing();
@ -603,6 +628,8 @@ void MapblockMeshGenerator::drawLiquidNode()
drawLiquidSides(); drawLiquidSides();
if (!top_is_same_liquid) if (!top_is_same_liquid)
drawLiquidTop(); drawLiquidTop();
if (draw_liquid_bottom)
drawLiquidBottom();
} }
void MapblockMeshGenerator::drawGlasslikeNode() void MapblockMeshGenerator::drawGlasslikeNode()

@ -92,6 +92,7 @@ public:
// liquid-specific // liquid-specific
bool top_is_same_liquid; bool top_is_same_liquid;
bool draw_liquid_bottom;
TileSpec tile_liquid; TileSpec tile_liquid;
TileSpec tile_liquid_top; TileSpec tile_liquid_top;
content_t c_flowing; content_t c_flowing;
@ -112,6 +113,7 @@ public:
f32 getCornerLevel(int i, int k); f32 getCornerLevel(int i, int k);
void drawLiquidSides(); void drawLiquidSides();
void drawLiquidTop(); void drawLiquidTop();
void drawLiquidBottom();
// raillike-specific // raillike-specific
// name of the group that enables connecting to raillike nodes of different kind // name of the group that enables connecting to raillike nodes of different kind