From a836385ed0270fa2e5f440236259407f4ed9c43c Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Tue, 3 Nov 2009 13:30:43 +0100 Subject: Split _mirror into point and direction parts. --- crawl-ref/source/ray.cc | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'crawl-ref/source/ray.cc') diff --git a/crawl-ref/source/ray.cc b/crawl-ref/source/ray.cc index 6418386a61..1917baf9b8 100644 --- a/crawl-ref/source/ray.cc +++ b/crawl-ref/source/ray.cc @@ -154,19 +154,31 @@ bool ray_def::advance() return (!on_corner); } -static geom::ray _mirror(const geom::ray &rorig, const coord_def &side) +static geom::vector _mirror_pt(const geom::vector &vorig, const coord_def &side) { - geom::ray r = rorig; + geom::vector v = vorig; if (side.x == -1) - { - r.start.x = 1.0 - r.start.x; - r.dir.x = -r.dir.x; - } + v.x = 1.0 - v.x; if (side.y == -1) - { - r.start.y = 1.0 - r.start.y; - r.dir.y = -r.dir.y; - } + v.y = 1.0 - v.y; + return (v); +} + +static geom::vector _mirror_dir(const geom::vector &vorig, const coord_def &side) +{ + geom::vector v = vorig; + if (side.x == -1) + v.x = -v.x; + if (side.y == -1) + v.y = -v.y; + return (v); +} + +static geom::ray _mirror(const geom::ray &rorig, const coord_def &side) +{ + geom::ray r; + r.start = _mirror_pt(rorig.start, side); + r.dir = _mirror_dir(rorig.dir, side); return (r); } -- cgit v1.2.3-54-g00ecf