summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dgn-proclayouts.cc
diff options
context:
space:
mode:
authorBrendan Hickey <brendan@bhickey.net>2013-03-05 20:47:36 -0800
committerBrendan Hickey <brendan@bhickey.net>2013-03-05 20:47:36 -0800
commite58ea8d632696e3d9636991f63af282153febfdc (patch)
treebea11298a7cdbe3f062bdaecca8e9345a653772e /crawl-ref/source/dgn-proclayouts.cc
parente31d4bde2647598477ee61b5cd3935f44eb72ed4 (diff)
downloadcrawl-ref-e58ea8d632696e3d9636991f63af282153febfdc.tar.gz
crawl-ref-e58ea8d632696e3d9636991f63af282153febfdc.zip
Clamp Layout
A procedural layout wrapper that clamps a layout to change no more frequently than some limiting parameter. If you underestimate how rapidly the underlying layout changes, aliasing will occur.
Diffstat (limited to 'crawl-ref/source/dgn-proclayouts.cc')
-rw-r--r--crawl-ref/source/dgn-proclayouts.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/crawl-ref/source/dgn-proclayouts.cc b/crawl-ref/source/dgn-proclayouts.cc
index c3347b1a3d..5655067837 100644
--- a/crawl-ref/source/dgn-proclayouts.cc
+++ b/crawl-ref/source/dgn-proclayouts.cc
@@ -273,3 +273,13 @@ LevelLayout::operator()(const coord_def &p, const uint32_t offset) const
return layout(p, offset);
return ProceduralSample(p, feat, offset + 4096);
}
+
+ProceduralSample
+ClampLayout::operator()(const coord_def &p, const uint32_t offset) const
+{
+ uint32_t order = hash3(p.x, p.y, 0xDEADBEEF);
+ uint32_t clamp_offset = (offset + order) / clamp * clamp;
+ ProceduralSample sample = layout(p, clamp_offset);
+ uint32_t cp = max(sample.changepoint(), offset + order);
+ return ProceduralSample(p, sample.feat(), cp);
+}