This commit is contained in:
Azgaar 2019-11-17 23:01:08 +03:00
parent 0b1c93b45d
commit f5985a4374
2 changed files with 6 additions and 6 deletions

View file

@ -515,11 +515,11 @@
} }
} }
const smooth = function(fr = 2) { const smooth = function(fr = 2, add = 0) {
cells.h = cells.h.map((h, i) => { cells.h = cells.h.map((h, i) => {
const a = [h]; const a = [h];
cells.c[i].forEach(c => a.push(cells.h[c])); 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);
}); });
} }

View file

@ -536,8 +536,8 @@ function editHeightmap() {
if (brush === "brushLower") s.forEach(i => h[i] = lim(h[i] - power)); else 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 === "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 === "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 === "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] < 17 ? h[i] : lim(h[i] + power/2 - Math.random()*power)); if (brush === "brushDisrupt") s.forEach(i => h[i] = h[i] < 15 ? h[i] : lim(h[i] + power/1.6 - Math.random()*power));
mockHeightmapSelection(s); mockHeightmapSelection(s);
// updateHistory(); uncomment to update history every step // updateHistory(); uncomment to update history every step
@ -573,12 +573,12 @@ function editHeightmap() {
} }
function smoothAllHeights() { function smoothAllHeights() {
HeightmapGenerator.smooth(4); HeightmapGenerator.smooth(4, 1.5);
updateHeightmap(); updateHeightmap();
} }
function disruptAllHeights() { 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(); updateHeightmap();
} }