For the simulation I am writing, one of the things I need to be able to test is find units within a certain radius of a given unit. I was wondering if there was an easy way to query the scene graph for such queries, or do people normally maintain a separate location graph to handle such queries?.
Also was wondering how people handle such things in general? Do people maintain two graphs, one the actual graph that contains all the units in the game and one graph (the render graph ) which gets populated every frame?
I would think of something like this
-> an OctTree based scene graph to do quick radius checks
-> Every frame
-> Walk octTree and find nodes visible to the player
-> for all visible nodes add to render graph
-> render frame
-> clear render graph [ how would one do this, detach the nodes individually? ]
Any ideas on how to accomplish something similar without maintaining a separate graph?
using the good old collision system with spheres will do a good job, combined with an octree-structured scene graph.
using a collisionqueue you can directly get a list of nodes involved in the collision.
just in case you are thinking about implementing frustum-culling. panda does that by default already.
Its not collisions i am looking for. This is for the AI of an unit to be able to respond when certain units come into its visibility radius. So I want to be able to check for every unit if there are hostile units nearby.
Not looking to implement frustum culling. Just reducing the number of units I need to go through to find nearby units.