diff options
author | paramat <mat.gregory@virginmedia.com> | 2015-03-01 01:30:47 +0000 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2015-03-02 02:13:43 +0000 |
commit | 773aa8c57b70dd85273cb61286f8be577b4ca3aa (patch) | |
tree | 96b8d9f741c819b95c85ee3d1f2cf62f81ce82aa | |
parent | 1a175c6982375c996d747ad5569d5d829fa2dde4 (diff) | |
download | minetest-773aa8c57b70dd85273cb61286f8be577b4ca3aa.tar.gz minetest-773aa8c57b70dd85273cb61286f8be577b4ca3aa.tar.bz2 minetest-773aa8c57b70dd85273cb61286f8be577b4ca3aa.zip |
Mgv6: Add heightmap. Do not make large caves that are entirely above ground
-rw-r--r-- | src/cavegen.cpp | 30 | ||||
-rw-r--r-- | src/mapgen_v6.cpp | 5 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/cavegen.cpp b/src/cavegen.cpp index 6010780e9..bac656511 100644 --- a/src/cavegen.cpp +++ b/src/cavegen.cpp @@ -173,6 +173,36 @@ void CaveV6::makeTunnel(bool dirswitch) { ); } + // Do not make large caves that are entirely above ground. + // It is only necessary to check the startpoint and endpoint. + if (large_cave) { + v3s16 orpi(orp.X, orp.Y, orp.Z); + v3s16 veci(vec.X, vec.Y, vec.Z); + s16 h1; + s16 h2; + + v3s16 p1 = orpi + veci + of + rs / 2; + if (p1.Z >= node_min.Z && p1.Z <= node_max.Z && + p1.X >= node_min.X && p1.X <= node_max.X) { + u32 index1 = (p1.Z - node_min.Z) * mg->ystride + (p1.X - node_min.X); + h1 = mg->heightmap[index1]; + } else { + h1 = water_level; // If not in heightmap + } + + v3s16 p2 = orpi + of + rs / 2; + if (p2.Z >= node_min.Z && p2.Z <= node_max.Z && + p2.X >= node_min.X && p2.X <= node_max.X) { + u32 index2 = (p2.Z - node_min.Z) * mg->ystride + (p2.X - node_min.X); + h2 = mg->heightmap[index2]; + } else { + h2 = water_level; + } + + if (p1.Y > h1 && p2.Y > h2) // If startpoint and endpoint are above ground + return; + } + vec += main_direction; v3f rp = orp + vec; diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index 95cdbd279..4783e4285 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -55,6 +55,8 @@ MapgenV6::MapgenV6(int mapgenid, MapgenParams *params, EmergeManager *emerge) this->m_emerge = emerge; this->ystride = csize.X; //////fix this + this->heightmap = new s16[csize.X * csize.Z]; + MapgenV6Params *sp = (MapgenV6Params *)params->sparams; this->spflags = sp->spflags; this->freq_desert = sp->freq_desert; @@ -498,6 +500,9 @@ void MapgenV6::makeChunk(BlockMakeData *data) } + // Create heightmap after mudflow + updateHeightmap(node_min, node_max); + // Add dungeons if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) { DungeonParams dp; |