mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-16 06:15:06 -05:00
Diagonal liquid animation
This commit is contained in:
parent
4095e8f383
commit
3ee8098708
@ -653,48 +653,36 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||||||
// -Z towards +Z, thus the direction is +Z.
|
// -Z towards +Z, thus the direction is +Z.
|
||||||
// Rotate texture to make animation go in flow direction
|
// Rotate texture to make animation go in flow direction
|
||||||
// Positive if liquid moves towards +Z
|
// Positive if liquid moves towards +Z
|
||||||
int dz = (corner_levels[side_corners[3][0]] +
|
f32 dz = (corner_levels[side_corners[3][0]] +
|
||||||
corner_levels[side_corners[3][1]]) -
|
corner_levels[side_corners[3][1]]) -
|
||||||
(corner_levels[side_corners[2][0]] +
|
(corner_levels[side_corners[2][0]] +
|
||||||
corner_levels[side_corners[2][1]]);
|
corner_levels[side_corners[2][1]]);
|
||||||
// Positive if liquid moves towards +X
|
// Positive if liquid moves towards +X
|
||||||
int dx = (corner_levels[side_corners[1][0]] +
|
f32 dx = (corner_levels[side_corners[1][0]] +
|
||||||
corner_levels[side_corners[1][1]]) -
|
corner_levels[side_corners[1][1]]) -
|
||||||
(corner_levels[side_corners[0][0]] +
|
(corner_levels[side_corners[0][0]] +
|
||||||
corner_levels[side_corners[0][1]]);
|
corner_levels[side_corners[0][1]]);
|
||||||
// -X
|
f32 tcoord_angle = atan2(dz, dx) * core::RADTODEG ;
|
||||||
if(-dx >= abs(dz))
|
v2f tcoord_center(0.5, 0.5);
|
||||||
|
v2f tcoord_translate(
|
||||||
|
blockpos_nodes.Z + z,
|
||||||
|
blockpos_nodes.X + x);
|
||||||
|
tcoord_translate.rotateBy(tcoord_angle);
|
||||||
|
tcoord_translate.X -= floor(tcoord_translate.X);
|
||||||
|
tcoord_translate.Y -= floor(tcoord_translate.Y);
|
||||||
|
|
||||||
|
for(s32 i=0; i<4; i++)
|
||||||
{
|
{
|
||||||
v2f t = vertices[0].TCoords;
|
vertices[i].TCoords.rotateBy(
|
||||||
vertices[0].TCoords = vertices[1].TCoords;
|
tcoord_angle,
|
||||||
vertices[1].TCoords = vertices[2].TCoords;
|
tcoord_center);
|
||||||
vertices[2].TCoords = vertices[3].TCoords;
|
vertices[i].TCoords += tcoord_translate;
|
||||||
vertices[3].TCoords = t;
|
|
||||||
}
|
|
||||||
// +X
|
|
||||||
if(dx >= abs(dz))
|
|
||||||
{
|
|
||||||
v2f t = vertices[0].TCoords;
|
|
||||||
vertices[0].TCoords = vertices[3].TCoords;
|
|
||||||
vertices[3].TCoords = vertices[2].TCoords;
|
|
||||||
vertices[2].TCoords = vertices[1].TCoords;
|
|
||||||
vertices[1].TCoords = t;
|
|
||||||
}
|
|
||||||
// -Z
|
|
||||||
if(-dz >= abs(dx))
|
|
||||||
{
|
|
||||||
v2f t = vertices[0].TCoords;
|
|
||||||
vertices[0].TCoords = vertices[3].TCoords;
|
|
||||||
vertices[3].TCoords = vertices[2].TCoords;
|
|
||||||
vertices[2].TCoords = vertices[1].TCoords;
|
|
||||||
vertices[1].TCoords = t;
|
|
||||||
t = vertices[0].TCoords;
|
|
||||||
vertices[0].TCoords = vertices[3].TCoords;
|
|
||||||
vertices[3].TCoords = vertices[2].TCoords;
|
|
||||||
vertices[2].TCoords = vertices[1].TCoords;
|
|
||||||
vertices[1].TCoords = t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v2f t = vertices[0].TCoords;
|
||||||
|
vertices[0].TCoords = vertices[2].TCoords;
|
||||||
|
vertices[2].TCoords = t;
|
||||||
|
|
||||||
u16 indices[] = {0,1,2,2,3,0};
|
u16 indices[] = {0,1,2,2,3,0};
|
||||||
// Add to mesh collector
|
// Add to mesh collector
|
||||||
collector.append(tile_liquid, vertices, 4, indices, 6);
|
collector.append(tile_liquid, vertices, 4, indices, 6);
|
||||||
|
Loading…
Reference in New Issue
Block a user