From e79394f321d455748113a360e76050019d41184f Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Tue, 3 Nov 2009 13:31:13 +0100 Subject: Add function to fudge corner ray into a non-solid cell. --- crawl-ref/source/ray.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crawl-ref/source') 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()); -- cgit v1.2.3-54-g00ecf