GoRogue icon indicating copy to clipboard operation
GoRogue copied to clipboard

Add FOV Implementations/Options which Consider 1-Thick Diagonal Walls Opaque

Open fcheadle opened this issue 4 years ago • 1 comments

FOV calculations can see through diagonal walls that have a thickness of 1.

To see what I mean, use TheSadRogue.Integration, and add the following lines to Program.cs after line 70:

if(location.X + location.Y == 7)
    map.SetTerrain(new MemoryAwareRogueLikeCell(location, Color.White, Color.Black, '#', 0, false, false));

This creates a simple diagonal line near the player's starting point that SHOULD be solid in some scenarios, or at least, have the option for the user to make them solid and non-transparent.

Simplest fix: make Calculate methods in `FOV virtual to allow for custom implementations.

Screenshot

fcheadle avatar Jun 19 '21 19:06 fcheadle

To clarify; this is not a "bug" in FOV's shadowcasting implementation so much as it's simply a feature which isn't implemented in GoRogue's implementation of that algorithm. It is, however, a valid use case that the library should have some built-in support for.

It is currently possible for a user to fix this on their own for a given use case; the GoRogue FOV system is now built around the IFOV interface, which provides an abstraction sufficient for a user to solve this by creating/implementing their own FOV algorithm which handles diagonal walls in this way.

Further, it is possible for the library to provide some FOV implementation or option that does this; it's just not implemented currently.

There are methods implementing checks into shadowcasting to solve this; so that's one option; we just need to make sure that if we do this, it doesn't affect performance of the overall algorithm. So there are basically 2 options; we can do 1 or both of these:

  1. Modify the current recursive shadowcasting implementations to have an option which considers 1-thick diagonal walls opaque.
  2. Create additional FOV algorithm implementations, such that some of which consider 1-thick diagonal walls opaque.

Chris3606 avatar May 28 '22 15:05 Chris3606