Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
Just ensure the eye point is in the same position as the position you're casting the ray to when testing visibility. –  Byte56 Jan 9 at 16:32
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.