Skip to content

Commit 3e35534

Browse files
committed
Remove Phase 4 from Hydrology Code
Phase 4 modified the elevation values, completely destroying the entire process of producing a valuable elevation map for tile placement. Removing it, restores the original process of elevation creation && retains the hydrology walkable pathing, enforcing ramps over cliffs where walkability exists.
1 parent 0aa184a commit 3e35534

File tree

2 files changed

+2
-55
lines changed

2 files changed

+2
-55
lines changed

demo/terrain_gen_script.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func _ready():
1919
#generate(grid_map, 128, 128, 4, seed_value, 12, NoiseType.VALUE, 0.79, 0.1);
2020

2121
# Simplex Noise Based
22-
var result: Dictionary = generate(grid_map, 128, 128, 4, seed_value, 12, NoiseType.SIMPLEX, 0.6, 0.01, 0.02);
22+
var result: Dictionary = generate(grid_map, 128, 128, 4, seed_value, 12, NoiseType.SIMPLEX, 0.6, 0.005, 0.015);
2323

2424
#
2525
#

src/TerrainGen/Terrain_Gen.cpp

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -605,59 +605,6 @@ Dictionary TerrainGen::generate(
605605
}
606606
}
607607

608-
//
609-
// Phase 4 : Setting Walkable Area's
610-
//
611-
// Modify Elevation Map to ensure walkable area's are expressed
612-
//
613-
// If the majority of cells in a 2x2 are marked walkable,
614-
// ensure elevation map's neighbors are equal value
615-
//
616-
// NOTICE : HeightMap.size() == elevationMap.size() * 2;
617-
618-
for (int x = 1; x < widthx2 - 2; ++x) {
619-
for (int y = 1; y < heightx2 - 2; ++y) {
620-
// Check 2x2 block
621-
bool w1 = walkableMap[x][y];
622-
bool w2 = walkableMap[x][y + 1];
623-
bool w3 = walkableMap[x + 1][y];
624-
bool w4 = walkableMap[x + 1][y + 1];
625-
626-
int walkableCount = w1 + w2 + w3 + w4;
627-
628-
if (walkableCount >= 3) {
629-
vector<int> values = {
630-
heightMap[x][y],
631-
heightMap[x][y + 1],
632-
heightMap[x + 1][y],
633-
heightMap[x + 1][y + 1]
634-
};
635-
636-
int heightMode = values[0];
637-
int maxCount = 0;
638-
639-
for (int i = 0; i < values.size(); ++i) {
640-
int count = 1;
641-
for (int j = i + 1; j < values.size(); ++j)
642-
if (values[j] == values[i])
643-
++count;
644-
645-
if (count > maxCount) {
646-
maxCount = count;
647-
heightMode = values[i];
648-
}
649-
}
650-
651-
// Majority walkable — flatten elevation
652-
653-
heightMap[x][y] = heightMode;
654-
heightMap[x][y + 1] = heightMode;
655-
heightMap[x + 1][y] = heightMode;
656-
heightMap[x + 1][y + 1] = heightMode;
657-
}
658-
}
659-
}
660-
661608
/*****************************************************
662609
663610
Enforce Square Patterns
@@ -1246,5 +1193,5 @@ Dictionary TerrainGen::generate(
12461193
}
12471194

12481195
void TerrainGen::_bind_methods() {
1249-
ClassDB::bind_method(D_METHOD("generate", "GridMap", "height", "width", "elevationMax", "seed", "noiseType", "waterRemoval", "cliffsThreshold", "noiseFreq"), &TerrainGen::generate);
1196+
ClassDB::bind_method(D_METHOD("generate", "GridMap", "height", "width", "elevationMax", "seed", "openAreaMin", "noiseType", "waterRemoval", "cliffsThreshold", "noiseFreq"), &TerrainGen::generate);
12501197
}

0 commit comments

Comments
 (0)