caewok / fvtt-token-visibility

Advanced token visibility rules for Foundry VTT
MIT License
4 stars 8 forks source link

Request: Add a mode that can more accurately recreated dnd5e line of sight #44

Closed Zamrod closed 1 year ago

Zamrod commented 1 year ago

Using the existing line of sight it isn’t possible to see a lot of tokens that you would be able to target with cover or even some tokens you would have no cover at all. You should be able to see them at least so that you can target them.

In the rules you can see something if you can trace a line from the corner of any square you occupy to the corner of any square the other token occupies. In theory, this means that you calculate line of sight from every corner of every square that you occupy and then combine the area of all of that LOS together. I believe that would slow down the game too much with all the extra calculations. I think that you could likely do it practically with only 5 points: Middle and the four corners of the creature's token. Or maybe every outside corner plus the middle for larger creatures.

As an example, in the following case the tokens should only have half cover to each other, making them completely visible to each other, but using the core line of sight they can't see each other at all. I have highlighted the area in green that should be visible according to the rules but isn't:

image

In this second picture the token at the bottom should be able to see the medium sized token above entirely with nothing being covered. The large token should be barely visible.

image

caewok commented 1 year ago

Added in v0.5.4. It is doing the calculations for each corner-to-corner if you select that option. I think performance is fine, because it is just intersection tests for the lines in the line of sight test; it is not redrawing the vision polygon.