summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/geom2d.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-30 14:19:21 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-01 21:45:24 +0100
commit03350fc556e032072673562dc15f06920bc5fc87 (patch)
tree908b37dee75bfe44271c1a986c58cff5e597208b /crawl-ref/source/geom2d.cc
parent8145afa69c7dd611850e521a557dc082a21e9e02 (diff)
downloadcrawl-ref-03350fc556e032072673562dc15f06920bc5fc87.tar.gz
crawl-ref-03350fc556e032072673562dc15f06920bc5fc87.zip
Simplify geom2d.cc to stop at corners.
Remove the unsure fudging. This does introduce the possiblity of hanging in place.
Diffstat (limited to 'crawl-ref/source/geom2d.cc')
-rw-r--r--crawl-ref/source/geom2d.cc25
1 files changed, 6 insertions, 19 deletions
diff --git a/crawl-ref/source/geom2d.cc b/crawl-ref/source/geom2d.cc
index ddb2ec771d..62930aec9c 100644
--- a/crawl-ref/source/geom2d.cc
+++ b/crawl-ref/source/geom2d.cc
@@ -68,10 +68,10 @@ static double tdist(const ray &r, const lineseq &ls)
}
// Shoot the ray inside the next cell.
-// Returns whether it hit a corner of the grid.
+// Returns true if succesfully advanced, false if aborted due to corner.
bool nextcell(ray &r, const grid &g, bool pass_corner)
{
- // XXX: ASSERT(!parallel(g.vert, g.horiz));
+ // ASSERT(!parallel(g.vert, g.horiz));
lineseq ls;
if (parallel(r.dir, g.ls1.f))
ls = g.ls2;
@@ -84,29 +84,16 @@ bool nextcell(ray &r, const grid &g, bool pass_corner)
double sd = tdist(r, g.ls1);
double td = tdist(r, g.ls2);
if (double_is_zero(s - t))
- {
- // Hitting the corner.
- r.advance(s);
- double u = std::min(sd, td);
- if (pass_corner)
- r.advance(0.5 * u);
- else
- {
- // XXX: fudge ray into off-diagonal cell.
- r.start.x += 0.001 * u * r.dir.y;
- r.start.y += -0.001 * u * r.dir.x;
- }
- return (true);
- }
+ return (false);
double dmin = std::min(s,t);
double dnext = std::min(std::max(s,t), dmin + std::min(sd, td));
r.advance((dmin + dnext) / 2.0);
- return (false);
+ return (true);
}
- // advance an extra half
+ // parallel: just advance an extra half
double s = nextintersect(r, ls);
r.advance(s + 0.5 * tdist(r, ls));
- return (false);
+ return (true);
}