mirror of
https://github.com/minetest/minetest.git
synced 2024-12-25 07:32:24 +01:00
Fixed liquid mesh generation
This commit is contained in:
parent
ad408f269c
commit
296748d32e
@ -386,8 +386,8 @@ 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)
|
||||||
level = (-0.5 + ((float)n2.param2 + 0.5) / 8.0
|
level = (-0.5 + ((float)(n2.param2&LIQUID_LEVEL_MASK)
|
||||||
* node_liquid_level) * BS;
|
+ 0.5) / 8.0 * node_liquid_level) * BS;
|
||||||
|
|
||||||
// Check node above neighbor.
|
// Check node above neighbor.
|
||||||
// NOTE: This doesn't get executed if neighbor
|
// NOTE: This doesn't get executed if neighbor
|
||||||
@ -404,9 +404,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||||||
neighbor_flags.insert(neighbor_dirs[i], flags);
|
neighbor_flags.insert(neighbor_dirs[i], flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
//float liquid_level = (-0.5 + ((float)n.param2 + 0.5) / 8.0) * BS;
|
|
||||||
//float liquid_level = neighbor_levels[v3s16(0,0,0)];
|
|
||||||
|
|
||||||
// Corner heights (average between four liquids)
|
// Corner heights (average between four liquids)
|
||||||
f32 corner_levels[4];
|
f32 corner_levels[4];
|
||||||
|
|
||||||
@ -421,29 +418,46 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||||||
v3s16 cornerdir = halfdirs[i];
|
v3s16 cornerdir = halfdirs[i];
|
||||||
float cornerlevel = 0;
|
float cornerlevel = 0;
|
||||||
u32 valid_count = 0;
|
u32 valid_count = 0;
|
||||||
|
u32 air_count = 0;
|
||||||
for(u32 j=0; j<4; j++)
|
for(u32 j=0; j<4; j++)
|
||||||
{
|
{
|
||||||
v3s16 neighbordir = cornerdir - halfdirs[j];
|
v3s16 neighbordir = cornerdir - halfdirs[j];
|
||||||
u8 content = neighbor_contents[neighbordir];
|
u8 content = neighbor_contents[neighbordir];
|
||||||
// Special case for source nodes
|
// If top is liquid, draw starting from top of node
|
||||||
if(content == c_source)
|
if(neighbor_flags[neighbordir] &
|
||||||
|
neighborflag_top_is_same_liquid)
|
||||||
|
{
|
||||||
|
cornerlevel = 0.5*BS;
|
||||||
|
valid_count = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Source is always the same height
|
||||||
|
else if(content == c_source)
|
||||||
{
|
{
|
||||||
cornerlevel = (-0.5+node_liquid_level)*BS;
|
cornerlevel = (-0.5+node_liquid_level)*BS;
|
||||||
valid_count = 1;
|
valid_count = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Flowing liquid has level information
|
||||||
else if(content == c_flowing)
|
else if(content == c_flowing)
|
||||||
{
|
{
|
||||||
cornerlevel += neighbor_levels[neighbordir];
|
cornerlevel += neighbor_levels[neighbordir];
|
||||||
valid_count++;
|
valid_count++;
|
||||||
}
|
}
|
||||||
else if(content == CONTENT_AIR)
|
else if(content == CONTENT_AIR)
|
||||||
|
{
|
||||||
|
air_count++;
|
||||||
|
}
|
||||||
|
/*// Air is liquid level 0
|
||||||
|
else if(content == CONTENT_AIR)
|
||||||
{
|
{
|
||||||
cornerlevel += -0.5*BS;
|
cornerlevel += -0.5*BS;
|
||||||
valid_count++;
|
valid_count++;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
if(valid_count > 0)
|
if(air_count >= 2)
|
||||||
|
cornerlevel = -0.5*BS;
|
||||||
|
else if(valid_count > 0)
|
||||||
cornerlevel /= valid_count;
|
cornerlevel /= valid_count;
|
||||||
corner_levels[i] = cornerlevel;
|
corner_levels[i] = cornerlevel;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user