MaterialFoundry / LockView

Foundry VTT module: Locks the view for the purpose of using Foundry on a digital playmat, such as a horizontally mounted TV. Scales the scene so the gridsize is always displayed corresponding to a real-world size, and can block zooming and panning
15 stars 7 forks source link

[BUG] Overlapping Drawings w/Owned Tokens breaks bounding box functionality #88

Open OpticalShadows opened 2 years ago

OpticalShadows commented 2 years ago

Setup

Describe the bug Creating a camera switching system to limit views to each room a player is in with the drawing tool and the bounding box feature. Having the box perfectly aligned with the walls makes it impossible for doors to be seen/clicked on. Adding padding of approximately 1 grid unit on each side improves the usability. Having multiple of these drawings (shown below) like this breaks the bounding box behavior when a token is in the overlapping zone. Screenshots below show the GM setup as well as the players view zoomed out as far as possible in each scenario.

Screenshots image

Player View in Room A: image

Player View in Room B: image

Player View in overlapped zone: image

Console Log No Errors reported

Additional context This could be an easy fix if there were some kind of view padding setting for the bounding box but this would only solve the issue with square shaped rooms.

Another thought (maybe more of an enhancement) is a bounding box that increases similar to the fog of war for explored areas.

CDeenen commented 1 year ago

Sorry for the late response. This doesn't work because Foundry creates a list of all drawings, Lock View checks these one by one until it finds one that contains the token. It never checks the second rectangle. The bounding box feature was never intended to be used in 'advanced' situations like this. On a map like this, it was more intended to bound the vision within the whole structure (so all 3 rooms) so the players can't pan to, for example, some other stuff on the right. Mainly useful for when you have multiple levels on the map. This is also why I haven't bothered implementing it for other shapes. Padding would work, but like you said, it'd only work on square rooms. Changing the bounding box functionality without supporting polygons wouldn't be worth it. I'm a bit worried about the math involved when checking polygons, since Lock View has to check this quite often, this might impact performance. I'll have a look, but I can't promise anything.