diff options
author | paramat <mat.gregory@virginmedia.com> | 2016-04-02 02:05:08 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-04-08 03:14:36 +0100 |
commit | 465bb6f5d13803819f329e4920bceb25a3887c6f (patch) | |
tree | 3e089079bc907e95fa0ae8c505ff4e93459f47e4 /src/mapgen_fractal.cpp | |
parent | c3993f6604a646b42c1586219c471acb6d9895c6 (diff) | |
download | minetest-465bb6f5d13803819f329e4920bceb25a3887c6f.tar.gz minetest-465bb6f5d13803819f329e4920bceb25a3887c6f.tar.bz2 minetest-465bb6f5d13803819f329e4920bceb25a3887c6f.zip |
Mapgen: Optimise cave noises and tunnel excavation
Instead of doing nothing at node_max.Y + 1 use 1-down
overgeneration for tunnel generation and noisemaps
Move some old unused code in mgv7 to end of file
Diffstat (limited to 'src/mapgen_fractal.cpp')
-rw-r--r-- | src/mapgen_fractal.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/mapgen_fractal.cpp b/src/mapgen_fractal.cpp index 0430f92ff..810645abb 100644 --- a/src/mapgen_fractal.cpp +++ b/src/mapgen_fractal.cpp @@ -56,7 +56,8 @@ MapgenFractal::MapgenFractal(int mapgenid, MapgenParams *params, EmergeManager * //// amount of elements to skip for the next index //// for noise/height/biome maps (not vmanip) this->ystride = csize.X; - this->zstride = csize.X * (csize.Y + 2); + // 1-down overgeneration + this->zstride_1d = csize.X * (csize.Y + 1); this->biomemap = new u8[csize.X * csize.Z]; this->heightmap = new s16[csize.X * csize.Z]; @@ -85,8 +86,9 @@ MapgenFractal::MapgenFractal(int mapgenid, MapgenParams *params, EmergeManager * noise_filler_depth = new Noise(&sp->np_filler_depth, seed, csize.X, csize.Z); //// 3D terrain noise - noise_cave1 = new Noise(&sp->np_cave1, seed, csize.X, csize.Y + 2, csize.Z); - noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y + 2, csize.Z); + // 1-down overgeneraion + noise_cave1 = new Noise(&sp->np_cave1, seed, csize.X, csize.Y + 1, csize.Z); + noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y + 1, csize.Z); //// Biome noise noise_heat = new Noise(¶ms->np_biome_heat, seed, csize.X, csize.Z); @@ -694,19 +696,19 @@ void MapgenFractal::generateCaves(s16 max_stone_y) for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) { bool column_is_open = false; // Is column open to overground bool is_tunnel = false; // Is tunnel or tunnel floor - u32 vi = vm->m_area.index(x, node_max.Y + 1, z); - u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride + + u32 vi = vm->m_area.index(x, node_max.Y, z); + u32 index3d = (z - node_min.Z) * zstride_1d + csize.Y * ystride + (x - node_min.X); // Biome of column Biome *biome = (Biome *)bmgr->getRaw(biomemap[index2d]); - for (s16 y = node_max.Y + 1; y >= node_min.Y - 1; - y--, index3d -= ystride, vm->m_area.add_y(em, vi, -1)) { - // 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. - if (y > node_max.Y) - continue; + // 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. + // This 'roof' is removed when the mapchunk above is generated. + for (s16 y = node_max.Y; y >= node_min.Y - 1; y--, + index3d -= ystride, + vm->m_area.add_y(em, vi, -1)) { content_t c = vm->m_data[vi].getContent(); if (c == CONTENT_AIR || c == biome->c_water_top || |