Remove everything except the caves.
This commit is contained in:
parent
e5e7475476
commit
6cb7f1da1d
205 changed files with 1251 additions and 15326 deletions
117
cavegen.lua
117
cavegen.lua
|
@ -1,120 +1,48 @@
|
|||
fun_caves.cave_width = 0.05 -- figurative width
|
||||
-- Fun_Caves cavegen.lua
|
||||
-- Copyright Duane Robertson (duane@duanerobertson.com), 2017
|
||||
-- Distributed under the LGPLv2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
|
||||
|
||||
|
||||
fun_caves_mod.cave_width = 0.05 -- figurative width
|
||||
local max_depth = 31000
|
||||
|
||||
|
||||
fun_caves.cave_noise_1 = {offset = 0, scale = 1, seed = 3901, spread = {x = 40, y = 10, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
|
||||
fun_caves.cave_noise_2 = {offset = 0, scale = 1, seed = -8402, spread = {x = 40, y = 20, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
|
||||
fun_caves_mod.cave_noise_1 = {offset = 0, scale = 1, seed = 3901, spread = {x = 40, y = 10, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
|
||||
fun_caves_mod.cave_noise_2 = {offset = 0, scale = 1, seed = -8402, spread = {x = 40, y = 20, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
|
||||
local cave_noise_3 = {offset = 15, scale = 10, seed = 3721, spread = {x = 40, y = 40, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
|
||||
|
||||
|
||||
fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone, ground_nodes)
|
||||
if not (minp and maxp and data and area and node and type(data) == 'table' and fun_caves.underzones) then
|
||||
fun_caves_mod.cavegen = function(minp, maxp, data, area, node, heightmap)
|
||||
if not (minp and maxp and data and area and node and type(data) == 'table') then
|
||||
return
|
||||
end
|
||||
|
||||
local csize = vector.add(vector.subtract(maxp, minp), 1)
|
||||
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 return_heightmap = false
|
||||
|
||||
local cave_1 = minetest.get_perlin_map(fun_caves.cave_noise_1, map_max):get3dMap_flat(map_min)
|
||||
local cave_2 = minetest.get_perlin_map(fun_caves.cave_noise_2, map_max):get3dMap_flat(map_min)
|
||||
local cave_3 = minetest.get_perlin_map(cave_noise_3, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
||||
local cave_1, cave_2, cave_3
|
||||
cave_1 = minetest.get_perlin_map(fun_caves_mod.cave_noise_1, map_max):get3dMap_flat(map_min)
|
||||
cave_2 = minetest.get_perlin_map(fun_caves_mod.cave_noise_2, map_max):get3dMap_flat(map_min)
|
||||
cave_3 = minetest.get_perlin_map(cave_noise_3, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
||||
|
||||
if not (cave_1 and cave_2 and cave_3) then
|
||||
return
|
||||
end
|
||||
|
||||
local write = false
|
||||
|
||||
local index = 0
|
||||
local crater
|
||||
if not underzone and math.random(10) == 1 then
|
||||
crater = {
|
||||
x = minp.x + math.random(math.floor(csize.x / 2)) + math.floor(csize.x / 4),
|
||||
y = 15,
|
||||
z = minp.z + math.random(math.floor(csize.z / 2)) + math.floor(csize.z / 4),
|
||||
}
|
||||
end
|
||||
|
||||
local crater_min = 33000
|
||||
for z = minp.z, maxp.z do
|
||||
for x = minp.x, maxp.x do
|
||||
index = index + 1
|
||||
|
||||
local height = heightmap[index]
|
||||
if crater then
|
||||
local dist = crater.y - math.sqrt((x - crater.x) ^ 2 + (z - crater.z) ^ 2)
|
||||
if dist > 0 and (height > maxp.y - 20 or height < minp.y + crater.y) then
|
||||
crater = nil
|
||||
end
|
||||
if crater and dist > 0 and dist <= 1 and crater_min > height then
|
||||
crater_min = height
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
index = 0
|
||||
local index3d = 0
|
||||
local cave_width = fun_caves.cave_width
|
||||
local styx_sea_level = fun_caves.underzones['Styx'].sealevel
|
||||
local cave_width = fun_caves_mod.cave_width
|
||||
local write
|
||||
for z = minp.z, maxp.z do
|
||||
for x = minp.x, maxp.x do
|
||||
index = index + 1
|
||||
index3d = (z - minp.z) * (csize.y + 2) * csize.x + (x - minp.x) + 1
|
||||
local ivm = area:index(x, minp.y-1, z)
|
||||
|
||||
local ivm = area:index(x, minp.y, z)
|
||||
local height = heightmap[index]
|
||||
|
||||
local column = 0
|
||||
if underzone then
|
||||
if cave_3[index] < 30 then
|
||||
column = 1
|
||||
elseif cave_3[index] < 35 then
|
||||
column = 2
|
||||
end
|
||||
end
|
||||
|
||||
local dist
|
||||
if crater then
|
||||
dist = crater.y - math.sqrt((x - crater.x) ^ 2 + (z - crater.z) ^ 2)
|
||||
end
|
||||
|
||||
for y = minp.y-1, maxp.y+1 do
|
||||
if crater and dist and dist > 0 then
|
||||
if y > crater_min - 1.5 * dist and y < maxp.y - 1.5 * dist then
|
||||
data[ivm] = data[ivm + (math.floor((height - crater_min) * dist / crater.y) + math.ceil(dist / 2)) * area.ystride]
|
||||
end
|
||||
if y > crater_min - dist and ground_nodes[data[ivm]] and math.random(300) == 1 then
|
||||
data[ivm] = node['fun_caves:stone_with_meteoritic_iron']
|
||||
end
|
||||
end
|
||||
|
||||
if underzone and underzone.regular_columns and (x - minp.x) < 8 and (z - minp.z) < 8 then
|
||||
data[ivm] = node[underzone.column_node]
|
||||
write = true
|
||||
elseif underzone and underzone.column_node and not underzone.regular_columns and column == 2 then
|
||||
if underzone.column_node_rare and math.random(70) == 1 then
|
||||
data[ivm] = node[underzone.column_node_rare]
|
||||
else
|
||||
data[ivm] = node[underzone.column_node]
|
||||
end
|
||||
write = true
|
||||
elseif underzone and (y < underzone.ceiling - (underzone.vary and cave_3[index] or 0) and y > underzone.floor + (underzone.vary and cave_3[index] or 0)) then
|
||||
if underzone.sealevel and y <= underzone.sealevel then
|
||||
data[ivm] = node["default:water_source"]
|
||||
else
|
||||
data[ivm] = node["air"]
|
||||
end
|
||||
write = true
|
||||
elseif underzone and (y < underzone.ceiling + 10 - (underzone.vary and cave_3[index] or 0) and y > underzone.floor - 10 + (underzone.vary and cave_3[index] or 0)) then
|
||||
-- nop
|
||||
elseif ((y <= maxp.y and y >= minp.y) or (data[ivm] == node['default:stone'])) and y < height - cave_3[index] and cave_1[index3d] * cave_2[index3d] > cave_width then
|
||||
if y <= styx_sea_level then
|
||||
data[ivm] = node["default:water_source"]
|
||||
else
|
||||
data[ivm] = node["air"]
|
||||
end
|
||||
for y = minp.y, maxp.y do
|
||||
if ((y <= maxp.y and y >= minp.y) or (data[ivm] == node['default:stone'])) and y < height - cave_3[index] and cave_1[index3d] * cave_2[index3d] > cave_width then
|
||||
data[ivm] = node["air"]
|
||||
write = true
|
||||
if y > 0 and cave_3[index] < 1 and y == height then
|
||||
-- Clear the air above a cave mouth.
|
||||
|
@ -134,6 +62,5 @@ fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone,
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
return write
|
||||
return write
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue