Hello. Can someone please explain the concept of the contact points when checking for collisions? I am using bullet to detect collisions between basic boxes and cylinders. There are times when I am sure there should be a collision, but for some reason it is not indicated. So I decided to take a closer look at the contact points and the corresponding 'distances' so as to maybe check for collisions when objects get within a certain distance to each other:
Sometimes, dist would be a positive number, and sometimes a negative one. Does it represent the distance between the two objects involved in the contact or is it the penetration distance? A clarification would be much appreciated.
There are times when I am sure there should be a collision, but for some reason it is not indicated.
If you think you found a bug, please create a reproduction case in one of the Bullet demos, zip it and attach to this issue. You could try modifying bullet-2.77\Demos\ConvexHullDistance.
Distance definition: when the distance between objects is positive, they are separated. When the distance is negative, they are penetrating. Zero distance means exactly touching.
Thanks,
Erwin
Distance definition: when the distance between objects is positive, they are separated. When the distance is negative, they are penetrating. Zero distance means exactly touching.
But how can I get the distance between objects if they are not colliding? I mean there seem to be contact points only when there are collisions going on (i.e. if contactManifold->getNumContacts() > 0).
Contacts are created when the associated AABBs of the bodies overlap. So a contact is created when two bodies are in close proximity. This doesn't mean necessarily that two objects are touching. This only happens if the closest points distance is less then some user defined margin (e.g. 0.04 m) and in this case the contact point count is greater zero. If you want the distance between two arbitrary bodies you have to perform a distance query yourself.
Dirk Gregorius wrote:Contacts are created when the associated AABBs of the bodies overlap. So a contact is created when two bodies are in close proximity. This doesn't mean necessarily that two objects are touching. This only happens if the closest points distance is less then some user defined margin (e.g. 0.04 m) and in this case the contact point count is greater zero. If you want the distance between two arbitrary bodies you have to perform a distance query yourself.
I see. Thanks a lot. But how can I change this closest distance threshold?
There should be a function called SetMargin(). Anyway, the margin should be a some specific range (maybe 0.05 - 0.01). You cannot choose it arbitrarily large. It is there to implement a concept sometimes refered to as "Shallow Contacts". See for example Gino v.d. Bergens book.