From 314930714b3b44516656672cb99fae262a32d3d2 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Thu, 21 May 2015 17:14:54 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=A6fix=20one=20perlin=20noise=20outside?= =?UTF-8?q?=20[-1;=201]=20problem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.txt | 2 +- nether/init.lua | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index 8c2f490..6a43301 100644 --- a/README.txt +++ b/README.txt @@ -8,4 +8,4 @@ http://i.imgur.com/pMZYqt9.png TODO: — care about nether torches -— find out why the nether forests top is sometimes flat +— find a way to get the perlin noise inside [-1; 1] diff --git a/nether/init.lua b/nether/init.lua index 5dd0862..95134e1 100644 --- a/nether/init.lua +++ b/nether/init.lua @@ -481,8 +481,13 @@ minetest.register_on_generated(function(minp, maxp, seed) if not f_perlins[pstr] then f_perlins[pstr] = math.floor(f_h_min+(math.abs(perlin_f_bottom:get2d({x=p.x, y=p.z})+1))*f_yscale_bottom+0.5) end - f_top = math.floor(f_h_max - (pmap_f_top[count]+1)*f_yscale_top + 0.5) - f_bottom = f_perlins[pstr]+math.random(0,f_bottom_scale-1) + local top_noise = pmap_f_top[count]+1 + if top_noise < 0 then + top_noise = -top_noise/10 + --nether:inform("ERROR: (perlin noise) "..pmap_f_top[count].." is not inside [-1; 1]", 1) + end + f_top = math.floor(f_h_max - top_noise*f_yscale_top + 0.5) + f_bottom = f_perlins[pstr]+pr:next(0,f_bottom_scale-1) is_forest = f_bottom < f_top f_h_dirt = f_bottom-pr:next(0,1) end