aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2015-11-13 07:16:15 +0000
committerparamat <mat.gregory@virginmedia.com>2015-11-14 07:54:03 +0000
commitfc89f467009822b5294967e3e58dbb2fd792bc44 (patch)
tree21a4404ee6807d64da16087d5d3240d3933e1f45
parent987d6a82f639126d5d8833739499150da286bdda (diff)
downloadminetest-fc89f467009822b5294967e3e58dbb2fd792bc44.tar.gz
minetest-fc89f467009822b5294967e3e58dbb2fd792bc44.tar.bz2
minetest-fc89f467009822b5294967e3e58dbb2fd792bc44.zip
Decoration API: Fix missing low density decorations
For a decoration count between 0 and 1 calculate a chance for 1
-rw-r--r--src/mg_decoration.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mg_decoration.cpp b/src/mg_decoration.cpp
index 1e50ba0de..5959af259 100644
--- a/src/mg_decoration.cpp
+++ b/src/mg_decoration.cpp
@@ -117,7 +117,15 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
float nval = (flags & DECO_USE_NOISE) ?
NoisePerlin2D(&np, p2d_center.X, p2d_center.Y, mapseed) :
fill_ratio;
- u32 deco_count = area * MYMAX(nval, 0.f);
+ u32 deco_count = 0;
+ float deco_count_f = (float)area * nval;
+ if (deco_count_f >= 1.f) {
+ deco_count = deco_count_f;
+ } else if (deco_count_f > 0.f) {
+ // For low density decorations calculate a chance for 1 decoration
+ if (ps.range(1000) <= deco_count_f * 1000.f)
+ deco_count = 1;
+ }
for (u32 i = 0; i < deco_count; i++) {
s16 x = ps.range(p2d_min.X, p2d_max.X);