summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/ray.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-03 13:31:13 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-03 15:27:27 +0100
commite79394f321d455748113a360e76050019d41184f (patch)
tree897e6fe4835e74dca33c6cae1f0a47e143af9e9e /crawl-ref/source/ray.cc
parenta836385ed0270fa2e5f440236259407f4ed9c43c (diff)
downloadcrawl-ref-e79394f321d455748113a360e76050019d41184f.tar.gz
crawl-ref-e79394f321d455748113a360e76050019d41184f.zip
Add function to fudge corner ray into a non-solid cell.
Diffstat (limited to 'crawl-ref/source/ray.cc')
-rw-r--r--crawl-ref/source/ray.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/crawl-ref/source/ray.cc b/crawl-ref/source/ray.cc
index 1917baf9b8..fa3aa09ba8 100644
--- a/crawl-ref/source/ray.cc
+++ b/crawl-ref/source/ray.cc
@@ -232,6 +232,28 @@ static geom::line _choose_reflect_line(bool rx, bool ry, bool rxy)
return (l);
}
+geom::vector _fudge_corner(const geom::vector &w, const reflect_grid &rg)
+{
+ geom::vector v = w;
+ if (double_is_integral(v.x))
+ {
+ // just try both sides
+ v.x += 10 * EPSILON_VALUE;
+ if (rg(round_vec(v) + rg_o))
+ v.x -= 20 * EPSILON_VALUE;
+ ASSERT(!rg(round_vec(v) + rg_o));
+ }
+ else
+ {
+ ASSERT(double_is_integral(v.y));
+ v.y += 10 * EPSILON_VALUE;
+ if (rg(round_vec(v) + rg_o))
+ v.y -= 20 * EPSILON_VALUE;
+ ASSERT(!rg(round_vec(v) + rg_o));
+ }
+ return (v);
+}
+
void ray_def::bounce(const reflect_grid &rg)
{
ASSERT(_valid());