diff --git a/README.txt b/README.txt index 570b021..1098524 100644 --- a/README.txt +++ b/README.txt @@ -7,4 +7,5 @@ http://i.imgur.com/pMZYqt9.png TODO: -— finish nether forest +— care about nether torches +— find a way to get the perlin noise inside [-1; 1] or use another noise diff --git a/nether/init.lua b/nether/init.lua index afc92cc..6e4e752 100644 --- a/nether/init.lua +++ b/nether/init.lua @@ -125,6 +125,36 @@ local function table_contains(t, v) return false end +-- Weierstrass function stuff from https://github.com/slemonide/gen +local SIZE = 1000 +local ssize = math.ceil(math.abs(SIZE)) +local function do_ws_func(depth, a, x) + local n = x/(16*SIZE) + local y = 0 + for k=1,depth do + y = y + SIZE*(math.sin(math.pi * k^a * n)/(math.pi * k^a)) + end + return y +end + +local chunksize = minetest.setting_get("chunksize") or 5 +local ws_lists = {} +local function get_ws_list(a,x) + ws_lists[a] = ws_lists[a] or {} + local v = ws_lists[a][x] + if v then + return v + end + v = {} + for x=x,x + (chunksize*16 - 1) do + local y = do_ws_func(ssize, a, x) + v[x] = y + end + ws_lists[a][x] = v + return v +end + + local function dif(z1, z2) if z1 < 0 and z2 < 0 then