mirror of
https://github.com/minetest/minetest.git
synced 2024-12-03 13:03:45 +01:00
Fix liquid_range
* Prevent graphical glitches on old servers * Fix flowing of liquids with viscosity != 1 and range != 8 * Fix range = 0, no flowing nodes will appear
This commit is contained in:
parent
2bf9abade2
commit
0d35350b69
@ -395,7 +395,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||||||
l = getInteriorLight(n, 0, data);
|
l = getInteriorLight(n, 0, data);
|
||||||
video::SColor c = MapBlock_LightColor(f.alpha, l, decode_light(f.light_source));
|
video::SColor c = MapBlock_LightColor(f.alpha, l, decode_light(f.light_source));
|
||||||
|
|
||||||
u8 range = rangelim(nodedef->get(c_flowing).liquid_range, 0, 8);
|
u8 range = rangelim(nodedef->get(c_flowing).liquid_range, 1, 8);
|
||||||
|
|
||||||
// Neighbor liquid levels (key = relative position)
|
// Neighbor liquid levels (key = relative position)
|
||||||
// Includes current node
|
// Includes current node
|
||||||
@ -429,7 +429,11 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||||||
if(n2.getContent() == c_source)
|
if(n2.getContent() == c_source)
|
||||||
level = (-0.5+node_liquid_level) * BS;
|
level = (-0.5+node_liquid_level) * BS;
|
||||||
else if(n2.getContent() == c_flowing){
|
else if(n2.getContent() == c_flowing){
|
||||||
u8 liquid_level = (n2.param2&LIQUID_LEVEL_MASK) - (LIQUID_LEVEL_MAX+1-range);
|
u8 liquid_level = (n2.param2&LIQUID_LEVEL_MASK);
|
||||||
|
if (liquid_level <= LIQUID_LEVEL_MAX+1-range)
|
||||||
|
liquid_level = 0;
|
||||||
|
else
|
||||||
|
liquid_level -= (LIQUID_LEVEL_MAX+1-range);
|
||||||
level = (-0.5 + ((float)liquid_level+ 0.5) / (float)range * node_liquid_level) * BS;
|
level = (-0.5 + ((float)liquid_level+ 0.5) / (float)range * node_liquid_level) * BS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2136,6 +2136,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
|
|||||||
content_t new_node_content;
|
content_t new_node_content;
|
||||||
s8 new_node_level = -1;
|
s8 new_node_level = -1;
|
||||||
s8 max_node_level = -1;
|
s8 max_node_level = -1;
|
||||||
|
u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
|
||||||
if ((num_sources >= 2 && nodemgr->get(liquid_kind).liquid_renewable) || liquid_type == LIQUID_SOURCE) {
|
if ((num_sources >= 2 && nodemgr->get(liquid_kind).liquid_renewable) || liquid_type == LIQUID_SOURCE) {
|
||||||
// liquid_kind will be set to either the flowing alternative of the node (if it's a liquid)
|
// liquid_kind will be set to either the flowing alternative of the node (if it's a liquid)
|
||||||
// or the flowing alternative of the first of the surrounding sources (if it's air), so
|
// or the flowing alternative of the first of the surrounding sources (if it's air), so
|
||||||
@ -2145,6 +2146,8 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
|
|||||||
// liquid_kind is set properly, see above
|
// liquid_kind is set properly, see above
|
||||||
new_node_content = liquid_kind;
|
new_node_content = liquid_kind;
|
||||||
max_node_level = new_node_level = LIQUID_LEVEL_MAX;
|
max_node_level = new_node_level = LIQUID_LEVEL_MAX;
|
||||||
|
if (new_node_level < (LIQUID_LEVEL_MAX+1-range))
|
||||||
|
new_node_content = CONTENT_AIR;
|
||||||
} else {
|
} else {
|
||||||
// no surrounding sources, so get the maximum level that can flow into this node
|
// no surrounding sources, so get the maximum level that can flow into this node
|
||||||
for (u16 i = 0; i < num_flows; i++) {
|
for (u16 i = 0; i < num_flows; i++) {
|
||||||
@ -2185,8 +2188,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
|
|||||||
} else
|
} else
|
||||||
new_node_level = max_node_level;
|
new_node_level = max_node_level;
|
||||||
|
|
||||||
u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
|
if (max_node_level >= (LIQUID_LEVEL_MAX+1-range))
|
||||||
if (new_node_level >= (LIQUID_LEVEL_MAX+1-range))
|
|
||||||
new_node_content = liquid_kind;
|
new_node_content = liquid_kind;
|
||||||
else
|
else
|
||||||
new_node_content = CONTENT_AIR;
|
new_node_content = CONTENT_AIR;
|
||||||
|
Loading…
Reference in New Issue
Block a user