1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Waves generated with Perlin-type noise #8994

This commit is contained in:
Lars Hofhansl 2019-11-19 19:42:52 -08:00
parent b3c245bb46
commit 60bff1e6cb
2 changed files with 64 additions and 7 deletions

View file

@ -795,6 +795,7 @@ static void getTileInfo(
v3s16 &p_corrected,
v3s16 &face_dir_corrected,
u16 *lights,
u8 &waving,
TileSpec &tile
)
{
@ -842,6 +843,7 @@ static void getTileInfo(
getNodeTile(n, p_corrected, face_dir_corrected, data, tile);
const ContentFeatures &f = ndef->get(n);
waving = f.waving;
tile.emissive_light = f.light_source;
// eg. water and glass
@ -876,6 +878,10 @@ static void updateFastFaceRow(
const v3s16 &&face_dir,
std::vector<FastFace> &dest)
{
static thread_local const bool waving_liquids =
g_settings->getBool("enable_shaders") &&
g_settings->getBool("enable_waving_water");
v3s16 p = startpos;
u16 continuous_tiles_count = 1;
@ -884,10 +890,11 @@ static void updateFastFaceRow(
v3s16 p_corrected;
v3s16 face_dir_corrected;
u16 lights[4] = {0, 0, 0, 0};
u8 waving;
TileSpec tile;
getTileInfo(data, p, face_dir,
makes_face, p_corrected, face_dir_corrected,
lights, tile);
lights, waving, tile);
// Unroll this variable which has a significant build cost
TileSpec next_tile;
@ -910,12 +917,15 @@ static void updateFastFaceRow(
getTileInfo(data, p_next, face_dir,
next_makes_face, next_p_corrected,
next_face_dir_corrected, next_lights,
waving,
next_tile);
if (next_makes_face == makes_face
&& next_p_corrected == p_corrected + translate_dir
&& next_face_dir_corrected == face_dir_corrected
&& memcmp(next_lights, lights, ARRLEN(lights) * sizeof(u16)) == 0
// Don't apply fast faces to waving water.
&& (waving != 3 || !waving_liquids)
&& next_tile.isTileable(tile)) {
next_is_different = false;
continuous_tiles_count++;