summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/ray.cc
Commit message (Collapse)AuthorAgeFilesLines
* Add formatting fixes.David Lawrence Ramsey2009-11-211-2/+2
| | | | This mostly puts && and || on the proper lines, per the style guide.
* Convert reflect_grid to SquareArray.Robert Vollmert2009-11-081-12/+12
|
* Put DJGPP's round() into a #define so other builds don't suffer.Adam Borowski2009-11-061-2/+2
|
* Standard <cmath> has no round().Adam Borowski2009-11-061-2/+2
|
* A variety of changes to make the reflection code more robust.Robert Vollmert2009-11-051-20/+76
| | | | | In particular, round things to grid or corner when they're regarded as on the grid or corner, and normalize direction vectors.
* Add get_degrees and set_degrees to ray_def; reenable chaos bolt munging.Robert Vollmert2009-11-031-0/+11
|
* Split up ray_def::bounce and implement better corner handling.Robert Vollmert2009-11-031-58/+144
| | | | | | | | | | | | | | | | Rays shot directly at diagonal walls should now reflect appropriately. For this, diagonal walls are assumed to be flat. Example: ...### @***## ...*.# ...*.. It's different from before, but I think it's probably a nice change without huge impact.
* Improve reflections when starting in a corner.Robert Vollmert2009-11-031-8/+8
|
* Move regress next to advance.Robert Vollmert2009-11-031-9/+9
|
* Also assert validity in ray_def::pos().Robert Vollmert2009-11-031-0/+1
|
* Fix a bug with corner rays.Robert Vollmert2009-11-031-7/+28
| | | | | Rays that reflected on corners could go too far. Now passes the bounce test.
* Add function to fudge corner ray into a non-solid cell.Robert Vollmert2009-11-031-0/+22
|
* Split _mirror into point and direction parts.Robert Vollmert2009-11-031-10/+22
|
* Add round_vec.Robert Vollmert2009-11-031-3/+8
|
* Bug fixes.Robert Vollmert2009-11-031-1/+1
|
* ray_def::bounce now guarantees it leaves the ray in a clear tile.Robert Vollmert2009-11-031-12/+7
|
* Add pre- and post-asserts to ray_def::regress.Robert Vollmert2009-11-031-0/+2
|
* Fix bugs in diagonal corridor reflections.Robert Vollmert2009-11-031-2/+2
|
* Move reflection line choice into separate function.Robert Vollmert2009-11-031-45/+52
|
* Implement diagonal corridor reflections.Robert Vollmert2009-11-031-3/+13
|
* Possibly fix diagonal corridor asserts.Robert Vollmert2009-11-031-1/+2
|
* Fix diagonal corner case leaving the ray on the boundary.Robert Vollmert2009-11-031-0/+1
|
* Refine ray_def assertions.Robert Vollmert2009-11-031-3/+22
| | | | | ray_def::advance() and ray_def::bounce() now check pre- and post- conditions on validity.
* Make ray.cc ASSERTs a little safer.Robert Vollmert2009-11-021-10/+32
| | | | | | | Not sure if this helps with the chain lightning problems, but the assertions should be less likely to trigger wrongly now. Also deal with "on_corner" in bounce().
* Some changes to the reflection details.Robert Vollmert2009-11-011-15/+25
| | | | | | | | | | | | | | | | | In particular, don't flatten outer corners, so air elementalists aren't hurt too badly. Also, start special casing rays that pass through corners, though they don't currently work the way I want for diagonals. Should now be usable including reflections. TODO - Diagonal wall reflections, both for corner rays and diagonal corridors. - Reenable chaos beam munging. - Fix test/los_maps.lua. It would be easy to make the test pass, but I should really work out what the result should be first. - Generally clean up reflections code -- it's a mess.
* Permit rays to go from diamond directly to diamond.Robert Vollmert2009-11-011-1/+1
| | | | | | | Also recenter the cardinal direction rays. Before, we didn't have centered rays going straight north/south or east/west, which was awkward for shift-firing.
* Implement reflection (except for the diagonal corridor case).Robert Vollmert2009-11-011-12/+145
| | | | | | | | | Reflection is modelled on diamond-shaped features, with gaps filled in as far as they don't affect LOS. Working on a case by case analysis: After normalization, a ray leaves cell * through the south-east diamond face. Then determine the line of reflection in each case.
* Simplify geom2d ray advance code.Robert Vollmert2009-11-011-5/+6
|
* Add a bunch of ASSERTs to ray.cc.Robert Vollmert2009-11-011-1/+43
|
* Change ray_def bouncing interface.Robert Vollmert2009-11-011-1/+1
| | | | | | | For one, rename ray_def::advance_and_bounce to ray_def::bounce. Then, pass a grid of bools for adjacent cells which states which cells are considered solid (reflecting).
* Some geom2d changes.Robert Vollmert2009-11-011-3/+3
| | | | | 1. Add function to reflect vector at a line. 2. Implement scalar multiplication as external operator.
* Make nextcell and movehalfcell methods of geom::ray.Robert Vollmert2009-11-011-4/+4
| | | | | Seems sensible given they modify the ray, even if it's not really something intrinsic to a ray.
* ray_def introductory comment.Robert Vollmert2009-11-011-2/+10
|
* Change corner handling.Robert Vollmert2009-11-011-3/+29
| | | | | | | | ray_def should now deal with hitting corners gracefully, though the raycasting will still discard such rays. If a ray hits a corner between two diamonds, it will stay there, and calling ray_def::pos will arbitrarily give one of the squares -- this is not optimal, but these rays shouldn't usually show up anyway.
* Replace ray_def by a version using "diamond rays".Robert Vollmert2009-11-011-181/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Think of the map tiled with squares (the cells). Previously, a ray was blocked by any part of an opaque cell except the very corners (to allow looking through diagonal maps -- we can move through those after all). In the new version, the rays are the same, but a dungeon feature is only considered to occupy the the central "diamond": convex hull of the mid points of the edges. The corners of the diamond are considered part of the feature, so vertically or horizontally adjacent walls still block. This has some effect on LOS: It's a bit more permissive on diagonals and around corners. The main advantage is that most rays will now have a footprint (the sequence of cells it passes through) that is like the old anti-aliased rays, without requiring any ray munging. TODO: * Make sure we don't hang because of stopping at a corner. * Implement proper bouncing. * Reenable setting/getting degrees for chaos beams.
* Remove get/set_degrees from ray_def.Robert Vollmert2009-11-011-41/+0
| | | | These were used by the temporarily disabled chaos beams.
* Remove ray antialiasing.Robert Vollmert2009-11-011-38/+3
| | | | | | | | | | | | | | | | | | | | | | Previously, rays were always cut short at corners: If a ray really went like ..... @**.. ..*** ..... it was cut short (for find_ray/targetting/shooting purposes) to ..... @*... ..*** ..... Note that a wall at the removed cell would still block the given ray! This makes ray footprint length matter, so rays are sorted to prefer those that pass through fewer cells. However, this gives quite a few ugly beams, in particular around corners.
* versioning: remove SVN-specific revision data, add Git versioningSteven Noonan2009-10-181-1/+0
| | | | Signed-off-by: Steven Noonan <steven@uplinklabs.net>
* Remove obsolete copy of footprint().Robert Vollmert2009-10-181-21/+0
|
* Naming consistency.Robert Vollmert2009-10-171-3/+3
| | | | | Mostly rename functions from terrain.h that accept features of typ dgn_feature_type from grid_is_* to feat_is_*.
* Rewrite find_ray to use precomputed cellrays.Robert Vollmert2009-10-161-1/+1
| | | | | | | | | | | | | | | | | | | | | 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.
* Replace quadrants by signs.Robert Vollmert2009-10-141-81/+45
|
* Clean up.Robert Vollmert2009-10-141-4/+4
| | | | Made some functions "static" and improved quadrant flipping.
* Make advance direction and quadrants explicit as enums.Robert Vollmert2009-10-111-45/+44
|
* More ray_def simplification.Robert Vollmert2009-10-111-32/+18
|
* Some more ray_def cleanup.Robert Vollmert2009-10-111-19/+18
|
* Simplify quadrant mirroring in ray_def::raw_advance.Robert Vollmert2009-10-111-8/+8
|
* Use floor() instead of static_cast<int> for rounding.Robert Vollmert2009-10-111-5/+25
| | | | | This way the code is less likely to fall over with negative coordinates.
* Move _find_next_intercept into ray_def.Robert Vollmert2009-10-111-85/+82
|
* Formatting.Robert Vollmert2009-10-111-9/+9
|