Skip to content

Commit bb2ee54

Browse files
committedMar 14, 2016
Mapgen: Fix light in tunnels at mapchunk borders
Don't excavate the overgenerated stone at node_max.Y + 1, this creates a 'roof' over the tunnel, preventing light in tunnels at mapchunk borders when generating mapchunks upwards.
1 parent c0b6986 commit bb2ee54

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed
 

‎src/mapgen_flat.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,12 @@ void MapgenFlat::generateCaves(s16 max_stone_y)
573573

574574
for (s16 y = node_max.Y + 1; y >= node_min.Y - 1;
575575
y--, index3d -= ystride, vm->m_area.add_y(em, vi, -1)) {
576+
// Don't excavate the overgenerated stone at node_max.Y + 1,
577+
// this creates a 'roof' over the tunnel, preventing light in
578+
// tunnels at mapchunk borders when generating mapchunks upwards.
579+
if (y > node_max.Y)
580+
continue;
581+
576582
content_t c = vm->m_data[vi].getContent();
577583
if (c == CONTENT_AIR || c == biome->c_water_top ||
578584
c == biome->c_water) {

‎src/mapgen_fractal.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,12 @@ void MapgenFractal::generateCaves(s16 max_stone_y)
701701

702702
for (s16 y = node_max.Y + 1; y >= node_min.Y - 1;
703703
y--, index3d -= ystride, vm->m_area.add_y(em, vi, -1)) {
704+
// Don't excavate the overgenerated stone at node_max.Y + 1,
705+
// this creates a 'roof' over the tunnel, preventing light in
706+
// tunnels at mapchunk borders when generating mapchunks upwards.
707+
if (y > node_max.Y)
708+
continue;
709+
704710
content_t c = vm->m_data[vi].getContent();
705711
if (c == CONTENT_AIR || c == biome->c_water_top ||
706712
c == biome->c_water) {

‎src/mapgen_v5.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ void MapgenV5::generateCaves(int max_stone_y)
519519
for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
520520
u32 vi = vm->m_area.index(node_min.X, y, z);
521521
for (s16 x = node_min.X; x <= node_max.X; x++, vi++, index++) {
522+
// Don't excavate the overgenerated stone at node_max.Y + 1,
523+
// this creates a 'roof' over the tunnel, preventing light in
524+
// tunnels at mapchunk borders when generating mapchunks upwards.
525+
if (y > node_max.Y)
526+
continue;
527+
522528
float d1 = contour(noise_cave1->result[index]);
523529
float d2 = contour(noise_cave2->result[index]);
524530
if (d1 * d2 > 0.125f) {

‎src/mapgen_v7.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,12 @@ void MapgenV7::generateCaves(s16 max_stone_y)
883883

884884
for (s16 y = node_max.Y + 1; y >= node_min.Y - 1;
885885
y--, index3d -= ystride, vm->m_area.add_y(em, vi, -1)) {
886+
// Don't excavate the overgenerated stone at node_max.Y + 1,
887+
// this creates a 'roof' over the tunnel, preventing light in
888+
// tunnels at mapchunk borders when generating mapchunks upwards.
889+
if (y > node_max.Y)
890+
continue;
891+
886892
content_t c = vm->m_data[vi].getContent();
887893
if (c == CONTENT_AIR || c == biome->c_water_top ||
888894
c == biome->c_water) {

‎src/mapgen_valleys.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,12 @@ void MapgenValleys::generateCaves(s16 max_stone_y)
931931
for (s16 y = node_max.Y + 1;
932932
y >= node_min.Y - 1;
933933
y--, index_3d -= ystride, vm->m_area.add_y(em, index_data, -1)) {
934+
// Don't excavate the overgenerated stone at node_max.Y + 1,
935+
// this creates a 'roof' over the tunnel, preventing light in
936+
// tunnels at mapchunk borders when generating mapchunks upwards.
937+
if (y > node_max.Y)
938+
continue;
939+
934940
float terrain = noise_terrain_height->result[index_2d];
935941

936942
// Saves some time.

0 commit comments

Comments
 (0)
Please sign in to comment.