I’m looking for an easy way to get the distance to a collision entry stored in a collision handler queue. The best explanation of what I want is the distances used to sort the entries when you call sortEntries() on the handler.
Here’s the reason I’m asking. I am working on a small game that uses squads of AI controlled drones that all move together. When things start shooting, I want to check collisions with a large collision sphere belonging to the squad before I bother checking collisions with spheres representing the 10-20 drones in the squad. If the shot doesn’t collide with the squad’s larger sphere, the shot won’t need to check for collision with the 10-20 drones.
To that end, I have the large collision spheres for the squads in a different part of the scene graph than the small spheres the drones use. Thus, I can traverse the part of the scene graph with the squads, without checking collision with the drones (and without having to change bitmasks when I use the same From collider to check collisions with drones later).
The problem is that I need all of the eventual drone collisions in one list, sorted by distance, so I can get the nearest one. If two squads are very near each other, I need to check the drones in both (two collision traversals) and find out what the closest collision out of all of them is.
Of course, I could just calculate all of the distances in my own code, but from my understanding a collision test with two spheres is just a distance check anyway, so if I go and recalculate the distances myself I’m pretty much doubling the labor.
That’s why I’d like to be able to either get the distance that was calculated in the collision detection, or somehow use that distance to sort all of the collision entries from all of the traversals I need to do.
Is this possible?