Localize get_perlin_map data.

master
Duane Robertson 2017-04-03 01:44:02 -05:00
parent c99b485293
commit 0504712346
2 changed files with 10 additions and 13 deletions

View File

@ -4,8 +4,6 @@
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.
@ -42,16 +40,6 @@ local function generate(p_minp, p_maxp, seed)
local area = VoxelArea:new({MinEdge = emin, MaxEdge = emax})
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
if not underworlds_mod.underzones then
return

View File

@ -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_map
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_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
return
end