From 4b553ece09908dfdee59e9841fdc9420350eda9f Mon Sep 17 00:00:00 2001 From: paramat Date: Sat, 18 Nov 2017 20:37:00 +0000 Subject: Stratum ore: Add option for a constant thickness stratum Add a 'stratum thickness' integer parameter, as an alternative to providing a 2nd noise parameter for thickness variation. --- src/mapgen/mg_ore.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/mapgen/mg_ore.cpp') diff --git a/src/mapgen/mg_ore.cpp b/src/mapgen/mg_ore.cpp index 979135ed4..297472420 100644 --- a/src/mapgen/mg_ore.cpp +++ b/src/mapgen/mg_ore.cpp @@ -434,13 +434,20 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed, MapNode n_ore(c_ore, 0, ore_param2); if (flags & OREFLAG_USE_NOISE) { - if (!(noise && noise_stratum_thickness)) { + 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); + } + + if (flags & OREFLAG_USE_NOISE2) { + if (!noise_stratum_thickness) { + int sx = nmax.X - nmin.X + 1; + int sz = nmax.Z - nmin.Z + 1; + noise_stratum_thickness = new Noise(&np_stratum_thickness, 0, sx, sz); + } noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z); } @@ -458,11 +465,13 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed, int y1; if (flags & OREFLAG_USE_NOISE) { + float nhalfthick = ((flags & OREFLAG_USE_NOISE2) ? + noise_stratum_thickness->result[index] : (float)stratum_thickness) / + 2.0f; float nmid = noise->result[index]; - float nhalfthick = noise_stratum_thickness->result[index] / 2.0f; - y0 = MYMAX(nmin.Y, nmid - nhalfthick); + y0 = MYMAX(nmin.Y, ceil(nmid - nhalfthick)); y1 = MYMIN(nmax.Y, nmid + nhalfthick); - } else { + } else { // Simple horizontal stratum y0 = nmin.Y; y1 = nmax.Y; } -- cgit v1.2.3