Fix averaging of heightmaps which broke on giant mapsizes. Thanks Sandarac for reporting.

This was SVN commit r18524.
This commit is contained in:
elexis 2016-07-17 12:59:10 +00:00
parent 33e3e6c2ab
commit ea3492a9a5

View File

@ -1296,12 +1296,12 @@ function paintHeightmap(heightmap, tilemap, pallet, func = undefined)
let nearby = [i];
if (i + hmSize < heightmap.length)
{
nearby.push(i + hmSize);
height = (heightmap[nearby[0]] + heightmap[nearby[1]]) / 2;
}
tile = pallet[tilemap[nearby[randInt(0, nearby.length - 1)]]];
// Average
height = nearby.reduce((sum, value) => sum + value) / nearby.length;
}
setHeight(x, y, height);