diff options
author | Brendan Hickey <brendan@bhickey.net> | 2012-09-20 23:14:51 -0700 |
---|---|---|
committer | Brendan Hickey <brendan@bhickey.net> | 2012-12-30 19:06:14 -0800 |
commit | 43754da300b02433c8f78f459daf43212ad9fe44 (patch) | |
tree | a203228aefbf053605a6c9292dcabad4dd9ef205 /crawl-ref/source/perlin.cc | |
parent | 96d469f78dc30e6d21c65c36b021e161a346deda (diff) | |
download | crawl-ref-43754da300b02433c8f78f459daf43212ad9fe44.tar.gz crawl-ref-43754da300b02433c8f78f459daf43212ad9fe44.zip |
Abyss layout changes
Futzing around quite a bit with the abyss layout.
Diffstat (limited to 'crawl-ref/source/perlin.cc')
-rw-r--r-- | crawl-ref/source/perlin.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crawl-ref/source/perlin.cc b/crawl-ref/source/perlin.cc index 3705874fcf..453fbad1d9 100644 --- a/crawl-ref/source/perlin.cc +++ b/crawl-ref/source/perlin.cc @@ -357,4 +357,28 @@ namespace perlin // Sum up and scale the result to cover the range [-1,1] return 27.0 * (n0 + n1 + n2 + n3 + n4); } + + double fBM(double x, double y, double z, uint32_t octaves) { + if (octaves < 1) + return 0.0; + if (octaves == 1) + return noise(x, y, z); + + uint32_t divisor = 1; + double norm = 0.0; + double value = 0; + double xi = x; + double yi = y; + double zi = z; + for (uint32_t octave = 0; octave < octaves; ++octave) { + value += noise(xi / divisor, yi / divisor, zi / divisor) / divisor; + norm += 1/divisor; + divisor *= 2; + double xt = yi * sin(1.41421356) + cos(1.41421356); + yi = yi * cos(1.41421356) + sin(1.41421356); + xi = xt; + zi += 1.7; + } + return value / norm; + } } |