diff --git a/modules/heightmap-generator.js b/modules/heightmap-generator.js index 28643976..6fc72f81 100644 --- a/modules/heightmap-generator.js +++ b/modules/heightmap-generator.js @@ -515,11 +515,11 @@ } } - const smooth = function(fr = 2) { + const smooth = function(fr = 2, add = 0) { cells.h = cells.h.map((h, i) => { const a = [h]; cells.c[i].forEach(c => a.push(cells.h[c])); - return lim((h * (fr-1) + d3.mean(a)) / fr); + return lim((h * (fr-1) + d3.mean(a) + add) / fr); }); } diff --git a/modules/ui/heightmap-editor.js b/modules/ui/heightmap-editor.js index a06f5258..25fcfd73 100644 --- a/modules/ui/heightmap-editor.js +++ b/modules/ui/heightmap-editor.js @@ -536,8 +536,8 @@ function editHeightmap() { if (brush === "brushLower") s.forEach(i => h[i] = lim(h[i] - power)); else if (brush === "brushDepress") s.forEach((i,d) => h[i] = lim(h[i] - interpolate(d/Math.max(s.length-1, 1)))); else if (brush === "brushAlign") s.forEach(i => h[i] = lim(h[start])); else - if (brush === "brushSmooth") s.forEach(i => h[i] = rn((d3.mean(grid.cells.c[i].filter(i => land ? h[i] >= 20 : 1).map(c => h[c])) + h[i]*(10-power)) / (11-power),1)); else - if (brush === "brushDisrupt") s.forEach(i => h[i] = h[i] < 17 ? h[i] : lim(h[i] + power/2 - Math.random()*power)); + if (brush === "brushSmooth") s.forEach(i => h[i] = rn((d3.mean(grid.cells.c[i].filter(i => land ? h[i] >= 20 : 1).map(c => h[c])) + h[i]*(10-power) + .6) / (11-power),1)); else + if (brush === "brushDisrupt") s.forEach(i => h[i] = h[i] < 15 ? h[i] : lim(h[i] + power/1.6 - Math.random()*power)); mockHeightmapSelection(s); // updateHistory(); uncomment to update history every step @@ -573,12 +573,12 @@ function editHeightmap() { } function smoothAllHeights() { - HeightmapGenerator.smooth(4); + HeightmapGenerator.smooth(4, 1.5); updateHeightmap(); } function disruptAllHeights() { - grid.cells.h = grid.cells.h.map(h => h < 17 ? h : lim(h + 2 - Math.random()*4)); + grid.cells.h = grid.cells.h.map(h => h < 15 ? h : lim(h + 2.5 - Math.random() * 4)); updateHeightmap(); }