Skip to content

Commit

Permalink
Mgv7: Always carve river channels in mountain terrain
Browse files Browse the repository at this point in the history
Previously, rivers were sometimes blocked by vertical walls
of mountain terrain due to river carving being disabled
when base terrain height was below water_level - 16
Remove now unused base terrain heightmap created in
generateTerrain()
  • Loading branch information
paramat committed Jun 2, 2016
1 parent 14ef2b4 commit 5699980
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/mapgen_v7.cpp
Expand Up @@ -206,13 +206,15 @@ void MapgenV7::makeChunk(BlockMakeData *data)

blockseed = getBlockSeed2(full_node_min, seed);

// Generate terrain and ridges with initial heightmaps
// Generate base and mountain terrain
// An initial heightmap is no longer created here for use in generateRidgeTerrain()
s16 stone_surface_max_y = generateTerrain();

// Generate rivers
if (spflags & MGV7_RIDGES)
generateRidgeTerrain();

// Update heightmap to include mountain terrain
// Create heightmap
updateHeightmap(node_min, node_max);

// Init biome generator, place biome-specific nodes, and build biomemap
Expand Down Expand Up @@ -331,7 +333,6 @@ int MapgenV7::generateTerrain()
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
s16 surface_y = baseTerrainLevelFromMap(index2d);
heightmap[index2d] = surface_y; // Create base terrain heightmap

if (surface_y > stone_surface_max_y)
stone_surface_max_y = surface_y;
Expand Down Expand Up @@ -382,9 +383,6 @@ void MapgenV7::generateRidgeTerrain()
for (s16 x = node_min.X; x <= node_max.X; x++, index++, vi++) {
int j = (z - node_min.Z) * csize.X + (x - node_min.X);

if (heightmap[j] < water_level - 16) // Use base terrain heightmap
continue;

float uwatern = noise_ridge_uwater->result[j] * 2;
if (fabs(uwatern) > width)
continue;
Expand Down

0 comments on commit 5699980

Please sign in to comment.