mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-11-13 14:20:20 +01:00
Use standard int instead of uint8, int32, etc.
Much faster with NumPy.
This commit is contained in:
parent
faef1658a9
commit
40098d6be3
|
@ -71,8 +71,8 @@ class EvolutionModel:
|
|||
self.calculate_flow()
|
||||
else:
|
||||
self.lakes = dem
|
||||
self.dirs = np.zeros(dem.shape, dtype='u1')
|
||||
self.rivers = np.zeros(dem.shape, dtype='u4')
|
||||
self.dirs = np.zeros(dem.shape, dtype=int)
|
||||
self.rivers = np.zeros(dem.shape, dtype=int)
|
||||
self.flow_uptodate = False
|
||||
|
||||
def calculate_flow(self):
|
||||
|
|
|
@ -14,7 +14,7 @@ neighbours_dirs = np.array([
|
|||
[0,1,0],
|
||||
[2,0,4],
|
||||
[0,3,0],
|
||||
], dtype='u1')
|
||||
], dtype=int)
|
||||
|
||||
neighbours_pattern = neighbours_dirs > 0
|
||||
|
||||
|
@ -49,7 +49,7 @@ def flow_dirs_lakes(dem, random=0):
|
|||
# Make a binary heap
|
||||
heapq.heapify(borders)
|
||||
|
||||
dirs = np.zeros((Y+2, X+2), dtype='u1')
|
||||
dirs = np.zeros((Y+2, X+2), dtype=int)
|
||||
dirs[-2:,:] = 1 # Border pixels flow outside the map
|
||||
dirs[:,-2:] = 2
|
||||
dirs[ :2,:] = 3
|
||||
|
@ -85,7 +85,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='i4')
|
||||
quantity = np.zeros((Y, X), dtype=int)
|
||||
|
||||
def calculate_quantity(y, x):
|
||||
if quantity[y,x] > 0:
|
||||
|
|
Loading…
Reference in New Issue
Block a user