forked from Mirrorlandia_minetest/minetest
Store liquid data as dimensionless fractions instead of BS multiplies
This commit is contained in:
parent
43c9647fe5
commit
b8ddde0a96
@ -599,7 +599,7 @@ void MapblockMeshGenerator::getLiquidNeighborhood()
|
|||||||
v3s16 p2 = p + v3s16(u, 0, w);
|
v3s16 p2 = p + v3s16(u, 0, w);
|
||||||
MapNode n2 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p2);
|
MapNode n2 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p2);
|
||||||
neighbor.content = n2.getContent();
|
neighbor.content = n2.getContent();
|
||||||
neighbor.level = -0.5 * BS;
|
neighbor.level = -0.5f;
|
||||||
neighbor.is_same_liquid = false;
|
neighbor.is_same_liquid = false;
|
||||||
neighbor.top_is_same_liquid = false;
|
neighbor.top_is_same_liquid = false;
|
||||||
|
|
||||||
@ -608,7 +608,7 @@ void MapblockMeshGenerator::getLiquidNeighborhood()
|
|||||||
|
|
||||||
if (neighbor.content == c_source) {
|
if (neighbor.content == c_source) {
|
||||||
neighbor.is_same_liquid = true;
|
neighbor.is_same_liquid = true;
|
||||||
neighbor.level = 0.5 * BS;
|
neighbor.level = 0.5f;
|
||||||
} else if (neighbor.content == c_flowing) {
|
} else if (neighbor.content == c_flowing) {
|
||||||
neighbor.is_same_liquid = true;
|
neighbor.is_same_liquid = true;
|
||||||
u8 liquid_level = (n2.param2 & LIQUID_LEVEL_MASK);
|
u8 liquid_level = (n2.param2 & LIQUID_LEVEL_MASK);
|
||||||
@ -616,7 +616,7 @@ void MapblockMeshGenerator::getLiquidNeighborhood()
|
|||||||
liquid_level = 0;
|
liquid_level = 0;
|
||||||
else
|
else
|
||||||
liquid_level -= (LIQUID_LEVEL_MAX + 1 - range);
|
liquid_level -= (LIQUID_LEVEL_MAX + 1 - range);
|
||||||
neighbor.level = (-0.5 + (liquid_level + 0.5) / range) * BS;
|
neighbor.level = (-0.5f + (liquid_level + 0.5f) / range);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check node above neighbor.
|
// Check node above neighbor.
|
||||||
@ -648,11 +648,11 @@ f32 MapblockMeshGenerator::getCornerLevel(int i, int k)
|
|||||||
|
|
||||||
// If top is liquid, draw starting from top of node
|
// If top is liquid, draw starting from top of node
|
||||||
if (neighbor_data.top_is_same_liquid)
|
if (neighbor_data.top_is_same_liquid)
|
||||||
return 0.5 * BS;
|
return 0.5f;
|
||||||
|
|
||||||
// Source always has the full height
|
// Source always has the full height
|
||||||
if (content == c_source)
|
if (content == c_source)
|
||||||
return 0.5 * BS;
|
return 0.5f;
|
||||||
|
|
||||||
// Flowing liquid has level information
|
// Flowing liquid has level information
|
||||||
if (content == c_flowing) {
|
if (content == c_flowing) {
|
||||||
@ -663,7 +663,7 @@ f32 MapblockMeshGenerator::getCornerLevel(int i, int k)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (air_count >= 2)
|
if (air_count >= 2)
|
||||||
return -0.5 * BS + 0.2;
|
return -0.5f + 0.2f / BS;
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
return sum / count;
|
return sum / count;
|
||||||
return 0;
|
return 0;
|
||||||
@ -721,12 +721,12 @@ void MapblockMeshGenerator::drawLiquidSides()
|
|||||||
pos.X = (base.X - 0.5f) * BS;
|
pos.X = (base.X - 0.5f) * BS;
|
||||||
pos.Z = (base.Z - 0.5f) * BS;
|
pos.Z = (base.Z - 0.5f) * BS;
|
||||||
if (vertex.v) {
|
if (vertex.v) {
|
||||||
pos.Y = neighbor.is_same_liquid ? corner_levels[base.Z][base.X] : -0.5f * BS;
|
pos.Y = (neighbor.is_same_liquid ? corner_levels[base.Z][base.X] : -0.5f) * BS;
|
||||||
} else if (top_is_same_liquid) {
|
} else if (top_is_same_liquid) {
|
||||||
pos.Y = 0.5f * BS;
|
pos.Y = 0.5f * BS;
|
||||||
} else {
|
} else {
|
||||||
pos.Y = corner_levels[base.Z][base.X];
|
pos.Y = corner_levels[base.Z][base.X] * BS;
|
||||||
v += (0.5f * BS - corner_levels[base.Z][base.X]) / BS;
|
v += 0.5f - corner_levels[base.Z][base.X];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->m_smooth_lighting)
|
if (data->m_smooth_lighting)
|
||||||
@ -755,7 +755,7 @@ void MapblockMeshGenerator::drawLiquidTop()
|
|||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int u = corner_resolve[i][0];
|
int u = corner_resolve[i][0];
|
||||||
int w = corner_resolve[i][1];
|
int w = corner_resolve[i][1];
|
||||||
vertices[i].Pos.Y += corner_levels[w][u];
|
vertices[i].Pos.Y += corner_levels[w][u] * BS;
|
||||||
if (data->m_smooth_lighting)
|
if (data->m_smooth_lighting)
|
||||||
vertices[i].Color = blendLightColor(vertices[i].Pos);
|
vertices[i].Color = blendLightColor(vertices[i].Pos);
|
||||||
vertices[i].Pos += origin;
|
vertices[i].Pos += origin;
|
||||||
|
Loading…
Reference in New Issue
Block a user