I have a simulation of shipping traffic around the world, which is displayed on a 3d globe via java opengl (my question has nothing to do with java opengl though). I would like to be able to evaluate which units can be “seen” by another team of units. The end effect is pretty much a fog of war. The unit’s positions are stored in spherical coordinates and I will probably just assess distances between units to determine if one can see the other. If a unit not owned by the user is seen by a unit “owned” by the user, this non-user unit will be rendered on the globe (along with all the user’s units). The problem is I would like there to be many units and for the evaluations to be carried out quite often. I have asked this question on another site and the only advice I got was to not model that many objects, which isn’t helpful. What I really want to know is what is the best way to make these evaluations given that I have a very large number of units that can be detected and units that are capable of detecting.
I am currently planning to take a list of all non-user units and iteratively consider whether or not each one can be seen. This involves taking one of the non-user units and then iterating through the user’s units to evaluate if one of them sees it. If none of the user units see it, the non-user unit is not flagged for rendering and I move on to evaluating the next non-user unit. If a user unit did see that non-user unit, I stop the evaluation, flag the unit, and move on to evaluating the next non-user unit.
I would appreciate any advice on how to make this better. Perhaps some heuristic tricks could be of use here.