mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-11-13 14:20:20 +01:00
Added margin with a settable width near grid border
Elevation gets closer to -50 when approaching the border
This commit is contained in:
parent
7e155b7076
commit
fabe107336
|
@ -14,6 +14,38 @@ local time_step = mapgen_rivers.settings.evol_time_step
|
|||
local niter = math.ceil(time/time_step)
|
||||
time_step = time / niter
|
||||
|
||||
local use_margin = true
|
||||
local margin_width = 2000 / blocksize
|
||||
local margin_elev = -200
|
||||
|
||||
local function margin(dem, width, elev)
|
||||
local X, Y = dem.X, dem.Y
|
||||
for i=1, width do
|
||||
local c1 = ((i-1)/width) ^ 0.5
|
||||
local c2 = (1-c1) * elev
|
||||
local index = (i-1)*X + 1
|
||||
for x=1, X do
|
||||
dem[index] = dem[index] * c1 + c2
|
||||
index = index + 1
|
||||
end
|
||||
index = i
|
||||
for y=1, Y do
|
||||
dem[index] = dem[index] * c1 + c2
|
||||
index = index + X
|
||||
end
|
||||
index = X*(Y-i) + 1
|
||||
for x=1, X do
|
||||
dem[index] = dem[index] * c1 + c2
|
||||
index = index + 1
|
||||
end
|
||||
index = X-i + 1
|
||||
for y=1, Y do
|
||||
dem[index] = dem[index] * c1 + c2
|
||||
index = index + X
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function pregenerate(keep_loaded)
|
||||
local grid = mapgen_rivers.grid
|
||||
local size = grid.size
|
||||
|
@ -31,6 +63,10 @@ local function pregenerate(keep_loaded)
|
|||
dem.X = size.x
|
||||
dem.Y = size.y
|
||||
|
||||
if use_margin then
|
||||
margin(dem, margin_width, margin_elev)
|
||||
end
|
||||
|
||||
local model = EvolutionModel(evol_params)
|
||||
model.dem = dem
|
||||
local ref_dem = model:define_isostasy(dem)
|
||||
|
@ -46,6 +82,9 @@ local function pregenerate(keep_loaded)
|
|||
if i < niter then
|
||||
if tectonic_step ~= 0 then
|
||||
nobj_base:get_3d_map_flat({x=0, y=tectonic_step*i, z=0}, ref_dem)
|
||||
if use_margin then
|
||||
margin(ref_dem, margin_width, margin_elev)
|
||||
end
|
||||
end
|
||||
model:isostasy()
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user