Jump to content
  • Advertisement
Sign in to follow this  
rXpSwiss

Difference between distance based collision and bounding box collision

This topic is 2547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

What is the big difference between the distance based collision detection way and the bounding box way ? I know the distance based use the right triangle to calculate the distance between the two objects therefore is it more slow but what is the plus ?
The bounding box way takes two rect and look if they are overlapping and the distance way look the distance between the two but in the end it is the same thing ?
I see it that way :
Bounding Box :
unledkb.jpg


Distance based collision :
unled2cm.jpg



What didn't I get ?

Best regards,

rXp>!<

Share this post


Link to post
Share on other sites
Advertisement
The difference is that one is a spherical detection whilst the other is rectangular.
It comes down to what is best suited for the object.

Share this post


Link to post
Share on other sites

The difference is that one is a spherical detection whilst the other is rectangular.
It comes down to what is best suited for the object.


Yes but the size of the sprite is still height x width size... so square... so no difference ?

Share this post


Link to post
Share on other sites
In the 2-dimensional case there isn't any difference.

Edit: For clarification, there isn't any difference when testing for collision as in your example. Actual differences, however, depend upon context. Are you just testing rectangles, or do your entities represent characters? A typical humanoid shape character can be approximated in 3D space using either a cylinder (based on the distance-based collision metric) or a box (the bounding box metric), in which case the response of the system will be slightly different. However, since a cylinder projected from the side into 2D space is just a box, then there is really no difference between the two methods as long as you are only dealing in 2D.

Share this post


Link to post
Share on other sites
I think with distance based collision detection you can get more accurate collisions where as with using just bounding box collision detection you can get a collision but visually you shouldn't have.

I may be wrong about this though as this is just a theory I haven't experimented too much with collision detection.

Share this post


Link to post
Share on other sites
That is not always true, you can have a sprite that is 10 wide and 100 high, if you draw a circle around that you'll see that it's not very precise.
You usually test the distance to see if you should use more advanced detection.

Share this post


Link to post
Share on other sites
So let's say I want to have collision on the head, the body and the legs : I should have 3 different sprites ?

Yes for 2D

Share this post


Link to post
Share on other sites
The big benefit I can see right away (having never done this before) is the distance method should be adaptable to space simulations where you are already using distance everywhere for gravitational calculations. I assume you could also use the same method for a collision style that causes rapid deceleration rather than abrupt collision (think bubbles). Also, a brief glance around on the subject seems to indicate that distance based is very useful for soft-body objects.

Share this post


Link to post
Share on other sites
The difference is that distance is circular in 2D and spherical in 3D, not square or rectangular like a bounding box.

So on your bottom example, those would be two circles. One with a radius of 2, and the other with a radius of 1. The pythagorean theorem determines the distance between the two as a linear value, instead of a vector of XYZ values, and that distance is used by checking if it's less than the sum of the radii of the two objects in question.

Bounding boxes check the XYZ independently, whereas distance combines XYZ using pythagorean resulting in the circular or spherical check.

distance.jpg

Share this post


Link to post
Share on other sites
Okey I see the advantage of this way in 3D but in 2D I have no use for it ? (except for a totally round sprite)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!