refactor: refactor greneration routine

This commit is contained in:
Azgaar 2022-07-10 23:31:03 +03:00
parent d1208b12ec
commit 6b2de4d20e
19 changed files with 401 additions and 292 deletions

View file

@ -6,7 +6,7 @@ import {ERROR, INFO, TIME} from "config/logging";
import {closeDialogs} from "dialogs/utils";
import {layerIsOn, turnLayerButtonOff, turnLayerButtonOn, updatePresetInput, renderLayer} from "layers";
import {drawCoastline} from "modules/coastline";
import {markFeatures, markupGridOcean} from "modules/markup";
import {markupGridFeatures} from "modules/markup";
import {generatePrecipitation} from "modules/precipitation";
import {calculateTemperatures} from "modules/temperature";
import {moveCircle, removeCircle} from "modules/ui/editors";
@ -214,11 +214,11 @@ export function open(options) {
TIME && console.time("regenerateErasedData");
const erosionAllowed = allowErosion.checked;
markFeatures();
markupGridOcean();
markupGridFeatures();
if (erosionAllowed) {
Lakes.addLakesInDeepDepressions();
Lakes.openNearSeaLakes();
Lakes.addLakesInDeepDepressions(grid);
Lakes.openNearSeaLakes(grid);
}
OceanLayers();
calculateTemperatures();
@ -336,8 +336,8 @@ export function open(options) {
zone.selectAll("*").remove();
});
markFeatures();
markupGridOcean();
markupGridFeatures();
if (erosionAllowed) addLakesInDeepDepressions();
OceanLayers();
calculateTemperatures();

View file

@ -2,7 +2,7 @@ import * as d3 from "d3";
import {heightmapTemplates} from "config/heightmap-templates";
import {precreatedHeightmaps} from "config/precreated-heightmaps";
import {shouldRegenerateGrid, generateGrid} from "utils/graphUtils";
import {shouldRegenerateGridPoints, generateGrid} from "utils/graphUtils";
import {byId} from "utils/shorthands";
import {generateSeed} from "utils/probabilityUtils";
import {getColorScheme} from "utils/colorUtils";
@ -274,7 +274,7 @@ function getName(id) {
}
function getGraph(currentGraph) {
const newGraph = shouldRegenerateGrid(currentGraph) ? generateGrid() : structuredClone(currentGraph);
const newGraph = shouldRegenerateGridPoints(currentGraph) ? generateGrid() : structuredClone(currentGraph);
delete newGraph.cells.h;
return newGraph;
}