1
0
mirror of https://github.com/Splizard/minetest-mod-snow.git synced 2024-12-28 23:40:17 +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 end
local nbuf_default, nbuf_cold, nbuf_ice
minetest.register_on_generated(function(minp, maxp, seed) minetest.register_on_generated(function(minp, maxp, seed)
local t1 = os.clock() local t1 = os.clock()
@ -209,7 +210,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local pines_tab,pnum = {},1 local pines_tab,pnum = {},1
get_perlins(x1 - x0 + 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 local nvals_cold, nvals_ice, ndia
-- Choose biomes -- Choose biomes
@ -236,9 +237,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local in_biome = false local in_biome = false
local test local test
if nvals_default[ni] < 0.35 then if nvals_default[ni] < 0.35 then
if not nvals_cold then nvals_cold = nvals_cold or perlin_objs.cold:get2dMap_flat({x=x0, y=z0}, nbuf_cold)
nvals_cold = perlin_objs.cold:get2dMap_flat{x=x0, y=z0}
end
test = math.min(nvals_cold[ni], 1) test = math.min(nvals_cold[ni], 1)
if smooth then if smooth then
if test >= smooth_rarity_max if test >= smooth_rarity_max
@ -289,9 +288,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
else else
nodes_added = true if not nvals_ice then
write_to_map = true nvals_ice = perlin_objs.ice:get2dMap_flat({x=x0, y=z0}, nbuf_ice)
nvals_ice = nvals_ice or perlin_objs.ice:get2dMap_flat{x=x0, y=z0}
nodes_added = true
write_to_map = true
end
local icetype = nvals_ice[ni] local icetype = nvals_ice[ni]
local cool = icetype > 0 -- only spawns ice on edge of water local cool = icetype > 0 -- only spawns ice on edge of water
local icebergs = icetype > -0.2 and icetype <= 0 local icebergs = icetype > -0.2 and icetype <= 0