Collision test based on distance compared to object radius

Hello,



I’m currently working on a collision test. I plan on doing this in several steps, each more finegrained then the one before. Reason for this is that the more finegrained you test for collision, the more expensive the test becomes.

The first test I planned on doing is a test where I take the distance between the two objects and compare that against the added collision radii of both objects. If the distance between the objects is smaller then added collision radii, I move to the next level of my collision check.

Reason for this first check is that it’s the simplest one I can come up with, and the fastest, just a simple comparison of two floats.



The o nly problem I’m facing at this time is how to determine the radius. The idea was to take the radius of the bounding volume and go from there, since that at least gives me some idea of the size of the object. The only problem is I can’t figure out how to determine the radius of the bounding volume.



Any thoughts on this is much needed. Or if you can figure out another way to determine the collision radius, that would also be welcome.

The bounding volume is either a BoundingBox or a BoundingSphere, or possibly something else but only if you created that bounding volume and are using it.

So just do a class instanceof check to see which it is and collect the radius from that.