diff options
author | Paramat <paramat@users.noreply.github.com> | 2017-09-03 21:32:21 +0100 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-09-03 22:32:21 +0200 |
commit | 9f6d90aa811dd8f523b137d602127d31307ea15c (patch) | |
tree | fa92018a3ddd212f30fbfe08804313218153d0b9 /src/mg_ore.cpp | |
parent | 5bef3393889e0a29155a7e777d19344eaaae96b7 (diff) | |
download | minetest-9f6d90aa811dd8f523b137d602127d31307ea15c.tar.gz minetest-9f6d90aa811dd8f523b137d602127d31307ea15c.tar.bz2 minetest-9f6d90aa811dd8f523b137d602127d31307ea15c.zip |
Ores: Add stratum ore (#6352)
Creates a single undulating ore stratum that is continuous across mapchunk
borders and horizontally spans the world.
Due to being continuous is ideal for creating bands of alternative stone
type running through cliffs and mountains, or underground layers.
Add missing documentation of 'ore_param2' parameter.
Diffstat (limited to 'src/mg_ore.cpp')
-rw-r--r-- | src/mg_ore.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/mg_ore.cpp b/src/mg_ore.cpp index 5f11dda92..54e332116 100644 --- a/src/mg_ore.cpp +++ b/src/mg_ore.cpp @@ -74,6 +74,7 @@ void OreManager::clear() /////////////////////////////////////////////////////////////////////////////// + Ore::~Ore() { delete noise; @@ -221,6 +222,8 @@ void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed, /////////////////////////////////////////////////////////////////////////////// + + OrePuff::~OrePuff() { delete noise_puff_top; @@ -365,6 +368,8 @@ void OreBlob::generate(MMVManip *vm, int mapseed, u32 blockseed, /////////////////////////////////////////////////////////////////////////////// + + OreVein::~OreVein() { delete noise2; @@ -422,3 +427,58 @@ void OreVein::generate(MMVManip *vm, int mapseed, u32 blockseed, vm->m_data[i] = n_ore; } } + + +/////////////////////////////////////////////////////////////////////////////// + + +OreStratum::~OreStratum() +{ + delete noise_stratum_thickness; +} + + +void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed, + v3s16 nmin, v3s16 nmax, u8 *biomemap) +{ + PcgRandom pr(blockseed + 4234); + MapNode n_ore(c_ore, 0, ore_param2); + + if (!noise) { + int sx = nmax.X - nmin.X + 1; + int sz = nmax.Z - nmin.Z + 1; + noise = new Noise(&np, 0, sx, sz); + noise_stratum_thickness = new Noise(&np_stratum_thickness, 0, sx, sz); + } + noise->perlinMap2D(nmin.X, nmin.Z); + noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z); + + size_t index = 0; + + for (int z = nmin.Z; z <= nmax.Z; z++) + for (int x = nmin.X; x <= nmax.X; x++, index++) { + if (biomemap && !biomes.empty()) { + std::unordered_set<u8>::const_iterator it = biomes.find(biomemap[index]); + if (it == biomes.end()) + continue; + } + + float nmid = noise->result[index]; + float nhalfthick = noise_stratum_thickness->result[index] / 2.0f; + int y0 = MYMAX(nmin.Y, nmid - nhalfthick); + int y1 = MYMIN(nmax.Y, nmid + nhalfthick); + + for (int y = y0; y <= y1; y++) { + if (pr.range(1, clust_scarcity) != 1) + continue; + + u32 i = vm->m_area.index(x, y, z); + if (!vm->m_area.contains(i)) + continue; + if (!CONTAINS(c_wherein, vm->m_data[i].getContent())) + continue; + + vm->m_data[i] = n_ore; + } + } +} |