mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
detect depressions on river flow and return
This commit is contained in:
parent
05e6cc388e
commit
e7cf6e4f5a
1 changed files with 8 additions and 8 deletions
|
|
@ -6,9 +6,8 @@
|
||||||
const generate = function (allowErosion = true) {
|
const generate = function (allowErosion = true) {
|
||||||
TIME && console.time("generateRivers");
|
TIME && console.time("generateRivers");
|
||||||
Math.random = aleaPRNG(seed);
|
Math.random = aleaPRNG(seed);
|
||||||
const cells = pack.cells,
|
const {cells, features} = pack;
|
||||||
p = cells.p,
|
const p = cells.p;
|
||||||
features = pack.features;
|
|
||||||
|
|
||||||
const riversData = []; // rivers data
|
const riversData = []; // rivers data
|
||||||
cells.fl = new Uint16Array(cells.i.length); // water flux array
|
cells.fl = new Uint16Array(cells.i.length); // water flux array
|
||||||
|
|
@ -93,7 +92,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// downhill cell (make sure it's not in the source lake)
|
// downhill cell (make sure it's not in the source lake)
|
||||||
const min = lakeOutCells[i] ? cells.c[i].filter(c => !lakes.map(lake => lake.i).includes(cells.f[c])).sort((a, b) => h[a] - h[b])[0] : cells.c[i].sort((a, b) => h[a] - h[b])[0];
|
const filtered = lakeOutCells[i] ? cells.c[i].filter(c => !lakes.map(lake => lake.i).includes(cells.f[c])) : cells.c[i];
|
||||||
|
const min = filtered.sort((a, b) => h[a] - h[b])[0];
|
||||||
|
|
||||||
|
// cells is depressed
|
||||||
|
if (h[i] <= h[min]) return;
|
||||||
|
|
||||||
if (cells.fl[i] < MIN_FLUX_TO_FORM_RIVER) {
|
if (cells.fl[i] < MIN_FLUX_TO_FORM_RIVER) {
|
||||||
if (h[min] >= 20) cells.fl[min] += cells.fl[i];
|
if (h[min] >= 20) cells.fl[min] += cells.fl[i];
|
||||||
|
|
@ -244,10 +247,7 @@
|
||||||
prevDepressions = depressions;
|
prevDepressions = depressions;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(iteration);
|
depressions && WARN && console.warn(`Unresolved depressions: ${depressions}. Edit heightmap to fix`);
|
||||||
|
|
||||||
if (!depressions) return;
|
|
||||||
WARN && console.warn(`Unresolved depressions: ${depressions}. Edit heightmap to fix`);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// add more river points on 1/3 and 2/3 of length
|
// add more river points on 1/3 and 2/3 of length
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue