Localize get_perlin_map data.
parent
c99b485293
commit
0504712346
12
mapgen.lua
12
mapgen.lua
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
|
|
||||||
local DEBUG = false
|
local DEBUG = false
|
||||||
local max_depth = 31000
|
|
||||||
local seed_noise = {offset = 0, scale = 32768, seed = 5202, spread = {x = 80, y = 80, z = 80}, octaves = 2, persist = 0.4, lacunarity = 2}
|
|
||||||
|
|
||||||
|
|
||||||
-- This tables looks up nodes that aren't already stored.
|
-- This tables looks up nodes that aren't already stored.
|
||||||
|
@ -42,16 +40,6 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
|
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
|
||||||
local csize = vector.add(vector.subtract(maxp, minp), 1)
|
local csize = vector.add(vector.subtract(maxp, minp), 1)
|
||||||
|
|
||||||
-- use the same seed (based on perlin noise).
|
|
||||||
do
|
|
||||||
local seed = minetest.get_perlin(seed_noise):get2d({x=minp.x, y=minp.z})
|
|
||||||
if not (seed and type(seed) == 'number') then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
math.randomseed(seed)
|
|
||||||
end
|
|
||||||
|
|
||||||
local write = false
|
local write = false
|
||||||
if not underworlds_mod.underzones then
|
if not underworlds_mod.underzones then
|
||||||
return
|
return
|
||||||
|
|
11
undergen.lua
11
undergen.lua
|
@ -8,6 +8,7 @@ local max_depth = 31000
|
||||||
|
|
||||||
|
|
||||||
local terrain_noise = {offset = 15, scale = 10, seed = 3721, spread = {x = 40, y = 40, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
|
local terrain_noise = {offset = 15, scale = 10, seed = 3721, spread = {x = 40, y = 40, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
|
||||||
|
local terrain_map
|
||||||
|
|
||||||
|
|
||||||
underworlds_mod.undergen = function(minp, maxp, data, p2data, area, node, underzone)
|
underworlds_mod.undergen = function(minp, maxp, data, p2data, area, node, underzone)
|
||||||
|
@ -19,7 +20,15 @@ underworlds_mod.undergen = function(minp, maxp, data, p2data, area, node, underz
|
||||||
local map_max = {x = csize.x, y = csize.y + 2, z = csize.z}
|
local map_max = {x = csize.x, y = csize.y + 2, z = csize.z}
|
||||||
local map_min = {x = minp.x, y = minp.y - 1, z = minp.z}
|
local map_min = {x = minp.x, y = minp.y - 1, z = minp.z}
|
||||||
|
|
||||||
local terrain = minetest.get_perlin_map(terrain_noise, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
if not terrain_map then
|
||||||
|
terrain_map = minetest.get_perlin_map(terrain_noise, {x=csize.x, y=csize.z})
|
||||||
|
|
||||||
|
if not terrain_map then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local terrain = terrain_map:get2dMap_flat({x=minp.x, y=minp.z})
|
||||||
if not terrain then
|
if not terrain then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue