refactor: detect feature vertex

This commit is contained in:
max 2022-07-16 02:14:59 +03:00
parent 3410c48c58
commit 1888b04d54
4 changed files with 116 additions and 43 deletions

View file

@ -47,12 +47,15 @@ export function calculateVoronoi(points: TPoints, boundary: TPoints): IGraph {
// add points along map edge to pseudo-clip voronoi cells
function getBoundaryPoints(width: number, height: number, spacing: number) {
const offset = rn(-1 * spacing);
const offset = rn(spacing * -1.5);
const bSpacing = spacing * 2;
const w = width - offset * 2;
const h = height - offset * 2;
const numberX = Math.ceil(w / bSpacing) - 1;
const numberY = Math.ceil(h / bSpacing) - 1;
const points: TPoints = [];
for (let i = 0.5; i < numberX; i++) {

View file

@ -15,7 +15,6 @@ import {calculateVoronoi} from "scripts/generation/graph";
import {createTypedArray} from "utils/arrayUtils";
import {pick} from "utils/functionUtils";
import {rn} from "utils/numberUtils";
import {rankCells} from "../rankCells";
const {LAND_COAST, WATER_COAST, DEEPER_WATER} = DISTANCE_FIELD;
const {Lakes, OceanLayers, Rivers, Biomes, Cultures, BurgsAndStates, Religions, Military, Markers, Names} = window;