finally getting a handle on the lava.

This commit is contained in:
FaceDeer 2017-04-05 22:40:35 -06:00
parent 18d64da1bd
commit d51e12a05f
3 changed files with 147 additions and 20 deletions

View File

@ -81,24 +81,50 @@ subterrane:register_cave_layer({
minimum_depth = dfcaverns.config.ymax,
maximum_depth = dfcaverns.config.level1_min,
cave_threshold = 0.5,
perlin_cave = perlin_cave,
perlin_wave = perlin_wave,
})
subterrane:register_cave_layer({
minimum_depth = dfcaverns.config.level1_min,
maximum_depth = dfcaverns.config.level2_min,
cave_threshold = 0.5,
perlin_cave = perlin_cave,
perlin_wave = perlin_wave,
})
subterrane:register_cave_layer({
minimum_depth = dfcaverns.config.level2_min,
maximum_depth = dfcaverns.config.level3_min,
cave_threshold = 0.5,
perlin_cave = perlin_cave,
perlin_wave = perlin_wave,
})
local perlin_cave_lava = {
offset = 0,
scale = 1,
spread = {x=dfcaverns.config.horizontal_cavern_scale * 2, y=dfcaverns.config.vertical_cavern_scale * 0.5, z=dfcaverns.config.horizontal_cavern_scale * 2},
seed = -400000000089,
octaves = 3,
persist = 0.67
}
local perlin_wave_lava = {
offset = 0,
scale = 1,
spread = {x=dfcaverns.config.horizontal_cavern_scale * 4, y=dfcaverns.config.vertical_cavern_scale * 0.5, z=dfcaverns.config.horizontal_cavern_scale * 4}, -- squashed 2:1
seed = 59033,
octaves = 6,
persist = 0.63
}
subterrane:register_cave_layer({
minimum_depth = dfcaverns.config.level3_min,
maximum_depth = dfcaverns.config.lava_sea_min,
cave_threshold = 0.1
cave_threshold = 0.2,
perlin_cave = perlin_cave_lava,
perlin_wave = perlin_wave_lava,
})
--subterrane:register_cave_layer({

View File

@ -13,27 +13,55 @@ local c_cavern_fungi = minetest.get_content_id("dfcaverns:cavern_fungi") -- para
-------------------------------------------------------------------------------------------
local subsea_level = (dfcaverns.config.lava_sea_min - dfcaverns.config.level3_min) * 0.3 + dfcaverns.config.level3_min
minetest.debug("level3_min", dfcaverns.config.level3_min)
minetest.debug("lava subsea", subsea_level)
minetest.debug("lava_sea_min", dfcaverns.config.lava_sea_min)
minetest.register_biome({
name = "dfcaverns_lava_sea_lower",
name = "dfcaverns_lava_sea",
y_min = dfcaverns.config.lava_sea_min,
y_max = subsea_level,
heat_point = 50,
humidity_point = 50,
_subterrane_fill_node = c_lava,
_subterrane_cave_fill_node = c_lava,
})
minetest.register_biome({
name = "dfcaverns_lava_sea_upper",
y_min = subsea_level,
y_max = dfcaverns.config.level3_min,
heat_point = 50,
humidity_point = 50,
_subterrane_fill_node = c_air,
_subterrane_cave_fill_node = c_lava,
})
local airspace = 256
local data = {}
minetest.register_on_generated(function(minp, maxp, seed)
--if out of range of cave definition limits, abort
if minp.y > dfcaverns.config.level3_min - airspace or maxp.y < dfcaverns.config.lava_sea_min then
return
end
--easy reference to commonly used values
local t_start = os.clock()
local x_max = maxp.x
local y_max = maxp.y
local z_max = maxp.z
local x_min = minp.x
local y_min = minp.y
local z_min = minp.z
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
vm:get_data(data)
for z = z_min, z_max do -- for each xy plane progressing northwards
--structure loop, hollows out the cavern
for y = y_min, y_max do -- for each x row progressing upwards
local vi = area:index(x_min, y, z) --current node index
for x = x_min, x_max do -- for each node do
if data[vi] == c_air or data[vi] == c_water then
data[vi] = c_lava
end
vi = vi + 1
end
end
end
--send data back to voxelmanip
vm:set_data(data)
--calc lighting
vm:set_lighting({day = 0, night = 0})
vm:calc_lighting()
--write it to world
vm:write_to_map(data)
end)

View File

@ -63,7 +63,7 @@ minetest.register_ore({
column_height_min = 2,
column_height_max = 6,
height_min = -31000,
height_max = 31000,
height_max = 512,
noise_threshold = 0.9,
noise_params = {
offset = 0,
@ -76,3 +76,76 @@ minetest.register_ore({
},
random_factor = 0,
})
local c_air = minetest.get_content_id("air")
local c_snowblock = minetest.get_content_id("default:snowblock")
local c_obsidian = minetest.get_content_id("default:obsidian")
local c_lava = minetest.get_content_id("default:lava_source")
local water_level = minetest.get_mapgen_params().water_level
local is_adjacent_to_air = function(area, data, pos)
return pos.y > water_level and
(data[area:index(pos.x+1, pos.y, pos.z)] == c_air
or data[area:index(pos.x-1, pos.y, pos.z)] == c_air
or data[area:index(pos.x, pos.y, pos.z+1)] == c_air
or data[area:index(pos.x, pos.y, pos.z-1)] == c_air
or data[area:index(pos.x, pos.y-1, pos.z)] == c_air)
end
dfcaverns.remove_unsupported_lava = function(area, data, vi)
if data[vi] == c_lava then
local pos = area:position(vi)
if is_adjacent_to_air(area, data, pos) then
data[vi] = c_air
dfcaverns.remove_unsupported_lava(area, data, area:index(pos.x+1, pos.y, pos.z))
dfcaverns.remove_unsupported_lava(area, data, area:index(pos.x-1, pos.y, pos.z))
dfcaverns.remove_unsupported_lava(area, data, area:index(pos.x, pos.y, pos.z+1))
dfcaverns.remove_unsupported_lava(area, data, area:index(pos.x, pos.y, pos.z-1))
dfcaverns.remove_unsupported_lava(area, data, area:index(pos.x, pos.y+1, pos.z))
end
end
end
local data = {}
minetest.register_on_generated(function(minp, maxp, seed)
--if too far from water level, abort. Caverns are on their own.
if minp.y > 512 or maxp.y < water_level then
return
end
--easy reference to commonly used values
local t_start = os.clock()
local x_max = maxp.x
local y_max = maxp.y
local z_max = maxp.z
local x_min = minp.x
local y_min = minp.y
local z_min = minp.z
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
vm:get_data(data)
for z = z_min, z_max do -- for each xy plane progressing northwards
--structure loop, hollows out the cavern
for y = y_min, y_max do -- for each x row progressing upwards
local vi = area:index(x_min, y, z) --current node index
for x = x_min, x_max do -- for each node do
dfcaverns.remove_unsupported_lava(area, data, vi)
vi = vi + 1
end
end
end
--send data back to voxelmanip
vm:set_data(data)
--calc lighting
vm:set_lighting({day = 0, night = 0})
vm:calc_lighting()
vm:update_liquids()
--write it to world
vm:write_to_map(data)
end)