From 2aac1b51752f09bb5fa40bcde2b9e4d2067b9f6a Mon Sep 17 00:00:00 2001 From: Splizard Date: Wed, 1 Aug 2012 13:47:59 +1200 Subject: [PATCH] Add inkelyad's smooth transitions, add config option for this. --- config.lua | 3 +++ mapgen.lua | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/config.lua b/config.lua index 426b2e1..ca9e467 100644 --- a/config.lua +++ b/config.lua @@ -5,3 +5,6 @@ snow.enable_snowfall = false --Enables debuging. snow.debug = false + +--Enables smooth transition of biomes. +snow.smooth = false diff --git a/mapgen.lua b/mapgen.lua index 2f8cfd9..d0ff868 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -114,6 +114,7 @@ if maxp.y >= -10 then end local make_pine = snow.make_pine + local smooth = snow.smooth --Reseed random. pr = PseudoRandom(seed+68) @@ -132,11 +133,18 @@ if maxp.y >= -10 then local x = x0+i local z = z0+j - --Check if we are in a "Snow biome" - local test = perlin1:get2d({x=x, y=z}) - if test > 0.53 then - - -- Find ground level (0...15) + --Check if we are in a "Snow biome" + local in_biome = false + local test = perlin1:get2d({x=x, y=z}) + if smooth and (test > 0.73 or (test > 0.43 and pr:next(0,29) > (0.73 - test) * 100 )) then + in_biome = true + elseif not smooth and test > 0.53 then + in_biome = true + end + + if in_biome then + + -- Find ground level (0...15) local ground_y = nil for y=maxp.y,minp.y+1,-1 do if env:get_node({x=x,y=y,z=z}).name ~= "air" then