Fixed lakes elevation

There were sometimes missing water patches near a lake's edge, when the neighbour catchment area was lower.
This commit allows to divide a cell into several mini-catchment basins, to fill only a part of it with water.
This commit is contained in:
Gael-de-Sailly 2020-12-22 18:34:30 +01:00
parent 9ffa150263
commit 83728cc932
2 changed files with 20 additions and 2 deletions

View File

@ -99,7 +99,25 @@ local function heightmaps(minp, maxp)
xf, zf
))
local lake_height = math.max(math.floor(poly.lake), terrain_height)
-- Spatial gradient of the interpolation
local slope_x = zf*(vdem[3]-vdem[4]) + (1-zf)*(vdem[2]-vdem[1]) < 0
local slope_z = xf*(vdem[3]-vdem[2]) + (1-xf)*(vdem[4]-vdem[1]) < 0
local lake_id = 0
if slope_x then
if slope_z then
lake_id = 3
else
lake_id = 2
end
else
if slope_z then
lake_id = 4
else
lake_id = 1
end
end
local lake_height = math.max(math.floor(poly.lake[lake_id]), terrain_height)
if imax > 0 and depth_factor_max > 0 then
terrain_height = math.min(math.max(lake_height, sea_level) - math.floor(1+depth_factor_max*riverbed_slope), terrain_height)
end

View File

@ -185,7 +185,7 @@ local function make_polygons(minp, maxp)
local poly_dem = {dem[iA], dem[iB], dem[iC], dem[iD]}
polygon.dem = poly_dem
polygon.lake = math.min(lakes[iA], lakes[iB], lakes[iC], lakes[iD])
polygon.lake = {lakes[iA], lakes[iB], lakes[iC], lakes[iD]}
-- Now, rivers.
-- Load river flux values for the 4 corners