based on suggestions simplified usage of biome usage

This commit is contained in:
ZoltanTheDM 2019-11-10 15:29:50 -08:00
parent d9df7c2f15
commit f6f49fd86b
4 changed files with 32 additions and 31 deletions

View file

@ -17,23 +17,23 @@
const height = cells.h[i];
if (height < 20) continue; // no icons on water
if (cells.r[i]) continue; // no icons on rivers
const b = cells.biome[i];
if (height < 50 && biomesData.biomeList[b].icons.density === 0) continue; // no icons for this biome
const b = biomesData.biomeList[cells.biome[i]];
if (height < 50 && b.icons.density === 0) continue; // no icons for this biome
const polygon = getPackPolygon(i);
const x = d3.extent(polygon, p => p[0]), y = d3.extent(polygon, p => p[1]);
const e = [Math.ceil(x[0]), Math.ceil(y[0]), Math.floor(x[1]), Math.floor(y[1])]; // polygon box
if (height < 50) placeBiomeIcons(i, b); else placeReliefIcons(i);
if (height < 50) placeBiomeIcons(); else placeReliefIcons(i);
function placeBiomeIcons() {
const iconsDensity = biomesData.biomeList[b].icons.density / 100;
const iconsDensity = b.icons.density / 100;
const radius = 2 / iconsDensity / density;
if (Math.random() > iconsDensity * 10) return;
for (const [cx, cy] of poissonDiscSampler(e[0], e[1], e[2], e[3], radius)) {
if (!d3.polygonContains(polygon, [cx, cy])) continue;
let h = rn((4 + Math.random()) * size, 2);
const icon = getBiomeIcon(i, biomesData.biomeList[b].icons.probability);
const icon = getBiomeIcon(i, b.icons.probability);
if (icon === "#relief-grass-1") h *= 1.3;
relief.push({i: icon, x: rn(cx-h, 2), y: rn(cy-h, 2), s: h*2});
}