aboutsummaryrefslogtreecommitdiff
path: root/src/mg_ore.cpp
diff options
context:
space:
mode:
authorparamat <paramat@users.noreply.github.com>2017-09-30 10:23:57 +0100
committerparamat <mat.gregory@virginmedia.com>2017-10-01 22:31:44 +0100
commite2afcf85ce5945a6ed08313dfed9f68d02912f73 (patch)
tree684f7f9bec103e188289fc2996b495a701651f48 /src/mg_ore.cpp
parent9fa78b7387ec6eb5f6e3419d37ae631085c69e1a (diff)
downloadhax-minetest-server-e2afcf85ce5945a6ed08313dfed9f68d02912f73.tar.gz
hax-minetest-server-e2afcf85ce5945a6ed08313dfed9f68d02912f73.zip
Stratum ore: Allow use with no noise for simple horizontal strata
If either of the 2 noise parameters are omitted the ore will occur from y_min to y_max in a simple horizontal stratum. As this does not compute noise performance improves, and is ideal for placing many layers. Clean up some nearby ore documentation.
Diffstat (limited to 'src/mg_ore.cpp')
-rw-r--r--src/mg_ore.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/mg_ore.cpp b/src/mg_ore.cpp
index 4f4c9c711..979135ed4 100644
--- a/src/mg_ore.cpp
+++ b/src/mg_ore.cpp
@@ -433,14 +433,16 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
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);
+ if (flags & OREFLAG_USE_NOISE) {
+ if (!(noise && noise_stratum_thickness)) {
+ 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);
}
- noise->perlinMap2D(nmin.X, nmin.Z);
- noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z);
size_t index = 0;
@@ -452,10 +454,18 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
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);
+ int y0;
+ int y1;
+
+ if (flags & OREFLAG_USE_NOISE) {
+ float nmid = noise->result[index];
+ float nhalfthick = noise_stratum_thickness->result[index] / 2.0f;
+ y0 = MYMAX(nmin.Y, nmid - nhalfthick);
+ y1 = MYMIN(nmax.Y, nmid + nhalfthick);
+ } else {
+ y0 = nmin.Y;
+ y1 = nmax.Y;
+ }
for (int y = y0; y <= y1; y++) {
if (pr.range(1, clust_scarcity) != 1)