mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2025-02-22 06:50:29 +01:00
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:
parent
9ffa150263
commit
83728cc932
@ -99,7 +99,25 @@ local function heightmaps(minp, maxp)
|
|||||||
xf, zf
|
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
|
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)
|
terrain_height = math.min(math.max(lake_height, sea_level) - math.floor(1+depth_factor_max*riverbed_slope), terrain_height)
|
||||||
end
|
end
|
||||||
|
@ -185,7 +185,7 @@ local function make_polygons(minp, maxp)
|
|||||||
|
|
||||||
local poly_dem = {dem[iA], dem[iB], dem[iC], dem[iD]}
|
local poly_dem = {dem[iA], dem[iB], dem[iC], dem[iD]}
|
||||||
polygon.dem = poly_dem
|
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.
|
-- Now, rivers.
|
||||||
-- Load river flux values for the 4 corners
|
-- Load river flux values for the 4 corners
|
||||||
|
Loading…
x
Reference in New Issue
Block a user