fix caves generation x2
This commit is contained in:
parent
4c8b082418
commit
79cd2b45b7
@ -3,6 +3,28 @@ local ores = require "base:generation/ores"
|
|||||||
math.randomseed(SEED)
|
math.randomseed(SEED)
|
||||||
ores.load(dir)
|
ores.load(dir)
|
||||||
|
|
||||||
|
local function get_rand(seed, x, y, z)
|
||||||
|
local h = bit.bxor(bit.bor(x * 23729, y % 16786), y * x + seed)
|
||||||
|
h = bit.bxor(h, z * 47917)
|
||||||
|
h = bit.bxor(h, bit.bor(z % 12345, x + y))
|
||||||
|
|
||||||
|
local n = (h % 10000) / 10000.0
|
||||||
|
|
||||||
|
return n
|
||||||
|
end
|
||||||
|
|
||||||
|
local function gen_parameters(size, seed, x, y)
|
||||||
|
local res = {}
|
||||||
|
local rand = 0
|
||||||
|
|
||||||
|
for i=1, size do
|
||||||
|
rand = get_rand(seed, x, y, rand)
|
||||||
|
table.insert(res, rand)
|
||||||
|
end
|
||||||
|
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
function place_structures(x, z, w, d, hmap, chunk_height)
|
function place_structures(x, z, w, d, hmap, chunk_height)
|
||||||
local placements = {}
|
local placements = {}
|
||||||
ores.place(placements, x, z, w, d, SEED, hmap, chunk_height)
|
ores.place(placements, x, z, w, d, SEED, hmap, chunk_height)
|
||||||
@ -11,15 +33,17 @@ end
|
|||||||
|
|
||||||
function place_structures_wide(x, z, w, d, chunk_height)
|
function place_structures_wide(x, z, w, d, chunk_height)
|
||||||
local placements = {}
|
local placements = {}
|
||||||
if math.random() < 0.05 then -- generate caves
|
local rands = gen_parameters(11, SEED, x, z)
|
||||||
local sx = x + math.random() * 10 - 5
|
if rands[1] < 0.05 then -- generate caves
|
||||||
local sy = math.random() * (chunk_height / 4) + 10
|
|
||||||
local sz = z + math.random() * 10 - 5
|
|
||||||
|
|
||||||
local dir = math.random() * math.pi * 2
|
local sx = x + rands[2] * 10 - 5
|
||||||
local dir_inertia = (math.random() - 0.5) * 2
|
local sy = rands[3] * (chunk_height / 4) + 10
|
||||||
|
local sz = z + rands[4] * 10 - 5
|
||||||
|
|
||||||
|
local dir = rands[5] * math.pi * 2
|
||||||
|
local dir_inertia = (rands[6] - 0.5) * 2
|
||||||
local elevation = -3
|
local elevation = -3
|
||||||
local width = math.random() * 3 + 2
|
local width = rands[7] * 3 + 2
|
||||||
|
|
||||||
for i=1,18 do
|
for i=1,18 do
|
||||||
local dx = math.sin(dir) * 10
|
local dx = math.sin(dir) * 10
|
||||||
@ -35,11 +59,11 @@ function place_structures_wide(x, z, w, d, chunk_height)
|
|||||||
sx = ex
|
sx = ex
|
||||||
sy = ey
|
sy = ey
|
||||||
sz = ez
|
sz = ez
|
||||||
|
|
||||||
dir_inertia = dir_inertia * 0.8 +
|
dir_inertia = dir_inertia * 0.8 +
|
||||||
(math.random() - 0.5) * math.pow(math.random(), 2) * 8
|
(rands[8] - 0.5) * math.pow(rands[10], 2) * 8
|
||||||
elevation = elevation * 0.9 +
|
elevation = elevation * 0.9 +
|
||||||
(math.random() - 0.4) * (1.0-math.pow(math.random(), 4)) * 8
|
(rands[9] - 0.4) * (1.0-math.pow(rands[11], 4)) * 8
|
||||||
dir = dir + dir_inertia
|
dir = dir + dir_inertia
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user