diff options
author | Brendan Hickey <brendan@bhickey.net> | 2013-03-05 20:47:36 -0800 |
---|---|---|
committer | Brendan Hickey <brendan@bhickey.net> | 2013-03-05 20:47:36 -0800 |
commit | e58ea8d632696e3d9636991f63af282153febfdc (patch) | |
tree | bea11298a7cdbe3f062bdaecca8e9345a653772e /crawl-ref/source/dgn-proclayouts.cc | |
parent | e31d4bde2647598477ee61b5cd3935f44eb72ed4 (diff) | |
download | crawl-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.cc | 10 |
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); +} |