Hi, I've been using FOW in my game for a few weeks and I've been thinking about some optimizations:
1) my units are stationary most of the time. I was thinking about leaving their LOSChecks value as OnlyOnce while they're standing still, and only set it to EveryUpdate while they're actually moving. Is it safe to set this on my revealer in the main thread? I think this would be a huge optimization.
2) As a test, I took my running game and for one FOWRevealer instance, I set the LOSChecks value to OnlyOnce in Unity's inspector. I immediately got an out of bounds crash here (in RevealIntoCache):
http://screencast.com/t/Bt4ivGYfb5The size of the buffer is 41616 ( or 204*204 as determined by xmax - ymin) but the range given by ymax-ymin is actually 205. The actually array index into r.cachedBuffer is 41709. I believe this is a rounding error in this code:
http://screencast.com/t/VnJMUXDFaMjQ.
One artificial way of fixing this is to set ymax be exactly ymin + ( xmax - xmin ). What do you think?
3) In RevealUsingLOS and RevealUsingRadius, there is a two-level nested for() loop that performs a check that x and y are within the bounds of the texture size. Can't those checks be pulled out of the for() loops for optimization? What if we clamped ymin,ymax,xmin,xmax like this?
http://screencast.com/t/u5rqTvDmThanks in advance,
jeff