MCPcopy Create free account
hub / github.com/SimHacker/micropolis / smoothTerrain

Method smoothTerrain

MicropolisCore/src/MicropolisEngine/src/scan.cpp:454–498  ·  view source on GitHub ↗

comefrom: pollutionTerrainLandValueScan */

Source from the content-addressed store, hash-verified

452
453/* comefrom: pollutionTerrainLandValueScan */
454void Micropolis::smoothTerrain()
455{
456 if (donDither & 1) {
457 int x, y = 0, dir = 1;
458 unsigned z = 0;
459
460 for (x = 0; x < terrainDensityMap.MAP_W; x++) {
461 for (; y != terrainDensityMap.MAP_H && y != -1; y += dir) {
462 z +=
463 tempMap3.get((x == 0) ? x : (x - 1), y) +
464 tempMap3.get((x == (terrainDensityMap.MAP_W - 1)) ? x : (x + 1), y) +
465 tempMap3.get(x, (y == 0) ? (0) : (y - 1)) +
466 tempMap3.get(x, (y == (terrainDensityMap.MAP_H - 1)) ? y : (y + 1)) +
467 (tempMap3.get(x, y) <<2);
468 Byte val = (Byte)(z / 8);
469 terrainDensityMap.set(x, y, val);
470 z &= 0x7;
471 }
472 dir = -dir;
473 y += dir;
474 }
475 } else {
476 short x, y;
477
478 for (x = 0; x < terrainDensityMap.MAP_W; x++) {
479 for (y = 0; y < terrainDensityMap.MAP_H; y++) {
480 unsigned z = 0;
481 if (x > 0) {
482 z += tempMap3.get(x - 1, y);
483 }
484 if (x < (terrainDensityMap.MAP_W - 1)) {
485 z += tempMap3.get(x + 1, y);
486 }
487 if (y > 0) {
488 z += tempMap3.get(x, y - 1);
489 }
490 if (y < (terrainDensityMap.MAP_H - 1)) {
491 z += tempMap3.get(x, y + 1);
492 }
493 Byte val = (Byte)(z / 4 + tempMap3.get(x, y)) / 2;
494 terrainDensityMap.set(x, y, val);
495 }
496 }
497 }
498}
499
500/**
501 * Perform smoothing with or without dithering.

Callers

nothing calls this directly

Calls 2

setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected