Refactor route merging logic for improved performance

This commit is contained in:
Azgaar 2024-05-23 03:33:54 +02:00
parent 29e7ab0953
commit 4e79e020e8
4 changed files with 91 additions and 57 deletions

View file

@ -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();