Knowing the field of view (fov) of an object, provides some interesting use cases. Determination of what is in sight of a character, lightening…and other ideas. There are some brilliant algorithms for bitmap based calculations out there: BASIC, Digital, Permissive (several variations) and ShadowCasting. I decided to implement the ShadowCast algorithm in as3, due to the overall performance in indoor and outdoor environments.
Here is a simple example, to show the functionality (click for interaction):
My implementation is very specialized and contains a lot of redundant code. Initially, I planned to create a flexible implementation, detached from bitmaps and visibility rules, handled by a given object. Mainly responsible for that is the fact, that function calls are relatively expensive.
Do you have any ideas to further improve the performance?
Here ist the source: