mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2025-07-03 08:50:40 +02:00
Compare commits
2 Commits
fix_rivers
...
refactor_s
Author | SHA1 | Date | |
---|---|---|---|
12c3394114 | |||
b374e8ee95 |
@ -1,3 +1,21 @@
|
|||||||
|
local function version_is_lower(v1, v2)
|
||||||
|
local d1, c1, d2, c2
|
||||||
|
while #v1 > 0 and #v2 > 0 do
|
||||||
|
d1, c1, v1 = v1:match("^(%d*)(%D*)(.*)$")
|
||||||
|
d2, c2, v2 = v2:match("^(%d*)(%D*)(.*)$")
|
||||||
|
|
||||||
|
d1 = tonumber(d1) or -1
|
||||||
|
d2 = tonumber(d2) or -1
|
||||||
|
if d1 ~= d2 then
|
||||||
|
return d1 < d2
|
||||||
|
end
|
||||||
|
if c1 ~= c2 then
|
||||||
|
return c1 < c2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local function fix_min_catchment(settings, is_global)
|
local function fix_min_catchment(settings, is_global)
|
||||||
local prefix = is_global and "mapgen_rivers_" or ""
|
local prefix = is_global and "mapgen_rivers_" or ""
|
||||||
|
|
||||||
@ -21,6 +39,18 @@ local function fix_compatibility_minetest(settings)
|
|||||||
if previous_version == "0.0" then
|
if previous_version == "0.0" then
|
||||||
fix_min_catchment(settings, true)
|
fix_min_catchment(settings, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if version_is_lower(previous_version, "1.0.2-dev1") then
|
||||||
|
local blocksize = tonumber(settings:get("mapgen_rivers_blocksize") or 15)
|
||||||
|
local grid_x_size = tonumber(settings:get("mapgen_rivers_grid_x_size"))
|
||||||
|
if grid_x_size then
|
||||||
|
settings:set("mapgen_rivers_map_x_size", tostring(grid_x_size * blocksize))
|
||||||
|
end
|
||||||
|
local grid_z_size = tonumber(settings:get("mapgen_rivers_grid_z_size"))
|
||||||
|
if grid_z_size then
|
||||||
|
settings:set("mapgen_rivers_map_z_size", tostring(grid_z_size * blocksize))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fix_compatibility_mapgen_rivers(settings)
|
local function fix_compatibility_mapgen_rivers(settings)
|
||||||
@ -29,6 +59,18 @@ local function fix_compatibility_mapgen_rivers(settings)
|
|||||||
if previous_version == "0.0" then
|
if previous_version == "0.0" then
|
||||||
fix_min_catchment(settings, false)
|
fix_min_catchment(settings, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if version_is_lower(previous_version, "1.0.2-dev1") then
|
||||||
|
local blocksize = tonumber(settings:get("blocksize") or 15)
|
||||||
|
local grid_x_size = tonumber(settings:get("grid_x_size"))
|
||||||
|
if grid_x_size then
|
||||||
|
settings:set("map_x_size", tostring(grid_x_size * blocksize))
|
||||||
|
end
|
||||||
|
local grid_z_size = tonumber(settings:get("grid_z_size"))
|
||||||
|
if grid_z_size then
|
||||||
|
settings:set("map_z_size", tostring(grid_z_size * blocksize))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return fix_compatibility_minetest, fix_compatibility_mapgen_rivers
|
return fix_compatibility_minetest, fix_compatibility_mapgen_rivers
|
||||||
|
@ -46,57 +46,50 @@ local function heightmaps(minp, maxp)
|
|||||||
-- = 0: on riverbank
|
-- = 0: on riverbank
|
||||||
-- > 0: inside river
|
-- > 0: inside river
|
||||||
local depth_factors = {
|
local depth_factors = {
|
||||||
r_west - xf , -- West edge (1)
|
r_west - xf,
|
||||||
r_north - zf , -- North edge (2)
|
r_north - zf,
|
||||||
r_east - (1-xf), -- East edge (3)
|
xf - r_east,
|
||||||
r_south - (1-zf), -- South edge (4)
|
zf - r_south,
|
||||||
c_NW - xf - zf , -- North-West corner (5)
|
c_NW-xf-zf,
|
||||||
c_NE - (1-xf) - zf , -- North-East corner (6)
|
xf-zf-c_NE,
|
||||||
c_SE - (1-xf) - (1-zf), -- South-East corner (7)
|
xf+zf-c_SE,
|
||||||
c_SW - xf - (1-zf), -- South-West corner (8)
|
zf-xf-c_SW,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Find the maximal depth factor, which determines to which of the 8 river sections (4 edges + 4 corners) the current point belongs.
|
-- Find the maximal depth factor and determine to which river it belongs
|
||||||
-- If imax is still at 0, it means that we are not in a river.
|
local depth_factor_max = 0
|
||||||
local dpmax = 0
|
|
||||||
local imax = 0
|
local imax = 0
|
||||||
for i=1, 8 do
|
for i=1, 8 do
|
||||||
if depth_factors[i] > dpmax then
|
if depth_factors[i] >= depth_factor_max then
|
||||||
dpmax = depth_factors[i]
|
depth_factor_max = depth_factors[i]
|
||||||
imax = i
|
imax = i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Transform the coordinates to have xfc and zfc = 0 or 1 in rivers (to avoid rivers having lateral slope and to accomodate the riverbanks smoothly)
|
-- Transform the coordinates to have xf and zf = 0 or 1 in rivers (to avoid rivers having lateral slope and to accomodate the surrounding smoothly)
|
||||||
local xfc, zfc
|
if imax == 0 then
|
||||||
-- xfc:
|
local x0 = max(r_west, c_NW-zf, zf-c_SW)
|
||||||
if imax == 0 or imax == 2 or imax == 4 then -- river segment does not constrain X coordinate, so accomodate xf in function of other river sections
|
local x1 = min(r_east, c_NE+zf, c_SE-zf)
|
||||||
local x0 = max(r_west-dpmax, c_NW-zf-dpmax, c_SW-(1-zf)-dpmax, 0) -- new xf will be bounded to 0 by western riverbank
|
local z0 = max(r_north, c_NW-xf, xf-c_NE)
|
||||||
local x1 = 1-max(r_east-dpmax, c_NE-zf-dpmax, c_SE-(1-zf)-dpmax, 0) -- and bounded to 1 by eastern riverbank
|
local z1 = min(r_south, c_SW+xf, c_SE-xf)
|
||||||
if x0 >= x1 then
|
xf = (xf-x0) / (x1-x0)
|
||||||
xfc = 0.5
|
zf = (zf-z0) / (z1-z0)
|
||||||
else
|
elseif imax == 1 then
|
||||||
xfc = (xf-x0) / (x1-x0)
|
xf = 0
|
||||||
end
|
elseif imax == 2 then
|
||||||
elseif imax == 1 or imax == 5 or imax == 8 then -- river at the western side of the polygon
|
zf = 0
|
||||||
xfc = 0
|
elseif imax == 3 then
|
||||||
else -- 3, 6, 7 : river at the eastern side of the polygon
|
xf = 1
|
||||||
xfc = 1
|
elseif imax == 4 then
|
||||||
end
|
zf = 1
|
||||||
|
elseif imax == 5 then
|
||||||
-- Same for zfc:
|
xf, zf = 0, 0
|
||||||
if imax == 0 or imax == 1 or imax == 3 then -- river segment does not constrain Z coordinate, so accomodate zf in function of other river sections
|
elseif imax == 6 then
|
||||||
local z0 = max(r_north-dpmax, c_NW-xf-dpmax, c_NE-(1-xf)-dpmax, 0) -- new zf will be bounded to 0 by northern riverbank
|
xf, zf = 1, 0
|
||||||
local z1 = 1-max(r_south-dpmax, c_SW-xf-dpmax, c_SE-(1-xf)-dpmax, 0) -- and bounded to 1 by southern riverbank
|
elseif imax == 7 then
|
||||||
if z0 >= z1 then
|
xf, zf = 1, 1
|
||||||
zfc = 0.5
|
elseif imax == 8 then
|
||||||
else
|
xf, zf = 0, 1
|
||||||
zfc = (zf-z0) / (z1-z0)
|
|
||||||
end
|
|
||||||
elseif imax == 2 or imax == 5 or imax == 6 then -- river at the northern side of the polygon
|
|
||||||
zfc = 0
|
|
||||||
else -- 4, 7, 8 : river at the southern side of the polygon
|
|
||||||
zfc = 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Determine elevation by interpolation
|
-- Determine elevation by interpolation
|
||||||
@ -106,12 +99,12 @@ local function heightmaps(minp, maxp)
|
|||||||
vdem[2],
|
vdem[2],
|
||||||
vdem[3],
|
vdem[3],
|
||||||
vdem[4],
|
vdem[4],
|
||||||
xfc, zfc
|
xf, zf
|
||||||
))
|
))
|
||||||
|
|
||||||
-- Spatial gradient of the interpolation
|
-- Spatial gradient of the interpolation
|
||||||
local slope_x = zfc*(vdem[3]-vdem[4]) + (1-zfc)*(vdem[2]-vdem[1]) < 0
|
local slope_x = zf*(vdem[3]-vdem[4]) + (1-zf)*(vdem[2]-vdem[1]) < 0
|
||||||
local slope_z = xfc*(vdem[3]-vdem[2]) + (1-xfc)*(vdem[4]-vdem[1]) < 0
|
local slope_z = xf*(vdem[3]-vdem[2]) + (1-xf)*(vdem[4]-vdem[1]) < 0
|
||||||
local lake_id = 0
|
local lake_id = 0
|
||||||
if slope_x then
|
if slope_x then
|
||||||
if slope_z then
|
if slope_z then
|
||||||
@ -128,8 +121,8 @@ local function heightmaps(minp, maxp)
|
|||||||
end
|
end
|
||||||
local lake_height = max(floor(poly.lake[lake_id]), terrain_height)
|
local lake_height = max(floor(poly.lake[lake_id]), terrain_height)
|
||||||
|
|
||||||
if imax > 0 and dpmax > 0 then
|
if imax > 0 and depth_factor_max > 0 then
|
||||||
terrain_height = min(max(lake_height, sea_level) - floor(1+dpmax*riverbed_slope), terrain_height)
|
terrain_height = min(max(lake_height, sea_level) - floor(1+depth_factor_max*riverbed_slope), terrain_height)
|
||||||
end
|
end
|
||||||
|
|
||||||
terrain_height_map[i] = terrain_height
|
terrain_height_map[i] = terrain_height
|
||||||
|
1
init.lua
1
init.lua
@ -21,7 +21,6 @@ use_biomes = use_biomes and minetest.global_exists('default') and not use_biomeg
|
|||||||
if use_biomegen_mod then
|
if use_biomegen_mod then
|
||||||
biomegen.set_elevation_chill(elevation_chill)
|
biomegen.set_elevation_chill(elevation_chill)
|
||||||
end
|
end
|
||||||
dofile(modpath .. 'noises.lua')
|
|
||||||
|
|
||||||
local heightmaps = dofile(modpath .. 'heightmap.lua')
|
local heightmaps = dofile(modpath .. 'heightmap.lua')
|
||||||
|
|
||||||
|
80
noises.lua
80
noises.lua
@ -1,80 +0,0 @@
|
|||||||
local def_setting = mapgen_rivers.define_setting
|
|
||||||
|
|
||||||
mapgen_rivers.noise_params = {
|
|
||||||
base = def_setting('np_base', 'noise', {
|
|
||||||
offset = 0,
|
|
||||||
scale = 300,
|
|
||||||
seed = 2469,
|
|
||||||
octaves = 8,
|
|
||||||
spread = {x=2048, y=2048, z=2048},
|
|
||||||
persist = 0.6,
|
|
||||||
lacunarity = 2,
|
|
||||||
flags = "eased",
|
|
||||||
}),
|
|
||||||
|
|
||||||
distort_x = def_setting('np_distort_x', 'noise', {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
seed = -4574,
|
|
||||||
spread = {x=64, y=32, z=64},
|
|
||||||
octaves = 3,
|
|
||||||
persistence = 0.75,
|
|
||||||
lacunarity = 2,
|
|
||||||
}),
|
|
||||||
|
|
||||||
distort_z = def_setting('np_distort_z', 'noise', {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
seed = -7940,
|
|
||||||
spread = {x=64, y=32, z=64},
|
|
||||||
octaves = 3,
|
|
||||||
persistence = 0.75,
|
|
||||||
lacunarity = 2,
|
|
||||||
}),
|
|
||||||
|
|
||||||
distort_amplitude = def_setting('np_distort_amplitude', 'noise', {
|
|
||||||
offset = 0,
|
|
||||||
scale = 10,
|
|
||||||
seed = 676,
|
|
||||||
spread = {x=1024, y=1024, z=1024},
|
|
||||||
octaves = 5,
|
|
||||||
persistence = 0.5,
|
|
||||||
lacunarity = 2,
|
|
||||||
flags = "absvalue",
|
|
||||||
}),
|
|
||||||
|
|
||||||
heat = minetest.get_mapgen_setting_noiseparams('mg_biome_np_heat'),
|
|
||||||
heat_blend = minetest.get_mapgen_setting_noiseparams('mg_biome_np_heat_blend'),
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Convert to number because Minetest API is not able to do it cleanly...
|
|
||||||
for name, np in pairs(mapgen_rivers.noise_params) do
|
|
||||||
for field, value in pairs(np) do
|
|
||||||
if field ~= 'flags' and type(value) == 'string' then
|
|
||||||
np[field] = tonumber(value) or value
|
|
||||||
elseif field == 'spread' then
|
|
||||||
for dir, v in pairs(value) do
|
|
||||||
value[dir] = tonumber(v) or v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local heat = mapgen_rivers.noise_params.heat
|
|
||||||
local base = mapgen_rivers.noise_params.base
|
|
||||||
local settings = mapgen_rivers.settings
|
|
||||||
heat.offset = heat.offset + settings.sea_level * settings.elevation_chill
|
|
||||||
base.spread.x = base.spread.x / settings.blocksize
|
|
||||||
base.spread.y = base.spread.y / settings.blocksize
|
|
||||||
base.spread.z = base.spread.z / settings.blocksize
|
|
||||||
|
|
||||||
for name, np in pairs(mapgen_rivers.noise_params) do
|
|
||||||
local lac = np.lacunarity or 2
|
|
||||||
if lac > 1 then
|
|
||||||
local omax = math.floor(math.log(math.min(np.spread.x, np.spread.y, np.spread.z)) / math.log(lac))+1
|
|
||||||
if np.octaves > omax then
|
|
||||||
minetest.log("warning", "[mapgen_rivers] Noise " .. name .. ": 'octaves' reduced to " .. omax)
|
|
||||||
np.octaves = omax
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
12
polygons.lua
12
polygons.lua
@ -11,8 +11,9 @@ dofile(modpath .. 'load.lua')
|
|||||||
|
|
||||||
mapgen_rivers.grid = {}
|
mapgen_rivers.grid = {}
|
||||||
|
|
||||||
local X = mapgen_rivers.settings.grid_x_size
|
local blocksize = mapgen_rivers.settings.blocksize
|
||||||
local Z = mapgen_rivers.settings.grid_z_size
|
local X = math.floor(mapgen_rivers.settings.map_x_size / blocksize)
|
||||||
|
local Z = math.floor(mapgen_rivers.settings.map_z_size / blocksize)
|
||||||
|
|
||||||
local function offset_converter(o)
|
local function offset_converter(o)
|
||||||
return (o + 0.5) * (1/256)
|
return (o + 0.5) * (1/256)
|
||||||
@ -80,7 +81,6 @@ local function index(x, z)
|
|||||||
return z*X+x+1
|
return z*X+x+1
|
||||||
end
|
end
|
||||||
|
|
||||||
local blocksize = mapgen_rivers.settings.blocksize
|
|
||||||
local min_catchment = mapgen_rivers.settings.min_catchment
|
local min_catchment = mapgen_rivers.settings.min_catchment
|
||||||
local max_catchment = mapgen_rivers.settings.max_catchment
|
local max_catchment = mapgen_rivers.settings.max_catchment
|
||||||
|
|
||||||
@ -236,15 +236,15 @@ local function make_polygons(minp, maxp)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
polygon.river_corners = {riverA, riverB, riverC, riverD}
|
polygon.river_corners = {riverA, 1-riverB, 2-riverC, 1-riverD}
|
||||||
|
|
||||||
-- Flow directions
|
-- Flow directions
|
||||||
local dirA, dirB, dirC, dirD = dirs[iA], dirs[iB], dirs[iC], dirs[iD]
|
local dirA, dirB, dirC, dirD = dirs[iA], dirs[iB], dirs[iC], dirs[iD]
|
||||||
-- Determine the river flux on the edges, by testing dirs values
|
-- Determine the river flux on the edges, by testing dirs values
|
||||||
local river_west = (dirA==1 and riverA or 0) + (dirD==3 and riverD or 0)
|
local river_west = (dirA==1 and riverA or 0) + (dirD==3 and riverD or 0)
|
||||||
local river_north = (dirA==2 and riverA or 0) + (dirB==4 and riverB or 0)
|
local river_north = (dirA==2 and riverA or 0) + (dirB==4 and riverB or 0)
|
||||||
local river_east = (dirB==1 and riverB or 0) + (dirC==3 and riverC or 0)
|
local river_east = 1 - (dirB==1 and riverB or 0) - (dirC==3 and riverC or 0)
|
||||||
local river_south = (dirD==2 and riverD or 0) + (dirC==4 and riverC or 0)
|
local river_south = 1 - (dirD==2 and riverD or 0) - (dirC==4 and riverC or 0)
|
||||||
|
|
||||||
polygon.rivers = {river_west, river_north, river_east, river_south}
|
polygon.rivers = {river_west, river_north, river_east, river_south}
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,7 @@ local blocksize = mapgen_rivers.settings.blocksize
|
|||||||
local tectonic_speed = mapgen_rivers.settings.tectonic_speed
|
local tectonic_speed = mapgen_rivers.settings.tectonic_speed
|
||||||
|
|
||||||
local np_base = table.copy(mapgen_rivers.noise_params.base)
|
local np_base = table.copy(mapgen_rivers.noise_params.base)
|
||||||
|
np_base.spread = vector.divide(np_base.spread, blocksize)
|
||||||
|
|
||||||
local evol_params = mapgen_rivers.settings.evol_params
|
local evol_params = mapgen_rivers.settings.evol_params
|
||||||
|
|
||||||
@ -17,6 +18,10 @@ local function pregenerate(keep_loaded)
|
|||||||
local grid = mapgen_rivers.grid
|
local grid = mapgen_rivers.grid
|
||||||
local size = grid.size
|
local size = grid.size
|
||||||
|
|
||||||
|
if size.x * size.y > 4e6 then
|
||||||
|
minetest.log("warning", "[mapgen_rivers] You are going to generate a very large grid (>4M nodes). If you experience problems, you should increase blocksize or reduce map size.")
|
||||||
|
end
|
||||||
|
|
||||||
local seed = tonumber(minetest.get_mapgen_setting("seed"))
|
local seed = tonumber(minetest.get_mapgen_setting("seed"))
|
||||||
np_base.seed = (np_base.seed or 0) + seed
|
np_base.seed = (np_base.seed or 0) + seed
|
||||||
|
|
||||||
|
80
settings.lua
80
settings.lua
@ -1,7 +1,7 @@
|
|||||||
local mtsettings = minetest.settings
|
local mtsettings = minetest.settings
|
||||||
local mgrsettings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
local mgrsettings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
||||||
|
|
||||||
mapgen_rivers.version = "1.0.2"
|
mapgen_rivers.version = "1.0.2-dev1"
|
||||||
|
|
||||||
local previous_version_mt = mtsettings:get("mapgen_rivers_version") or "0.0"
|
local previous_version_mt = mtsettings:get("mapgen_rivers_version") or "0.0"
|
||||||
local previous_version_mgr = mgrsettings:get("version") or "0.0"
|
local previous_version_mgr = mgrsettings:get("version") or "0.0"
|
||||||
@ -19,13 +19,33 @@ end
|
|||||||
mtsettings:set("mapgen_rivers_version", mapgen_rivers.version)
|
mtsettings:set("mapgen_rivers_version", mapgen_rivers.version)
|
||||||
mgrsettings:set("version", mapgen_rivers.version)
|
mgrsettings:set("version", mapgen_rivers.version)
|
||||||
|
|
||||||
|
local defaults
|
||||||
|
do
|
||||||
|
local f = io.open(mapgen_rivers.modpath .. "/settings_default.json")
|
||||||
|
defaults = minetest.parse_json(f:read("*all"))
|
||||||
|
f:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Convert strings to numbers in noise params because Minetest API is not able to do it cleanly...
|
||||||
|
local function clean_np(np)
|
||||||
|
for field, value in pairs(np) do
|
||||||
|
if field ~= 'flags' and type(value) == 'string' then
|
||||||
|
np[field] = tonumber(value) or value
|
||||||
|
elseif field == 'spread' then
|
||||||
|
for dir, v in pairs(value) do
|
||||||
|
value[dir] = tonumber(v) or v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function mapgen_rivers.define_setting(name, dtype, default)
|
function mapgen_rivers.define_setting(name, dtype, default)
|
||||||
if dtype == "number" or dtype == "string" then
|
if dtype == "number" or dtype == "string" then
|
||||||
local v = mgrsettings:get(name)
|
local v = mgrsettings:get(name)
|
||||||
if v == nil then
|
if v == nil then
|
||||||
v = mtsettings:get('mapgen_rivers_' .. name)
|
v = mtsettings:get('mapgen_rivers_' .. name)
|
||||||
if v == nil then
|
if v == nil then
|
||||||
v = default
|
v = defaults[name]
|
||||||
end
|
end
|
||||||
mgrsettings:set(name, v)
|
mgrsettings:set(name, v)
|
||||||
end
|
end
|
||||||
@ -39,7 +59,7 @@ function mapgen_rivers.define_setting(name, dtype, default)
|
|||||||
if v == nil then
|
if v == nil then
|
||||||
v = mtsettings:get_bool('mapgen_rivers_' .. name)
|
v = mtsettings:get_bool('mapgen_rivers_' .. name)
|
||||||
if v == nil then
|
if v == nil then
|
||||||
v = default
|
v = defaults[name]
|
||||||
end
|
end
|
||||||
mgrsettings:set_bool(name, v)
|
mgrsettings:set_bool(name, v)
|
||||||
end
|
end
|
||||||
@ -49,10 +69,11 @@ function mapgen_rivers.define_setting(name, dtype, default)
|
|||||||
if v == nil then
|
if v == nil then
|
||||||
v = mtsettings:get_np_group('mapgen_rivers_' .. name)
|
v = mtsettings:get_np_group('mapgen_rivers_' .. name)
|
||||||
if v == nil then
|
if v == nil then
|
||||||
v = default
|
v = defaults[name]
|
||||||
end
|
end
|
||||||
mgrsettings:set_np_group(name, v)
|
mgrsettings:set_np_group(name, v)
|
||||||
end
|
end
|
||||||
|
clean_np(v)
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -60,33 +81,46 @@ end
|
|||||||
local def_setting = mapgen_rivers.define_setting
|
local def_setting = mapgen_rivers.define_setting
|
||||||
|
|
||||||
mapgen_rivers.settings = {
|
mapgen_rivers.settings = {
|
||||||
center = def_setting('center', 'bool', true),
|
center = def_setting('center', 'bool'),
|
||||||
blocksize = def_setting('blocksize', 'number', 15),
|
blocksize = def_setting('blocksize', 'number'),
|
||||||
sea_level = tonumber(minetest.get_mapgen_setting('water_level')),
|
sea_level = tonumber(minetest.get_mapgen_setting('water_level')),
|
||||||
min_catchment = def_setting('min_catchment', 'number', 3600),
|
min_catchment = def_setting('min_catchment', 'number'),
|
||||||
river_widening_power = def_setting('river_widening_power', 'number', 0.5),
|
river_widening_power = def_setting('river_widening_power', 'number'),
|
||||||
riverbed_slope = def_setting('riverbed_slope', 'number', 0.4),
|
riverbed_slope = def_setting('riverbed_slope', 'number'),
|
||||||
distort = def_setting('distort', 'bool', true),
|
distort = def_setting('distort', 'bool'),
|
||||||
biomes = def_setting('biomes', 'bool', true),
|
biomes = def_setting('biomes', 'bool'),
|
||||||
glaciers = def_setting('glaciers', 'bool', false),
|
glaciers = def_setting('glaciers', 'bool'),
|
||||||
glacier_factor = def_setting('glacier_factor', 'number', 8),
|
glacier_factor = def_setting('glacier_factor', 'number'),
|
||||||
elevation_chill = def_setting('elevation_chill', 'number', 0.25),
|
elevation_chill = def_setting('elevation_chill', 'number'),
|
||||||
|
|
||||||
grid_x_size = def_setting('grid_x_size', 'number', 1000),
|
map_x_size = def_setting('map_x_size', 'number'),
|
||||||
grid_z_size = def_setting('grid_z_size', 'number', 1000),
|
map_z_size = def_setting('map_z_size', 'number'),
|
||||||
evol_params = {
|
evol_params = {
|
||||||
K = def_setting('river_erosion_coef', 'number', 0.5),
|
K = def_setting('river_erosion_coef', 'number'),
|
||||||
m = def_setting('river_erosion_power', 'number', 0.4),
|
m = def_setting('river_erosion_power', 'number'),
|
||||||
d = def_setting('diffusive_erosion', 'number', 0.5),
|
d = def_setting('diffusive_erosion', 'number'),
|
||||||
compensation_radius = def_setting('compensation_radius', 'number', 50),
|
compensation_radius = def_setting('compensation_radius', 'number'),
|
||||||
},
|
},
|
||||||
tectonic_speed = def_setting('tectonic_speed', 'number', 70),
|
tectonic_speed = def_setting('tectonic_speed', 'number'),
|
||||||
evol_time = def_setting('evol_time', 'number', 10),
|
evol_time = def_setting('evol_time', 'number'),
|
||||||
evol_time_step = def_setting('evol_time_step', 'number', 1),
|
evol_time_step = def_setting('evol_time_step', 'number'),
|
||||||
|
|
||||||
load_all = mtsettings:get_bool('mapgen_rivers_load_all')
|
load_all = mtsettings:get_bool('mapgen_rivers_load_all')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mapgen_rivers.noise_params = {
|
||||||
|
base = def_setting("np_base", "noise"),
|
||||||
|
distort_x = def_setting("np_distort_x", "noise"),
|
||||||
|
distort_z = def_setting("np_distort_z", "noise"),
|
||||||
|
distort_amplitude = def_setting("np_distort_amplitude", "noise"),
|
||||||
|
|
||||||
|
heat = minetest.get_mapgen_setting_noiseparams('mg_biome_np_heat'),
|
||||||
|
heat_blend = minetest.get_mapgen_setting_noiseparams('mg_biome_np_heat_blend'),
|
||||||
|
}
|
||||||
|
|
||||||
|
mapgen_rivers.noise_params.heat.offset = mapgen_rivers.noise_params.heat.offset +
|
||||||
|
mapgen_rivers.settings.sea_level * mapgen_rivers.settings.elevation_chill
|
||||||
|
|
||||||
local function write_settings()
|
local function write_settings()
|
||||||
mgrsettings:write()
|
mgrsettings:write()
|
||||||
end
|
end
|
||||||
|
68
settings_default.json
Normal file
68
settings_default.json
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0.2",
|
||||||
|
|
||||||
|
"center": true,
|
||||||
|
"water_level": 1,
|
||||||
|
"blocksize": 15,
|
||||||
|
"min_catchment": 3600,
|
||||||
|
"river_widening_power": 0.5,
|
||||||
|
"riverbed_slope": 0.4,
|
||||||
|
"distort": true,
|
||||||
|
"biomes": true,
|
||||||
|
"glaciers": false,
|
||||||
|
"glacier_factor": 8,
|
||||||
|
"elevation_chill": 0.25,
|
||||||
|
|
||||||
|
"map_x_size": 15000,
|
||||||
|
"map_z_size": 15000,
|
||||||
|
"river_erosion_coef": 0.5,
|
||||||
|
"river_erosion_power": 0.4,
|
||||||
|
"diffusive_erosion": 0.5,
|
||||||
|
"compensation_radius": 50,
|
||||||
|
"tectonic_speed": 70,
|
||||||
|
"evol_time": 10,
|
||||||
|
"evol_time_step": 1,
|
||||||
|
"load_all": false,
|
||||||
|
|
||||||
|
"np_base": {
|
||||||
|
"offset": 0,
|
||||||
|
"scale": 300,
|
||||||
|
"seed": 2469,
|
||||||
|
"octaves": 8,
|
||||||
|
"spread": {"x": 2048, "y": 2048, "z": 2048},
|
||||||
|
"persist": 0.6,
|
||||||
|
"lacunarity": 2.0,
|
||||||
|
"flags": "eased"
|
||||||
|
},
|
||||||
|
|
||||||
|
"np_distort_x": {
|
||||||
|
"offset": 0,
|
||||||
|
"scale": 1,
|
||||||
|
"seed": -4574,
|
||||||
|
"octaves": 3,
|
||||||
|
"spread": {"x": 64, "y": 32, "z": 64},
|
||||||
|
"persist": 0.75,
|
||||||
|
"lacunarity": 2.0
|
||||||
|
},
|
||||||
|
|
||||||
|
"np_distort_z": {
|
||||||
|
"offset": 0,
|
||||||
|
"scale": 1,
|
||||||
|
"seed": -7940,
|
||||||
|
"octaves": 3,
|
||||||
|
"spread": {"x": 64, "y": 32, "z": 64},
|
||||||
|
"persist": 0.75,
|
||||||
|
"lacunarity": 2.0
|
||||||
|
},
|
||||||
|
|
||||||
|
"np_distort_amplitude": {
|
||||||
|
"offset": 0,
|
||||||
|
"scale": 10,
|
||||||
|
"seed": 676,
|
||||||
|
"octaves": 5,
|
||||||
|
"spread": {"x": 1024, "y": 1024, "z": 1024},
|
||||||
|
"persist": 0.5,
|
||||||
|
"lacunarity": 2.0,
|
||||||
|
"flags": "absvalue"
|
||||||
|
}
|
||||||
|
}
|
@ -3,19 +3,25 @@
|
|||||||
# Whether the map should be centered at x=0, z=0.
|
# Whether the map should be centered at x=0, z=0.
|
||||||
mapgen_rivers_center (Center map) bool true
|
mapgen_rivers_center (Center map) bool true
|
||||||
|
|
||||||
# Represents horizontal map scale. Every cell of the grid will be upscaled to
|
# Every cell of the river grid will represent a square of this size.
|
||||||
# a square of this size.
|
# A lower value will result in more detailed terrain and finer computation
|
||||||
# For example if the grid size is 1000x1000 and block size is 12,
|
# of rivers, but will be slower to generate and use more resources.
|
||||||
# the actual size of the map will be 12000.
|
#
|
||||||
|
# WARNING: Excessively low values may cause crashes at pre-generation, due to
|
||||||
|
# memory issues
|
||||||
mapgen_rivers_blocksize (Block size) float 15.0 2.0 100.0
|
mapgen_rivers_blocksize (Block size) float 15.0 2.0 100.0
|
||||||
|
|
||||||
# X size of the grid being generated
|
# X size of the map being generated
|
||||||
# Actual size of the map is grid_x_size * blocksize
|
#
|
||||||
mapgen_rivers_grid_x_size (Grid X size) int 1000 50 5000
|
# X size of the river grid will be this/blocksize
|
||||||
|
# When increasing, it is recommended to increase blocksize too
|
||||||
|
mapgen_rivers_map_x_size (Map X size) int 15000 500 66000
|
||||||
|
|
||||||
# Z size of the grid being generated
|
# Z size of the map being generated
|
||||||
# Actual size of the map is grid_z_size * blocksize
|
#
|
||||||
mapgen_rivers_grid_z_size (Grid Z size) int 1000 50 5000
|
# Z size of the river grid will be this/blocksize
|
||||||
|
# When increasing, it is recommended to increase blocksize too
|
||||||
|
mapgen_rivers_map_z_size (Map Z size) int 15000 500 66000
|
||||||
|
|
||||||
# Minimal catchment area for a river to be drawn, in square nodes
|
# Minimal catchment area for a river to be drawn, in square nodes
|
||||||
# Lower value means bigger river density
|
# Lower value means bigger river density
|
||||||
|
Reference in New Issue
Block a user