1
0
mirror of https://github.com/Splizard/minetest-mod-snow.git synced 2024-12-27 15:10:20 +01:00

buffer the perlin values

M  src/mapgen_v6.lua
This commit is contained in:
HybridDog 2016-09-17 22:03:53 +02:00
parent bf113a15ff
commit da6a4b3361

View File

@ -186,6 +186,7 @@ local function get_perlins(sidelen)
}
end
local nbuf_default, nbuf_cold, nbuf_ice
minetest.register_on_generated(function(minp, maxp, seed)
local t1 = os.clock()
@ -209,7 +210,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local pines_tab,pnum = {},1
get_perlins(x1 - x0 + 1)
local nvals_default = perlin_objs.default:get2dMap_flat{x=x0+150, y=z0+50}
local nvals_default = perlin_objs.default:get2dMap_flat({x=x0+150, y=z0+50}, nbuf_default)
local nvals_cold, nvals_ice, ndia
-- Choose biomes
@ -236,9 +237,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local in_biome = false
local test
if nvals_default[ni] < 0.35 then
if not nvals_cold then
nvals_cold = perlin_objs.cold:get2dMap_flat{x=x0, y=z0}
end
nvals_cold = nvals_cold or perlin_objs.cold:get2dMap_flat({x=x0, y=z0}, nbuf_cold)
test = math.min(nvals_cold[ni], 1)
if smooth then
if test >= smooth_rarity_max
@ -289,9 +288,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
else
nodes_added = true
write_to_map = true
nvals_ice = nvals_ice or perlin_objs.ice:get2dMap_flat{x=x0, y=z0}
if not nvals_ice then
nvals_ice = perlin_objs.ice:get2dMap_flat({x=x0, y=z0}, nbuf_ice)
nodes_added = true
write_to_map = true
end
local icetype = nvals_ice[ni]
local cool = icetype > 0 -- only spawns ice on edge of water
local icebergs = icetype > -0.2 and icetype <= 0