diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-06-16 03:40:45 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-06-16 16:47:28 +0300 |
commit | fd1135c7af46eb2f5b99a11f48bf9f9ae335ea9c (patch) | |
tree | 69fe59e684b1e75e817b5a31cfc9a147c2d0a3da /src/content_mapblock.cpp | |
parent | f0678979b1ed5c70095a48820a8110eb631ed74d (diff) | |
download | minetest-fd1135c7af46eb2f5b99a11f48bf9f9ae335ea9c.tar.gz minetest-fd1135c7af46eb2f5b99a11f48bf9f9ae335ea9c.tar.bz2 minetest-fd1135c7af46eb2f5b99a11f48bf9f9ae335ea9c.zip |
Node texture animation
Diffstat (limited to 'src/content_mapblock.cpp')
-rw-r--r-- | src/content_mapblock.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 7585abb69..9d95e1758 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -471,7 +471,9 @@ void mapblock_mesh_generate_special(MeshMakeData *data, pa_liquid.x0(), pa_liquid.y0()), }; - // This fixes a strange bug + // To get backface culling right, the vertices need to go + // clockwise around the front of the face. And we happened to + // calculate corner levels in exact reverse order. s32 corner_resolve[4] = {3,2,1,0}; for(s32 i=0; i<4; i++) @@ -482,6 +484,52 @@ void mapblock_mesh_generate_special(MeshMakeData *data, vertices[i].Pos.Y += corner_levels[j]; vertices[i].Pos += intToFloat(p, BS); } + + // Default downwards-flowing texture animation goes from + // -Z towards +Z, thus the direction is +Z. + // Rotate texture to make animation go in flow direction + // Positive if liquid moves towards +Z + int dz = (corner_levels[side_corners[2][0]] + + corner_levels[side_corners[2][1]] < + corner_levels[side_corners[3][0]] + + corner_levels[side_corners[3][1]]); + // Positive if liquid moves towards +X + int dx = (corner_levels[side_corners[0][0]] + + corner_levels[side_corners[0][1]] < + corner_levels[side_corners[1][0]] + + corner_levels[side_corners[1][1]]); + // -X + if(-dx >= abs(dz)) + { + v2f t = vertices[0].TCoords; + vertices[0].TCoords = vertices[1].TCoords; + vertices[1].TCoords = vertices[2].TCoords; + vertices[2].TCoords = vertices[3].TCoords; + 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; + } u16 indices[] = {0,1,2,2,3,0}; // Add to mesh collector |