Cleanup in content_mapblock (#5746)
NDT_LIQUID is being drawn by MapBlockMesh since a long time ago...
This commit is contained in:
parent
1ff5ee0b69
commit
7779bac3a5
|
@ -376,10 +376,10 @@ static TileSpec getSpecialTile(const ContentFeatures &f,
|
|||
return copy;
|
||||
}
|
||||
|
||||
void MapblockMeshGenerator::prepareLiquidNodeDrawing(bool flowing)
|
||||
void MapblockMeshGenerator::prepareLiquidNodeDrawing()
|
||||
{
|
||||
tile_liquid_top = getSpecialTile(*f, n, 0);
|
||||
tile_liquid = getSpecialTile(*f, n, flowing ? 1 : 0);
|
||||
tile_liquid = getSpecialTile(*f, n, 1);
|
||||
|
||||
MapNode ntop = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(p.X, p.Y + 1, p.Z));
|
||||
c_flowing = nodedef->getId(f->liquid_alternative_flowing);
|
||||
|
@ -403,16 +403,12 @@ void MapblockMeshGenerator::prepareLiquidNodeDrawing(bool flowing)
|
|||
color = encode_light(light, f->light_source);
|
||||
}
|
||||
|
||||
void MapblockMeshGenerator::getLiquidNeighborhood(bool flowing)
|
||||
void MapblockMeshGenerator::getLiquidNeighborhood()
|
||||
{
|
||||
u8 range = rangelim(nodedef->get(c_flowing).liquid_range, 1, 8);
|
||||
|
||||
for (int w = -1; w <= 1; w++)
|
||||
for (int u = -1; u <= 1; u++) {
|
||||
// Skip getting unneeded data
|
||||
if (!flowing && u && w)
|
||||
continue;
|
||||
|
||||
NeighborData &neighbor = liquid_neighbors[w + 1][u + 1];
|
||||
v3s16 p2 = p + v3s16(u, 0, w);
|
||||
MapNode n2 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p2);
|
||||
|
@ -447,13 +443,6 @@ void MapblockMeshGenerator::getLiquidNeighborhood(bool flowing)
|
|||
}
|
||||
}
|
||||
|
||||
void MapblockMeshGenerator::resetCornerLevels()
|
||||
{
|
||||
for (int k = 0; k < 2; k++)
|
||||
for (int i = 0; i < 2; i++)
|
||||
corner_levels[k][i] = 0.5 * BS;
|
||||
}
|
||||
|
||||
void MapblockMeshGenerator::calculateCornerLevels()
|
||||
{
|
||||
for (int k = 0; k < 2; k++)
|
||||
|
@ -494,7 +483,7 @@ f32 MapblockMeshGenerator::getCornerLevel(int i, int k)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void MapblockMeshGenerator::drawLiquidSides(bool flowing)
|
||||
void MapblockMeshGenerator::drawLiquidSides()
|
||||
{
|
||||
struct LiquidFaceDesc {
|
||||
v3s16 dir; // XZ
|
||||
|
@ -523,17 +512,12 @@ void MapblockMeshGenerator::drawLiquidSides(bool flowing)
|
|||
// at the top to which it should be connected. Again, unless the face
|
||||
// there would be inside the liquid
|
||||
if (neighbor.is_same_liquid) {
|
||||
if (!flowing)
|
||||
continue;
|
||||
if (!top_is_same_liquid)
|
||||
continue;
|
||||
if (neighbor.top_is_same_liquid)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!flowing && (neighbor.content == CONTENT_IGNORE))
|
||||
continue;
|
||||
|
||||
const ContentFeatures &neighbor_features = nodedef->get(neighbor.content);
|
||||
// Don't draw face if neighbor is blocking the view
|
||||
if (neighbor_features.solidness == 2)
|
||||
|
@ -559,7 +543,7 @@ void MapblockMeshGenerator::drawLiquidSides(bool flowing)
|
|||
}
|
||||
}
|
||||
|
||||
void MapblockMeshGenerator::drawLiquidTop(bool flowing)
|
||||
void MapblockMeshGenerator::drawLiquidTop()
|
||||
{
|
||||
// To get backface culling right, the vertices need to go
|
||||
// clockwise around the front of the face. And we happened to
|
||||
|
@ -582,7 +566,6 @@ void MapblockMeshGenerator::drawLiquidTop(bool flowing)
|
|||
vertices[i].Pos += origin;
|
||||
}
|
||||
|
||||
if (flowing) {
|
||||
// Default downwards-flowing texture animation goes from
|
||||
// -Z towards +Z, thus the direction is +Z.
|
||||
// Rotate texture to make animation go in flow direction
|
||||
|
@ -605,22 +588,18 @@ void MapblockMeshGenerator::drawLiquidTop(bool flowing)
|
|||
}
|
||||
|
||||
std::swap(vertices[0].TCoords, vertices[2].TCoords);
|
||||
}
|
||||
|
||||
collector->append(tile_liquid_top, vertices, 4, quad_indices, 6);
|
||||
}
|
||||
|
||||
void MapblockMeshGenerator::drawLiquidNode(bool flowing)
|
||||
void MapblockMeshGenerator::drawLiquidNode()
|
||||
{
|
||||
prepareLiquidNodeDrawing(flowing);
|
||||
getLiquidNeighborhood(flowing);
|
||||
if (flowing)
|
||||
prepareLiquidNodeDrawing();
|
||||
getLiquidNeighborhood();
|
||||
calculateCornerLevels();
|
||||
else
|
||||
resetCornerLevels();
|
||||
drawLiquidSides(flowing);
|
||||
drawLiquidSides();
|
||||
if (!top_is_same_liquid)
|
||||
drawLiquidTop(flowing);
|
||||
drawLiquidTop();
|
||||
}
|
||||
|
||||
void MapblockMeshGenerator::drawGlasslikeNode()
|
||||
|
@ -1291,8 +1270,7 @@ void MapblockMeshGenerator::drawNode()
|
|||
else
|
||||
light = getInteriorLight(n, 1, nodedef);
|
||||
switch (f->drawtype) {
|
||||
case NDT_LIQUID: drawLiquidNode(false); break;
|
||||
case NDT_FLOWINGLIQUID: drawLiquidNode(true); break;
|
||||
case NDT_FLOWINGLIQUID: drawLiquidNode(); break;
|
||||
case NDT_GLASSLIKE: drawGlasslikeNode(); break;
|
||||
case NDT_GLASSLIKE_FRAMED: drawGlasslikeFramedNode(); break;
|
||||
case NDT_ALLFACES: drawAllfacesNode(); break;
|
||||
|
|
|
@ -93,13 +93,12 @@ public:
|
|||
NeighborData liquid_neighbors[3][3];
|
||||
f32 corner_levels[2][2];
|
||||
|
||||
void prepareLiquidNodeDrawing(bool flowing);
|
||||
void getLiquidNeighborhood(bool flowing);
|
||||
void resetCornerLevels();
|
||||
void prepareLiquidNodeDrawing();
|
||||
void getLiquidNeighborhood();
|
||||
void calculateCornerLevels();
|
||||
f32 getCornerLevel(int i, int k);
|
||||
void drawLiquidSides(bool flowing);
|
||||
void drawLiquidTop(bool flowing);
|
||||
void drawLiquidSides();
|
||||
void drawLiquidTop();
|
||||
|
||||
// raillike-specific
|
||||
// name of the group that enables connecting to raillike nodes of different kind
|
||||
|
@ -122,7 +121,7 @@ public:
|
|||
float offset_h, float offset_v = 0.0);
|
||||
|
||||
// drawtypes
|
||||
void drawLiquidNode(bool flowing);
|
||||
void drawLiquidNode();
|
||||
void drawGlasslikeNode();
|
||||
void drawGlasslikeFramedNode();
|
||||
void drawAllfacesNode();
|
||||
|
|
Loading…
Reference in New Issue