From 26cad481d08432df1c9ace5f1ac23f1fad9a403f Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sun, 24 Mar 2013 22:35:23 -0400 Subject: [PATCH] Vary ore sheet y position by noise --- doc/lua_api.txt | 9 ++++++--- src/mapgen.cpp | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 23f7f856..38b89f14 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -383,9 +383,12 @@ All default ores are of the uniformly-distributed scatter type. that point is greater than the noise_threshhold, giving the ability to create a non-equal distribution of ore. - sheet - Creates a sheet of ore in a blob shape according to the 2d perlin noise described by - the noise_params structure. The height of the blob is randomly scattered, with a maximum - height of clust_size. Here, clust_scarcity and clust_num_ores are ignored. + Creates a sheet of ore in a blob shape according to the 2d perlin noise described by noise_params. + The relative height of the sheet can be controlled by the same perlin noise as well, by specifying + a non-zero 'scale' parameter in noise_params. IMPORTANT: The noise is not transformed by offset or + scale when comparing against the noise threshhold, but scale is used to determine relative height. + The height of the blob is randomly scattered, with a maximum height of clust_size. + clust_scarcity and clust_num_ores are ignored. This is essentially an improved version of the so-called "stratus" ore seen in some unofficial mods. - claylike - NOT YET IMPLEMENTED Places ore if there are no more than clust_scarcity number of specified nodes within a Von Neumann diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 689ad63c..b5deaae5 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -165,12 +165,12 @@ void OreSheet::generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { int index = 0; for (int z = z0; z != z1; z++) for (int x = x0; x != x1; x++) { - - if (noise->result[index++] < nthresh) + float noiseval = noise->result[index++]; + if (noiseval < nthresh) continue; int height = max_height * (1. / pr.range(1, 3)); - int y0 = y_start + pr.range(1, 3) - 1; + int y0 = y_start + np->scale * noiseval; //pr.range(1, 3) - 1; int y1 = y0 + height; for (int y = y0; y != y1; y++) { u32 i = vm->m_area.index(x, y, z);