diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-10-10 12:26:58 +0200 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-10-10 12:26:58 +0200 |
commit | 28112f6099b94dff010198d6b3cbf33d40219a7e (patch) | |
tree | 73ea07a4a36b0f67b00ce993a2abba0026c4b608 /crawl-ref/source/ray.cc | |
parent | 32f7f9c05634d9442ccdc6fcc9bda35ab1f682d7 (diff) | |
download | crawl-ref-28112f6099b94dff010198d6b3cbf33d40219a7e.tar.gz crawl-ref-28112f6099b94dff010198d6b3cbf33d40219a7e.zip |
Move shoot_ray into ray_def.
Diffstat (limited to 'crawl-ref/source/ray.cc')
-rw-r--r-- | crawl-ref/source/ray.cc | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/crawl-ref/source/ray.cc b/crawl-ref/source/ray.cc index a4bb3b21f0..5db398f4e4 100644 --- a/crawl-ref/source/ray.cc +++ b/crawl-ref/source/ray.cc @@ -80,30 +80,8 @@ static int _find_next_intercept(double* accx, double* accy, const double slope) return rc; } -// Shoot a ray from the given start point (accx, accy) with the given -// slope, bounded by LOS radius. Store the visited cells in -// xpos[] and ypos[], and return the number of cells visited. -int shoot_ray(double accx, double accy, const double slope, - int maxrange, int xpos[], int ypos[]) -{ - int curx, cury; - int cellnum; - for (cellnum = 0; true; ++cellnum) - { - _find_next_intercept(&accx, &accy, slope); - curx = static_cast<int>(accx); - cury = static_cast<int>(accy); - if (curx*curx + cury*cury > get_los_radius_squared()) - break; - - xpos[cellnum] = curx; - ypos[cellnum] = cury; - } - return cellnum; -} - -ray_def::ray_def() - : accx(0.0), accy(0.0), slope(0.0), quadrant(0), fullray_idx(-1) +ray_def::ray_def(double ax, double ay, double s, int q, int idx) + : accx(ax), accy(ay), slope(s), quadrant(q), fullray_idx(idx) { } @@ -340,3 +318,25 @@ int ray_def::raw_advance() } } +// Shoot a ray from the given start point (accx, accy) with the given +// slope, bounded by the given pre-squared LOS radius. +// Store the visited cells in xpos[] and ypos[], and +// return the number of cells visited. +int ray_def::footprint(int radius2, int xpos[], int ypos[]) +{ + int curx, cury; + int cellnum; + for (cellnum = 0; true; ++cellnum) + { + _find_next_intercept(&accx, &accy, slope); + curx = static_cast<int>(accx); + cury = static_cast<int>(accy); + if (curx*curx + cury*cury > radius2) + break; + + xpos[cellnum] = curx; + ypos[cellnum] = cury; + } + return cellnum; +} + |