mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-23 04:21:24 +01:00
fix:riverbed generation
This commit is contained in:
parent
aee8c974a1
commit
ecb367616d
2 changed files with 15 additions and 16 deletions
|
|
@ -31,10 +31,12 @@ window.Rivers = (function () {
|
|||
TIME && console.timeEnd("generateRivers");
|
||||
|
||||
function drainWater() {
|
||||
const sqrpixel = distanceScale * distanceScale
|
||||
const MIN_FLUX_TO_FORM_RIVER = 10 * distanceScale;
|
||||
const pixel2 = distanceScale * distanceScale
|
||||
//const MIN_FLUX_TO_FORM_RIVER = 10 * distanceScale;
|
||||
const MIN_FLUX_TO_FORM_RIVER = 30;
|
||||
const prec = grid.cells.prec;
|
||||
const area = c => pack.cells.area[c] * sqrpixel;
|
||||
// const area = c => pack.cells.area[c] * pixel2;
|
||||
const area = pack.cells.area;
|
||||
const land = cells.i.filter(i => h[i] >= 20).sort((a, b) => h[b] - h[a]);
|
||||
const lakeOutCells = Lakes.setClimateData(h);
|
||||
|
||||
|
|
@ -167,7 +169,7 @@ window.Rivers = (function () {
|
|||
const mouth = riverCells[riverCells.length - 2];
|
||||
const parent = riverParents[key] || 0;
|
||||
|
||||
const widthFactor = (!parent || parent === riverId ? 3.6 : 3) / distanceScale;
|
||||
const widthFactor = (!parent || parent === riverId ? 1.2 : 1);
|
||||
const meanderedPoints = addMeandering(riverCells);
|
||||
const discharge = cells.fl[mouth]; // m3 in second
|
||||
const length = getApproximateLength(meanderedPoints);
|
||||
|
|
|
|||
|
|
@ -53,9 +53,6 @@ window.Submap = (function () {
|
|||
})
|
||||
// TODO: add smooth/noise function for h, temp, prec n times
|
||||
|
||||
stage("Detect features, ocean and generating lakes.")
|
||||
markFeatures();
|
||||
|
||||
if (options.depressRivers) {
|
||||
stage("Generating riverbeds.")
|
||||
const rbeds = new Uint16Array(grid.cells.i.length);
|
||||
|
|
@ -69,19 +66,24 @@ window.Submap = (function () {
|
|||
if (!targetCells)
|
||||
throw "TargetCell shouldn't be empty.";
|
||||
targetCells.forEach(c => {
|
||||
if (grid.cells.t[c]<1) return;
|
||||
if (grid.cells.h[c]<20) return;
|
||||
rbeds[c] = 1;
|
||||
});
|
||||
})
|
||||
);
|
||||
console.log("rbed stats: ", rbeds.filter(x=>x).length, rbeds.length)
|
||||
// raise every land cell a bit except riverbeds
|
||||
grid.cells.h.forEach((h, i) => {
|
||||
if (!rbeds[i] || grid.cells.t[i]<1) return;
|
||||
grid.cells.h[i] = Math.min(grid.cells.h[i]+2, 100);
|
||||
if (rbeds[i] || h<20) return;
|
||||
grid.cells.h[i] = Math.min(h+2, 100);
|
||||
});
|
||||
}
|
||||
|
||||
stage("Detect features, ocean and generating lakes.")
|
||||
markFeatures();
|
||||
|
||||
markupGridOcean();
|
||||
|
||||
// Warning: addLakesInDeepDepressions can be very slow!
|
||||
if (options.addLakesInDepressions) {
|
||||
addLakesInDeepDepressions();
|
||||
|
|
@ -118,7 +120,7 @@ window.Submap = (function () {
|
|||
|
||||
resampler(cells.p, oldCells.q, (id, oldid) => {
|
||||
if (cells.t[id] * oldCells.t[oldid] < 0) {
|
||||
// missmaped cell: water instead of land or vice versa
|
||||
// fix missmaped cell: water instead of land or vice versa
|
||||
WARN && console.warn('Type discrepancy detected:', id, oldid, `${pack.cells.t[id]} != ${oldCells.t[oldid]}`);
|
||||
const aid = cells.t[id]<0
|
||||
? cells.c[id].find(c=>cells.t[c]<0)
|
||||
|
|
@ -136,11 +138,6 @@ window.Submap = (function () {
|
|||
forwardMap[oldid].push(id)
|
||||
})
|
||||
|
||||
DEBUG && console.log('reversemap:',forwardMap)
|
||||
DEBUG && console.log('forwardmap:',reverseMap)
|
||||
|
||||
// TODO: errode riverbeds
|
||||
|
||||
stage("Regenerating river network.")
|
||||
Rivers.generate();
|
||||
drawRivers();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue