10
\$\begingroup\$

I'm working on a Roguelike, and for it I've created a ray-tracing/casting field-of-view (FoV) algorithm that consists of plotting Bresenham lines to every point in a solid circle. It's artifact free (and reasonably efficient), but it is missing an important requirement of mine: symmetry (if you can see a monster, it must also be able to see you).

enter image description here

Here's an example of the non-symmetric behavior of my code. In the left image I'm standing in a corner (red 'X' blocks = wall). I'm able to see the top right tiles. However, if I move to one of those tiles (right image), I can no longer see the tile from which I came from.

I think I might be after a form of Permissive Field of View, but only because the Roguebasin article suggested it allowed for symmetry. Are there alternative means to get symmetry?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Just ensure the eye point is in the same position as the position you're casting the ray to when testing visibility. \$\endgroup\$
    – House
    Jan 9, 2014 at 16:32

1 Answer 1

8
\$\begingroup\$

It seems you include a square when you can see any point in it while the eye is at the single fixed point.

However, you should only include a square when you can see the middle of it (assuming the "eye" is also in the middle). Or you can draw rays from each corner of the starting square to the corners of the tested square, if you can see any from any then include.

The key point is that the hitbox of a square should also be all the locations where the eye must be.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .