Diagonal line of sight with two corners
- by Ash Blue
Right now I'm using Bresenham's line algorithm for line of sight. The problem is I've found an edge case where players can look through walls. Occurs when the player looks between two corners of a wall with a gap on the other side at specific angles.
The result I want is for the tile between two walls to be marked invalid as so.
What is the fastest way to modify Bresenham's line algorithm to solve this? If there isn't a good solution, is there a better suited algorithm? Any ideas are welcome. Please note the solution should also be capable of supporting 3d.
Edit: For the working source code and an interactive demo of the completed product please see http://ashblue.github.io/javascript-pathfinding/