mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
restore river cells of load
This commit is contained in:
parent
a84dff6294
commit
467c9c2a9b
1 changed files with 17 additions and 2 deletions
|
|
@ -710,8 +710,23 @@ function parseLoadedData(data) {
|
|||
if (version < 1.65) {
|
||||
// v 1.65 changed rivers data
|
||||
for (const river of pack.rivers) {
|
||||
river.sourceWidth = 0;
|
||||
// get points and cells
|
||||
const node = document.getElementById("river" + river.i);
|
||||
if (node && !river.cells) {
|
||||
const riverCells = new Set();
|
||||
const length = node.getTotalLength() / 2;
|
||||
const segments = Math.ceil(length / 6);
|
||||
const increment = length / segments;
|
||||
for (let i = increment * segments, c = i; i >= 0; i -= increment, c += increment) {
|
||||
const p1 = node.getPointAtLength(i);
|
||||
const p2 = node.getPointAtLength(c);
|
||||
const x = (p1.x + p2.x) / 2;
|
||||
const y = (p1.y + p2.y) / 2;
|
||||
const cell = findCell(x, y, 6);
|
||||
if (cell) riverCells.add(cell);
|
||||
}
|
||||
|
||||
river.cells = Array.from(riverCells);
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue