From 0a624bcd948148817226c9585db7ce16bf5cb599 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 16 Oct 2009 11:00:40 +0200 Subject: Rewrite find_ray to use precomputed cellrays. During precomputation, we store the minimal cellrays by target and sort them according to niceness. find_ray now simply picks the first non-blocked ray to a target, which means looping through the 10 or so minimal cellrays with that target -- this should be a lot more efficient. (An extended findray test went from 150s to 40s (debug) and 40s to 26s (profile)). The interface to find_ray has changed: cycle_dir=-1,0,1 was changed to cyle=false/true since we never cycle in the other direction anyway. find_shortest was removed: all rays to a target had the same length all along, but now we also return the straightest one automatically. The change also eliminates the duplicate corner-cutting code between ray_def::advance and find_ray as imbalance calculation now relies on ray_def::advance. --- crawl-ref/source/ray.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/ray.h') diff --git a/crawl-ref/source/ray.h b/crawl-ref/source/ray.h index 1565595d7f..0505f8923c 100644 --- a/crawl-ref/source/ray.h +++ b/crawl-ref/source/ray.h @@ -21,9 +21,11 @@ public: double accx; double accy; double slope; + // Quadrant by sign of x/y coordinate. int quadx; int quady; - int fullray_idx; // for cycling: where did we come from? + // For cycling: where did we come from? + int cycle_idx; public: ray_def(double accx = 0.0, double accy = 0.0, double slope = 0.0, -- cgit v1.2.3-54-g00ecf