mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
get back to using vertices
This commit is contained in:
parent
67235bc41e
commit
1cd9069b15
1 changed files with 3 additions and 14 deletions
|
|
@ -32,20 +32,9 @@
|
||||||
|
|
||||||
// get array of land cells aroound lake
|
// get array of land cells aroound lake
|
||||||
const getShoreline = function (lake) {
|
const getShoreline = function (lake) {
|
||||||
const queue = [lake.firstCell];
|
const uniqueCells = new Set();
|
||||||
const used = [queue[0]];
|
lake.vertices.forEach(v => pack.vertices.c[v].forEach(c => pack.cells.h[c] >= 20 && uniqueCells.add(c)));
|
||||||
const landCellsAround = [];
|
lake.shoreline = [...uniqueCells];
|
||||||
while (queue.length) {
|
|
||||||
const q = queue.pop();
|
|
||||||
for (const c of pack.cells.c[q]) {
|
|
||||||
if (used[c]) continue;
|
|
||||||
used[c] = true;
|
|
||||||
if (pack.cells.f[c] === lake.i) queue.push(c);
|
|
||||||
if (pack.cells.h[c] >= 20) landCellsAround.push(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lake.shoreline = landCellsAround;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const cleanupLakeData = function () {
|
const cleanupLakeData = function () {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue