mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-23 23:57:23 +01:00
refactor: replace deepCopy with structuredClone
This commit is contained in:
parent
7a49098425
commit
1116cc5e0f
9 changed files with 123 additions and 142 deletions
|
|
@ -57,7 +57,8 @@ window.Submap = (function () {
|
|||
const oldGrid = parentMap.grid;
|
||||
// build cache old -> [newcelllist]
|
||||
const forwardGridMap = parentMap.grid.points.map(_ => []);
|
||||
resampler(grid.points, parentMap.pack.cells.q, (id, oldid) => {
|
||||
const parentPackQ = d3.quadtree(parentMap.pack.cells.p.map(([x, y], i) => [x, y, i]));
|
||||
resampler(grid.points, parentPackQ, (id, oldid) => {
|
||||
const cid = parentMap.pack.cells.g[oldid];
|
||||
grid.cells.h[id] = oldGrid.cells.h[cid];
|
||||
grid.cells.temp[id] = oldGrid.cells.temp[cid];
|
||||
|
|
@ -154,7 +155,7 @@ window.Submap = (function () {
|
|||
// find replacement: closest water cell
|
||||
const [ox, oy] = cells.p[id];
|
||||
const [tx, ty] = inverse(x, y);
|
||||
oldid = oldCells.q.find(tx, ty, Infinity)[2];
|
||||
oldid = d3.quadtree(oldCells.p.map(([px, py], i) => [px, py, i])).find(tx, ty, Infinity)[2];
|
||||
if (!oldid) {
|
||||
console.warn("Warning, no id found in quad", id, "parent", gridCellId);
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue