Skip to content

Commit 392ac41

Browse files
committedApr 7, 2015
Cavegen: Remove now unnecessary checks for water, lava, ice
Remove large cave checks for air Mgv5/mgv7:Add is_ground_content checks to 3d noise tunnels More large caves Shorten lines
1 parent f817597 commit 392ac41

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed
 

Diff for: ‎src/cavegen.cpp

+3-11
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,8 @@ void CaveV5::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
262262
continue;
263263

264264
u32 i = vm->m_area.index(p);
265-
266-
// Don't replace air, water, lava, or ice
267265
content_t c = vm->m_data[i].getContent();
268-
if (!ndef->get(c).is_ground_content || c == CONTENT_AIR ||
269-
c == c_water_source || c == c_lava_source || c == c_ice)
266+
if (!ndef->get(c).is_ground_content)
270267
continue;
271268

272269
int full_ymin = node_min.Y - MAP_BLOCKSIZE;
@@ -551,9 +548,7 @@ void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz) {
551548
vm->m_data[i] = airnode;
552549
}
553550
} else {
554-
// Don't replace air or water or lava or ignore
555-
if (c == CONTENT_IGNORE || c == CONTENT_AIR ||
556-
c == c_water_source || c == c_lava_source)
551+
if (c == CONTENT_IGNORE || c == CONTENT_AIR)
557552
continue;
558553

559554
vm->m_data[i] = airnode;
@@ -800,11 +795,8 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
800795
continue;
801796

802797
u32 i = vm->m_area.index(p);
803-
804-
// Don't replace air, water, lava, or ice
805798
content_t c = vm->m_data[i].getContent();
806-
if (!ndef->get(c).is_ground_content || c == CONTENT_AIR ||
807-
c == c_water_source || c == c_lava_source || c == c_ice)
799+
if (!ndef->get(c).is_ground_content)
808800
continue;
809801

810802
int full_ymin = node_min.Y - MAP_BLOCKSIZE;

Diff for: ‎src/mapgen_v5.cpp

+17-15
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,12 @@ bool MapgenV5::generateBiomes(float *heat_map, float *humidity_map)
411411
for (s16 y = node_max.Y; y >= node_min.Y; y--) {
412412
content_t c = vm->m_data[i].getContent();
413413

414-
if (c != CONTENT_IGNORE && c != CONTENT_AIR && (y == node_max.Y || have_air)) {
415-
biome = bmgr->getBiome(heat_map[index], humidity_map[index], y);
416-
dfiller = biome->depth_filler + noise_filler_depth->result[index];
417-
y0_top = biome->depth_top;
418-
y0_filler = biome->depth_top + dfiller;
414+
if (c != CONTENT_IGNORE && c != CONTENT_AIR &&
415+
(y == node_max.Y || have_air)) {
416+
biome = bmgr->getBiome(heat_map[index], humidity_map[index], y);
417+
dfiller = biome->depth_filler + noise_filler_depth->result[index];
418+
y0_top = biome->depth_top;
419+
y0_filler = biome->depth_top + dfiller;
419420
depth_water_top = biome->depth_water_top;
420421

421422
if (biome->c_stone == c_desert_stone)
@@ -478,18 +479,19 @@ void MapgenV5::generateCaves(int max_stone_y)
478479
for (s16 y=node_min.Y - 1; y<=node_max.Y + 1; y++) {
479480
u32 i = vm->m_area.index(node_min.X, y, z);
480481
for (s16 x=node_min.X; x<=node_max.X; x++, i++, index++, index2d++) {
481-
Biome *biome = (Biome *)bmgr->getRaw(biomemap[index2d]);
482-
content_t c = vm->m_data[i].getContent();
483-
if (c == CONTENT_AIR
484-
|| (y <= water_level
485-
&& c != biome->c_stone
486-
&& c != c_stone))
487-
continue;
488-
489482
float d1 = contour(noise_cave1->result[index]);
490483
float d2 = contour(noise_cave2->result[index]);
491-
if (d1*d2 > 0.125)
484+
if (d1*d2 > 0.125) {
485+
Biome *biome = (Biome *)bmgr->getRaw(biomemap[index2d]);
486+
content_t c = vm->m_data[i].getContent();
487+
if (!ndef->get(c).is_ground_content || c == CONTENT_AIR ||
488+
(y <= water_level &&
489+
c != biome->c_stone &&
490+
c != c_stone))
491+
continue;
492+
492493
vm->m_data[i] = MapNode(CONTENT_AIR);
494+
}
493495
}
494496
index2d -= ystride;
495497
}
@@ -500,7 +502,7 @@ void MapgenV5::generateCaves(int max_stone_y)
500502
return;
501503

502504
PseudoRandom ps(blockseed + 21343);
503-
u32 bruises_count = (ps.range(1, 5) == 1) ? ps.range(1, 2) : 0;
505+
u32 bruises_count = (ps.range(1, 4) == 1) ? ps.range(1, 2) : 0;
504506
for (u32 i = 0; i < bruises_count; i++) {
505507
CaveV5 cave(this, &ps);
506508
cave.makeCave(node_min, node_max, max_stone_y);

Diff for: ‎src/mapgen_v7.cpp

+19-13
Original file line numberDiff line numberDiff line change
@@ -605,11 +605,12 @@ bool MapgenV7::generateBiomes(float *heat_map, float *humidity_map)
605605
for (s16 y = node_max.Y; y >= node_min.Y; y--) {
606606
content_t c = vm->m_data[i].getContent();
607607

608-
if (c != CONTENT_IGNORE && c != CONTENT_AIR && (y == node_max.Y || have_air)) {
609-
biome = bmgr->getBiome(heat_map[index], humidity_map[index], y);
610-
dfiller = biome->depth_filler + noise_filler_depth->result[index];
611-
y0_top = biome->depth_top;
612-
y0_filler = biome->depth_top + dfiller;
608+
if (c != CONTENT_IGNORE && c != CONTENT_AIR &&
609+
(y == node_max.Y || have_air)) {
610+
biome = bmgr->getBiome(heat_map[index], humidity_map[index], y);
611+
dfiller = biome->depth_filler + noise_filler_depth->result[index];
612+
y0_top = biome->depth_top;
613+
y0_filler = biome->depth_top + dfiller;
613614
depth_water_top = biome->depth_water_top;
614615

615616
if (biome->c_stone == c_desert_stone)
@@ -820,16 +821,21 @@ void MapgenV7::generateCaves(int max_stone_y)
820821
u32 i = vm->m_area.index(node_min.X, y, z);
821822
for (s16 x = node_min.X; x <= node_max.X;
822823
x++, i++, index++, index2d++) {
823-
Biome *biome = (Biome *)bmgr->getRaw(biomemap[index2d]);
824-
content_t c = vm->m_data[i].getContent();
825-
if (c == CONTENT_AIR || (y <= water_level &&
826-
c != biome->c_stone && c != c_stone))
827-
continue;
828-
829824
float d1 = contour(noise_cave1->result[index]);
830825
float d2 = contour(noise_cave2->result[index]);
831-
if (d1 * d2 > 0.3)
826+
if (d1 * d2 > 0.3) {
827+
Biome *biome = (Biome *)bmgr->
828+
getRaw(biomemap[index2d]);
829+
content_t c = vm->m_data[i].getContent();
830+
if (!ndef->get(c).is_ground_content ||
831+
c == CONTENT_AIR ||
832+
(y <= water_level &&
833+
c != biome->c_stone &&
834+
c != c_stone))
835+
continue;
836+
832837
vm->m_data[i] = MapNode(CONTENT_AIR);
838+
}
833839
}
834840
index2d -= ystride;
835841
}
@@ -838,7 +844,7 @@ void MapgenV7::generateCaves(int max_stone_y)
838844
}
839845

840846
PseudoRandom ps(blockseed + 21343);
841-
u32 bruises_count = (ps.range(1, 5) == 1) ? ps.range(1, 2) : 0;
847+
u32 bruises_count = (ps.range(1, 4) == 1) ? ps.range(1, 2) : 0;
842848
for (u32 i = 0; i < bruises_count; i++) {
843849
CaveV7 cave(this, &ps);
844850
cave.makeCave(node_min, node_max, max_stone_y);

0 commit comments

Comments
 (0)
Please sign in to comment.