summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dgn-proclayouts.cc
diff options
context:
space:
mode:
authorBrendan Hickey <brendan@bhickey.net>2012-09-20 23:14:51 -0700
committerBrendan Hickey <brendan@bhickey.net>2012-12-30 19:06:14 -0800
commit43754da300b02433c8f78f459daf43212ad9fe44 (patch)
treea203228aefbf053605a6c9292dcabad4dd9ef205 /crawl-ref/source/dgn-proclayouts.cc
parent96d469f78dc30e6d21c65c36b021e161a346deda (diff)
downloadcrawl-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/dgn-proclayouts.cc')
-rw-r--r--crawl-ref/source/dgn-proclayouts.cc74
1 files changed, 36 insertions, 38 deletions
diff --git a/crawl-ref/source/dgn-proclayouts.cc b/crawl-ref/source/dgn-proclayouts.cc
index 6073d1c743..35206a29a5 100644
--- a/crawl-ref/source/dgn-proclayouts.cc
+++ b/crawl-ref/source/dgn-proclayouts.cc
@@ -11,7 +11,7 @@
#include "terrain.h"
#include "worley.h"
-#include "random.h"
+#include "mpr.h"
bool less_dense_than(const dungeon_feature_type &a, const dungeon_feature_type &b)
{
@@ -47,7 +47,21 @@ ColumnLayout::operator()(const coord_def &p, const uint32_t offset) const
return ProceduralSample(p, DNGN_ROCK_WALL, offset + 4096);
return ProceduralSample(p, DNGN_FLOOR, offset + 4096);
}
-
+
+ProceduralSample
+DiamondLayout::operator()(const coord_def &p, const uint32_t offset) const
+{
+
+ uint8_t halfCell = w + s;
+ uint8_t cellSize = halfCell * 2;
+ uint8_t x = abs(abs(p.x) % cellSize - halfCell);
+ uint8_t y = abs(abs(p.y) % cellSize - halfCell);
+ if (x+y < w)
+ return ProceduralSample(p, DNGN_ROCK_WALL, offset + 4096);
+ return ProceduralSample(p, DNGN_FLOOR, offset + 4096);
+}
+
+
uint32_t _get_changepoint(const worley::noise_datum &n, const double scale)
{
return max(1, (int) floor((n.distance[1] - n.distance[0]) * scale));
@@ -66,36 +80,29 @@ WorleyLayout::operator()(const coord_def &p, const uint32_t offset) const
double x = p.x / 5.0;
double y = p.y / 5.0;
double z = offset / scale;
- worley::noise_datum n = worley::noise(x, y, z);
- ProceduralSample sampleA = a(p, offset);
- ProceduralSample sampleB = b(p, offset);
+ worley::noise_datum n = worley::noise(x, y, z + seed);
const uint32_t changepoint = offset + _get_changepoint(n, scale);
+ ProceduralSample sample = (*layouts[n.id[0] % layouts.size()])(p, offset);
- if (n.id[0] % 2)
- return ProceduralSample(p,
- sampleA.feat(),
- min(changepoint, sampleA.changepoint()));
- return ProceduralSample(p,
- sampleB.feat(),
- min(changepoint, sampleB.changepoint()));
+ return ProceduralSample(p, sample.feat(),
+ min(changepoint, sample.changepoint()));
}
ProceduralSample
ChaosLayout::operator()(const coord_def &p, const uint32_t offset) const
{
uint64_t base = hash3(p.x, p.y, seed);
- uint32_t density = 450 + seed % 50 + (seed >> 16) % 60;
+ uint32_t density = baseDensity + seed % 50 + (seed >> 16) % 60;
if ((base % 1000) > density)
return ProceduralSample(p, _pick_pseudorandom_feature(base/3), offset + 4096);
return ProceduralSample(p, DNGN_FLOOR, offset + 4096);
-
}
ProceduralSample
RoilingChaosLayout::operator()(const coord_def &p, const uint32_t offset) const
{
- const double scale = 500.0;
+ const double scale = (density - 350) + 800;
double x = p.x;
double y = p.y;
double z = offset / scale;
@@ -108,34 +115,25 @@ RoilingChaosLayout::operator()(const coord_def &p, const uint32_t offset) const
ProceduralSample
RiverLayout::operator()(const coord_def &p, const uint32_t offset) const
{
- const int periodicity = 100;
- const int baseWidth = 12;
- const double scale = 20000;
- worley::noise_datum n =
- worley::noise(p.x/100.0, p.y/1000.0, offset / scale + seed);
- if ((n.id[0] + n.id[1]) % 6 || p.x % periodicity > baseWidth * 2)
- {
- int cp = offset + _get_changepoint(n, scale);
- ProceduralSample sample = layout(p, offset);
- return _maybe_set_changepoint(sample, cp);
+ const double scale = 1000;
+ const double scalar = 90.0;
+ double x = (p.x + perlin::fBM(p.x/4.0, p.y/4.0, seed, 5) * 3) / scalar;
+ double y = (p.y + perlin::fBM(p.x/4.0 + 3.7, p.y/4.0 + 1.9, seed + 4, 5) * 3) / scalar;
+ worley::noise_datum n = worley::noise(x, y, offset / scale + seed);
+ const uint32_t changepoint = offset + _get_changepoint(n, scale);
+ if ((n.id[0] ^ n.id[1] ^ seed) % 4) {
+ return layout(p, offset);
}
- int xi = p.x + perlin::noise(p.x/4.0, p.y/4.0, offset / scale) * 6;
- int yi = p.y + perlin::noise(p.x/4.0 + 31., p.y/4.0 + 17., offset / scale) * 10;
- int x = xi + sin(yi / 6.0) * 7;
- int width = baseWidth + perlin::noise(p.x/5.0, p.y/5.0, seed) * 6;
- if (x % periodicity < width)
+ double delta = n.distance[1] - n.distance[0];
+ if (delta < 1.25/scalar)
{
dungeon_feature_type feat = DNGN_SHALLOW_WATER;
- if (width > baseWidth && (x + baseWidth/2) % periodicity > width/2)
+ uint64_t hash = hash3(p.x, p.y, n.id[0] + seed);
+ if (!(hash % 5))
feat = DNGN_DEEP_WATER;
- return ProceduralSample(p, feat, offset + 1);
- }
- if ((x + 4) % periodicity < width + 8)
- {
- dungeon_feature_type feat = DNGN_FLOOR;
- if (!(hash3(xi, yi, seed) % 23))
+ if (!(hash % 23))
feat = DNGN_MANGROVE;
- return ProceduralSample(p, feat, offset + 1);
+ return ProceduralSample(p, feat, changepoint);
}
return layout(p, offset);
}