mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
Urquhart routes (#1072)
* feat: routes generation * feat: routes rendering * feat: searoutes fix, changing reGraph * feat: searoute - change pathfinding algo * feat: routes - cleanup code * feat: routes - change data format * feat: routes - add routes to json export * feat: edit routes - start * feat: edit routes - main * feat: edit routes - EP * feat: edit routes - remove route * feat: route - generate names * feat: route - continue * Refactor route merging logic for improved performance * feat: routes - show name in tooltip * feat: routes - create route dialog * feat: update data on control point remove * feat: routes editor - split route * feat: add join route functionality to routes editor * feat: Add join route functionality to routes editor * feat: Update join route tooltip in routes editor * feat: routes overview - sort by length * feat: routes overview - fix distanceScale value * feat: routes overview - create route * Refactor getMiddlePoint function to getCloseToEdgePoint * feat: routes - change data format, fix issues * feat: routes - regenerateRoutes * feat: routes - add route on burg creation * chore - remove merge conflict markers * chore - remove merge conflict markers * feat: routes name - no unnamed burg names * feat: routes - lock routes * fix: routes - split routes * feat: routes - tip correction * feat: routes - auto-update part 1 * feat: routes - return old rePacj logic to not break auto-update * feat: routes - auto-update - add connections --------- Co-authored-by: Azgaar <azgaar.fmg@yandex.com>
This commit is contained in:
parent
c6dd331eb6
commit
f19b891421
47 changed files with 2462 additions and 1032 deletions
|
|
@ -860,4 +860,59 @@ export function resolveVersionConflicts(version) {
|
|||
shiftCompass();
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 1.99) {
|
||||
// v1.99.00 changed routes generation algorithm and data format
|
||||
delete cells.road;
|
||||
delete cells.crossroad;
|
||||
|
||||
pack.routes = [];
|
||||
const POINT_DISTANCE = grid.spacing * 0.75;
|
||||
|
||||
routes.selectAll("g").each(function () {
|
||||
const group = this.id;
|
||||
if (!group) return;
|
||||
|
||||
for (const node of this.querySelectorAll("path")) {
|
||||
const totalLength = node.getTotalLength();
|
||||
if (!totalLength) debugger;
|
||||
const increment = totalLength / Math.ceil(totalLength / POINT_DISTANCE);
|
||||
const points = [];
|
||||
|
||||
for (let i = 0; i <= totalLength + 0.1; i += increment) {
|
||||
const point = node.getPointAtLength(i);
|
||||
const x = rn(point.x, 2);
|
||||
const y = rn(point.y, 2);
|
||||
const cellId = findCell(x, y);
|
||||
points.push([x, y, cellId]);
|
||||
}
|
||||
|
||||
if (points.length < 2) return;
|
||||
|
||||
const secondCellId = points[1][2];
|
||||
const feature = pack.cells.f[secondCellId];
|
||||
|
||||
pack.routes.push({i: pack.routes.length, group, feature, points});
|
||||
}
|
||||
});
|
||||
|
||||
routes.selectAll("path").remove();
|
||||
if (layerIsOn("toggleRoutes")) drawRoutes();
|
||||
|
||||
const links = (pack.cells.routes = {});
|
||||
for (const route of pack.routes) {
|
||||
for (let i = 0; i < route.points.length - 1; i++) {
|
||||
const cellId = route.points[i][2];
|
||||
const nextCellId = route.points[i + 1][2];
|
||||
|
||||
if (cellId !== nextCellId) {
|
||||
if (!links[cellId]) links[cellId] = {};
|
||||
links[cellId][nextCellId] = route.i;
|
||||
|
||||
if (!links[nextCellId]) links[nextCellId] = {};
|
||||
links[nextCellId][cellId] = route.i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -966,7 +966,7 @@ function dragStateBrush() {
|
|||
const p = d3.mouse(this);
|
||||
moveCircle(p[0], p[1], r);
|
||||
|
||||
const found = r > 5 ? findAll(p[0], p[1], r) : [findCell(p[0], p[1], r)];
|
||||
const found = r > 5 ? findAll(p[0], p[1], r) : [findCell(p[0], p[1])];
|
||||
const selection = found.filter(isLand);
|
||||
if (selection) changeStateForSelection(selection);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ function getMinimalDataJson() {
|
|||
provinces: pack.provinces,
|
||||
religions: pack.religions,
|
||||
rivers: pack.rivers,
|
||||
markers: pack.markers
|
||||
markers: pack.markers,
|
||||
routes: pack.routes
|
||||
};
|
||||
return JSON.stringify({info, settings, mapCoordinates, pack: packData, biomesData, notes, nameBases});
|
||||
}
|
||||
|
|
@ -85,7 +86,7 @@ function getMapInfo() {
|
|||
function getSettings() {
|
||||
return {
|
||||
distanceUnit: distanceUnitInput.value,
|
||||
distanceScale: distanceScaleInput.value,
|
||||
distanceScale,
|
||||
areaUnit: areaUnit.value,
|
||||
heightUnit: heightUnit.value,
|
||||
heightExponent: heightExponentInput.value,
|
||||
|
|
@ -106,7 +107,7 @@ function getSettings() {
|
|||
}
|
||||
|
||||
function getPackCellsData() {
|
||||
const dataArrays = {
|
||||
const data = {
|
||||
v: pack.cells.v,
|
||||
c: pack.cells.c,
|
||||
p: pack.cells.p,
|
||||
|
|
@ -125,8 +126,7 @@ function getPackCellsData() {
|
|||
pop: Array.from(pack.cells.pop),
|
||||
culture: Array.from(pack.cells.culture),
|
||||
burg: Array.from(pack.cells.burg),
|
||||
road: Array.from(pack.cells.road),
|
||||
crossroad: Array.from(pack.cells.crossroad),
|
||||
routes: pack.cells.routes,
|
||||
state: Array.from(pack.cells.state),
|
||||
religion: Array.from(pack.cells.religion),
|
||||
province: Array.from(pack.cells.province)
|
||||
|
|
@ -135,29 +135,28 @@ function getPackCellsData() {
|
|||
return {
|
||||
cells: Array.from(pack.cells.i).map(cellId => ({
|
||||
i: cellId,
|
||||
v: dataArrays.v[cellId],
|
||||
c: dataArrays.c[cellId],
|
||||
p: dataArrays.p[cellId],
|
||||
g: dataArrays.g[cellId],
|
||||
h: dataArrays.h[cellId],
|
||||
area: dataArrays.area[cellId],
|
||||
f: dataArrays.f[cellId],
|
||||
t: dataArrays.t[cellId],
|
||||
haven: dataArrays.haven[cellId],
|
||||
harbor: dataArrays.harbor[cellId],
|
||||
fl: dataArrays.fl[cellId],
|
||||
r: dataArrays.r[cellId],
|
||||
conf: dataArrays.conf[cellId],
|
||||
biome: dataArrays.biome[cellId],
|
||||
s: dataArrays.s[cellId],
|
||||
pop: dataArrays.pop[cellId],
|
||||
culture: dataArrays.culture[cellId],
|
||||
burg: dataArrays.burg[cellId],
|
||||
road: dataArrays.road[cellId],
|
||||
crossroad: dataArrays.crossroad[cellId],
|
||||
state: dataArrays.state[cellId],
|
||||
religion: dataArrays.religion[cellId],
|
||||
province: dataArrays.province[cellId]
|
||||
v: data.v[cellId],
|
||||
c: data.c[cellId],
|
||||
p: data.p[cellId],
|
||||
g: data.g[cellId],
|
||||
h: data.h[cellId],
|
||||
area: data.area[cellId],
|
||||
f: data.f[cellId],
|
||||
t: data.t[cellId],
|
||||
haven: data.haven[cellId],
|
||||
harbor: data.harbor[cellId],
|
||||
fl: data.fl[cellId],
|
||||
r: data.r[cellId],
|
||||
conf: data.conf[cellId],
|
||||
biome: data.biome[cellId],
|
||||
s: data.s[cellId],
|
||||
pop: data.pop[cellId],
|
||||
culture: data.culture[cellId],
|
||||
burg: data.burg[cellId],
|
||||
routes: data.routes[cellId],
|
||||
state: data.state[cellId],
|
||||
religion: data.religion[cellId],
|
||||
province: data.province[cellId]
|
||||
})),
|
||||
vertices: Array.from(pack.vertices.p).map((_, vertexId) => ({
|
||||
i: vertexId,
|
||||
|
|
@ -172,7 +171,8 @@ function getPackCellsData() {
|
|||
provinces: pack.provinces,
|
||||
religions: pack.religions,
|
||||
rivers: pack.rivers,
|
||||
markers: pack.markers
|
||||
markers: pack.markers,
|
||||
routes: pack.routes
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import {rollups} from "../../../utils/functionUtils.js";
|
||||
|
||||
const entitiesMap = {
|
||||
states: {
|
||||
label: "State",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue