1
0
mirror of https://github.com/Splizard/minetest-mod-snow.git synced 2024-12-28 07:30:17 +01:00

this should make ice generation faster

M  src/mapgen_v6.lua
This commit is contained in:
HybridDog 2016-09-14 19:46:44 +02:00
parent 7774eb3f7f
commit 48db038755

View File

@ -197,7 +197,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local sidelen = x1 - x0 + 1 local sidelen = x1 - x0 + 1
local chulens = {x=sidelen, y=sidelen, z=sidelen} local chulens = {x=sidelen, y=sidelen, z=sidelen}
local nvals_default = minetest.get_perlin_map(np_default, chulens):get2dMap_flat{x=x0+150, y=z0+50} local nvals_default = minetest.get_perlin_map(np_default, chulens):get2dMap_flat{x=x0+150, y=z0+50}
local nvals_cold, nvals_ice local nvals_cold, nvals_ice, ndia
-- Choose biomes -- Choose biomes
local pr = PseudoRandom(seed+57) local pr = PseudoRandom(seed+57)
@ -278,9 +278,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
else else
nodes_added = true nodes_added = true
write_to_map = true write_to_map = true
if not nvals_ice then nvals_ice = nvals_ice or minetest.get_perlin_map(np_ice, chulens):get2dMap_flat{x=x0, y=z0}
nvals_ice = minetest.get_perlin_map(np_ice, chulens):get2dMap_flat{x=x0, y=z0}
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
@ -345,27 +343,21 @@ minetest.register_on_generated(function(minp, maxp, seed)
if not icesheet if not icesheet
and not icecave and not icecave
and not icehole then and not icehole then
local nds = { local y = data[node - area.ystride]
data[area:index(x+1, ground_y, z)], local ice = y ~= c.water and y ~= c.ice
data[area:index(x, ground_y, z+1)],
data[area:index(x+1, ground_y, z+1)],
data[area:index(x-1, ground_y, z-1)],
data[area:index(x-1, ground_y, z)],
data[area:index(x, ground_y, z-1)],
}
local ice
if pr:next(1,4) == 1
and (cool or icebergs) then
for i = 1,#nds do
if nds[i] == c.ice then
ice = true
break
end
end
end
if not ice then if not ice then
for i = 1,#nds do ndia = ndia or {
i = nds[i] area.zstride - 1,
1,
-2*area.zstride - 2,
area.zstride,
1 - area.zstride,
0
}
local vi = node + 1
for n = 1,6 do
local i = data[vi]
if i ~= c.water if i ~= c.water
and i ~= c.ice and i ~= c.ice
and i ~= c.air and i ~= c.air
@ -373,11 +365,24 @@ minetest.register_on_generated(function(minp, maxp, seed)
ice = true ice = true
break break
end end
vi = vi + ndia[n]
end
if not ice
and (cool or icebergs)
and pr:next(1,4) == 1 then
local vi = node + 1
for i = 1,6 do
if data[vi] == c.ice then
ice = true
break
end
vi = vi + ndia[i]
end
end end
end end
local y = data[area:index(x, ground_y-1, z)]
if ice if ice
or (y ~= c.water and y ~= c.ice) -- and y ~= "air") …I don't think y can be a string here ~HybridDog
or (icebergs and pr:next(1,6) == 1) then or (icebergs and pr:next(1,6) == 1) then
data[node] = c.ice data[node] = c.ice
end end