fix smooth transitions

This commit is contained in:
HybridDog 2014-05-12 20:05:55 +02:00
parent 18eadc282a
commit 33357399bd
2 changed files with 17 additions and 14 deletions

View File

@ -55,12 +55,13 @@ end
local riesenpilz_rarity = riesenpilz.mapgen_rarity local riesenpilz_rarity = riesenpilz.mapgen_rarity
local riesenpilz_size = riesenpilz.mapgen_size local riesenpilz_size = riesenpilz.mapgen_size
local smooth_trans_size = riesenpilz.smooth_trans_size
local nosmooth_rarity = -(riesenpilz_rarity/50)+1 local nosmooth_rarity = 1-riesenpilz_rarity/50
local perlin_scale = riesenpilz_size*100/riesenpilz_rarity local perlin_scale = riesenpilz_size*100/riesenpilz_rarity
local smooth_rarity_full = nosmooth_rarity+perlin_scale/(20*riesenpilz_size) local smooth_rarity_max = nosmooth_rarity+smooth_trans_size*2/perlin_scale
local smooth_rarity_ran = nosmooth_rarity-perlin_scale/(40*riesenpilz_size) local smooth_rarity_min = nosmooth_rarity-smooth_trans_size/perlin_scale
local smooth_rarity_dif = (smooth_rarity_full-smooth_rarity_ran)*100-1 local smooth_rarity_dif = smooth_rarity_max-smooth_rarity_min
local GROUND = {c_gr, c_sand, c_dirt, c_desert_sand} local GROUND = {c_gr, c_sand, c_dirt, c_desert_sand}
--local USUAL_STUFF = {"default:leaves","default:apple","default:tree","default:cactus","default:papyrus"} --local USUAL_STUFF = {"default:leaves","default:apple","default:tree","default:cactus","default:papyrus"}
@ -132,15 +133,14 @@ minetest.register_on_generated(function(minp, maxp, seed)
--smooth mapgen --smooth mapgen
if riesenpilz.always_generate then if riesenpilz.always_generate then
in_biome = true in_biome = true
elseif smooth elseif smooth then
and ( if test >= smooth_rarity_max
test > smooth_rarity_full
or ( or (
test > smooth_rarity_ran test > smooth_rarity_min
and pr:next(0,smooth_rarity_dif) > (smooth_rarity_full - test) * 100 and pr:next(1, 1000) <= ((test-smooth_rarity_min)/smooth_rarity_dif)*1000
)
) then ) then
in_biome = true in_biome = true
end
elseif (not smooth) elseif (not smooth)
and test > nosmooth_rarity then and test > nosmooth_rarity then
in_biome = true in_biome = true
@ -271,7 +271,7 @@ end)
and not (perlin1:get2d({x=x0+((x1-x0)/2), y=z1}) > 0.53) --left middle and not (perlin1:get2d({x=x0+((x1-x0)/2), y=z1}) > 0.53) --left middle
and not (perlin1:get2d({x=(x1-x0)/2, y=(z1-z0)/2}) > 0.53) --middle and not (perlin1:get2d({x=(x1-x0)/2, y=(z1-z0)/2}) > 0.53) --middle
and not (perlin1:get2d({x=x0, y=z1+((z1-z0)/2)}) > 0.53) then --bottom middle and not (perlin1:get2d({x=x0, y=z1+((z1-z0)/2)}) > 0.53) then --bottom middle
print("abortsumpf") print("abortriesenpilz")
return return
end end
local divs = (maxp.x-minp.x); local divs = (maxp.x-minp.x);

View File

@ -6,7 +6,7 @@ riesenpilz.enable_mapgen = true
riesenpilz.always_generate = false riesenpilz.always_generate = false
--Enables smooth transition of biomes. --Enables smooth transition of biomes.
riesenpilz.smooth = false riesenpilz.smooth = true
--rarity in % --rarity in %
riesenpilz.mapgen_rarity = 0.1 riesenpilz.mapgen_rarity = 0.1
@ -14,5 +14,8 @@ riesenpilz.mapgen_rarity = 0.1
--size of the generated... (has an effect to the rarity, too) --size of the generated... (has an effect to the rarity, too)
riesenpilz.mapgen_size = 50 riesenpilz.mapgen_size = 50
--approximate size of smooth transitions
riesenpilz.smooth_trans_size = 2
riesenpilz.info = true riesenpilz.info = true