getSignedDistanceField

This commit is contained in:
Azgaar 2021-03-14 14:32:21 +03:00
parent 845f2e99f5
commit 00189f2185
4 changed files with 60 additions and 52 deletions

View file

@ -15,7 +15,6 @@ const generate = function(changeHeights = true) {
cells.conf = new Uint8Array(cells.i.length); // confluences array
let riverNext = 1; // first river id is 1
markupLand();
const h = alterHeights();
removeStoredLakeData();
resolveDepressions(h);
@ -27,16 +26,6 @@ const generate = function(changeHeights = true) {
TIME && console.timeEnd('generateRivers');
// build distance field in cells from water (cells.t)
function markupLand() {
const q = t => cells.i.filter(i => cells.t[i] === t);
for (let t = 2, queue = q(t); queue.length; t++, queue = q(t)) {
queue.forEach(i => cells.c[i].forEach(c => {
if (!cells.t[c]) cells.t[c] = t+1;
}));
}
}
// height with added t value to make map less depressed
function alterHeights() {
const h = Array.from(cells.h)