mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-12-29 12:20:41 +01:00
Add a small random number to DEM when calculating flow direction, to smooth flat areas
This commit is contained in:
parent
8b78f6c5b4
commit
ecba126983
@ -18,11 +18,13 @@ neighbours_dirs = np.array([
|
||||
|
||||
neighbours_pattern = neighbours_dirs > 0
|
||||
|
||||
def flow_dirs_lakes(dem):
|
||||
def flow_dirs_lakes(dem, random=0.0625):
|
||||
(Y, X) = dem.shape
|
||||
|
||||
dem_margin = np.zeros((Y+2, X+2))
|
||||
dem_margin[1:-1,1:-1] = dem
|
||||
if random > 0:
|
||||
dem_margin += np.random.random(dem_margin.shape) * random
|
||||
|
||||
# Initialize: list map borders
|
||||
borders = []
|
||||
@ -72,7 +74,7 @@ def accumulate(dirs, dem=None):
|
||||
(Y, X) = dirs.shape
|
||||
dirs_margin = np.zeros((Y+2,X+2))-1
|
||||
dirs_margin[1:-1,1:-1] = dirs
|
||||
quantity = np.zeros((Y, X), dtype='u4')
|
||||
quantity = np.zeros((Y, X), dtype='i4')
|
||||
|
||||
def calculate_quantity(y, x):
|
||||
if quantity[y,x] > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user