Skip to content
Permalink
Browse files

Fix spelling of noise_threshold

  • Loading branch information
zhangjunphy authored and BlockMen committed Dec 6, 2015
1 parent 70ece71 commit a78dd7f2b6b0e1fefdbaa1ae21b722dd4459e4f4
Showing with 19 additions and 10 deletions.
  1. +3 −3 doc/lua_api.txt
  2. +1 −1 games/minimal/mods/default/mapgen.lua
  3. +1 −1 src/mg_ore.h
  4. +4 −4 src/noise.cpp
  5. +10 −1 src/script/lua_api/l_mapgen.cpp
@@ -763,7 +763,7 @@ Creates veins of ore varying in density by according to the intersection of two
instances of 3d perlin noise with diffferent seeds, both described by
`noise_params`. `random_factor` varies the influence random chance has on
placement of an ore inside the vein, which is `1` by default. Note that
modifying this parameter may require adjusting `noise_threshhold`.
modifying this parameter may require adjusting `noise_threshold`.
The parameters `clust_scarcity`, `clust_num_ores`, and `clust_size` are ignored
by this ore type. This ore type is difficult to control since it is sensitive
to small changes. The following is a decent set of parameters to work from:
@@ -777,7 +777,7 @@ to small changes. The following is a decent set of parameters to work from:
persist = 0.5,
flags = "eased",
},
noise_threshhold = 1.6
noise_threshold = 1.6

WARNING: Use this ore type *very* sparingly since it is ~200x more
computationally expensive than any other ore.
@@ -3572,7 +3572,7 @@ Definition tables
y_max = 64,
flags = "",
-- ^ Attributes for this ore generation
noise_threshhold = 0.5,
noise_threshold = 0.5,
-- ^ If noise is above this threshold, ore is placed. Not needed for a uniform distribution
noise_params = {offset=0, scale=1, spread={x=100, y=100, z=100}, seed=23, octaves=3, persist=0.70}
-- ^ NoiseParams structure describing the perlin noise used for ore distribution.
@@ -36,7 +36,7 @@ minetest.register_ore({
clust_size = 7,
y_min = -15,
y_max = 0,
noise_threshhold = 0,
noise_threshold = 0,
noise_params = {
offset=0.35,
scale=0.2,
@@ -61,7 +61,7 @@ class Ore : public ObjDef, public NodeResolver {
s16 y_max;
u8 ore_param2; // to set node-specific attributes
u32 flags; // attributes for this ore
float nthresh; // threshhold for noise at which an ore is placed
float nthresh; // threshold for noise at which an ore is placed
NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering)
Noise *noise;
std::set<u8> biomes;
@@ -99,17 +99,17 @@ u32 PcgRandom::range(u32 bound)
Using rand() % 3, the number 0 would be twice as likely to appear.
With a very large RNG range, the effect becomes less prevalent but
still present. This can be solved by modifying the range of the RNG
to become a multiple of bound by dropping values above the a threshhold.
In our example, threshhold == 4 - 3 = 1 % 3 == 1, so reject 0, thus
to become a multiple of bound by dropping values above the a threshold.
In our example, threshold == 4 - 3 = 1 % 3 == 1, so reject 0, thus
making the range 3 with no bias.
This loop looks dangerous, but will always terminate due to the
RNG's property of uniformity.
*/
u32 threshhold = -bound % bound;
u32 threshold = -bound % bound;
u32 r;

while ((r = next()) < threshhold)
while ((r = next()) < threshold)
;

return r % bound;
@@ -944,10 +944,19 @@ int ModApiMapgen::l_register_ore(lua_State *L)
ore->clust_scarcity = getintfield_default(L, index, "clust_scarcity", 1);
ore->clust_num_ores = getintfield_default(L, index, "clust_num_ores", 1);
ore->clust_size = getintfield_default(L, index, "clust_size", 0);
ore->nthresh = getfloatfield_default(L, index, "noise_threshhold", 0);
ore->noise = NULL;
ore->flags = 0;

//// Get noise_threshold
warn_if_field_exists(L, index, "noise_threshhold",
"Deprecated: new name is \"noise_threshold\".");

int nthresh;

This comment has been minimized.

Copy link
@kwolekr

kwolekr Dec 7, 2015

Contributor

This completely breaks noise-based ore, ore->nthresh is a float.

if (!getintfield(L, index, "noise_threshold", nthresh) &&
!getintfield(L, index, "noise_threshhold", nthresh))

This comment has been minimized.

Copy link
@LazyJ

LazyJ Dec 6, 2015

"threshold" is misspelled here (line 956), too. :)

This comment has been minimized.

Copy link
@paramat

paramat Dec 6, 2015

Member

That's intentional, it's checking for both uses for compatibility.

nthresh = 0;
ore->nthresh = nthresh;

//// Get y_min/y_max
warn_if_field_exists(L, index, "height_min",
"Deprecated: new name is \"y_min\".");

0 comments on commit a78dd7f

Please sign in to comment.