I'm in the process of making an RTS game and I've ran into a problem I could use help with. I want to create a fog of war system that reveals an area around a unit that belongs to you like how it's done in Starcraft 2. To do this, I'm using a 2 dimensional influence map that's stored in a 1 dimensional array to communicate with the FoW texture. Currently, every element in the array is a square tile and to find out whether or not it's revealed, I do a simple distance check but this generates a lot of performance demand on the CPU. Is there a clever way to check if a tile is revealed or not more efficiently? I've been thinking of using hexagons for the job, checking in 6 directions and interpolating the space in between but I'm not sure how to check in a single direction nor how to interpolate the space between.
Note: I'm using C# but pseudocode in any language works for me.
for each unit in unitlist: unit->draw();and make a subclass for drawing your units, then your system is even decoupled from the 3D engine you use, if you later want to switch your 3D engine you don't need to rewrite all your code. – Pedro Mar 20 '15 at 00:43