mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
Refactor route merging logic for improved performance
This commit is contained in:
parent
29e7ab0953
commit
4e79e020e8
4 changed files with 91 additions and 57 deletions
|
|
@ -20,7 +20,7 @@ function editRoute(id) {
|
|||
|
||||
updateRouteData();
|
||||
|
||||
drawControlPoints(getRoutePoints(getRoute()));
|
||||
drawControlPoints(getPoints());
|
||||
drawCells();
|
||||
|
||||
$("#routeEditor").dialog({
|
||||
|
|
@ -49,6 +49,17 @@ function editRoute(id) {
|
|||
return route;
|
||||
}
|
||||
|
||||
function getPoints() {
|
||||
const {cells, burgs} = pack;
|
||||
let points = cells.p.map(([x, y], cellId) => {
|
||||
const burgId = cells.burg[cellId];
|
||||
if (burgId) return [burgs[burgId].x, burgs[burgId].y];
|
||||
return [x, y];
|
||||
});
|
||||
|
||||
return getRoutePoints(getRoute(), points);
|
||||
}
|
||||
|
||||
function updateRouteData() {
|
||||
const route = getRoute();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue