NeedsResponse Overlap Question

thePoet
Posts: 17
Joined: Tue Apr 15, 2008 4:14 pm

NeedsResponse Overlap Question

Post by thePoet »

I'm trying to ascertain the accuracy of detecting whether an object is within another object using the NeedsResponse function. What kind of likelyhood is it that the NeedsResponse function will see an overlap of the aabb space, but the objects aren't actually overlapped? For example, if you had a very large sphere with a small sphere that isn't overlapping, but is sitting in space that where there would be an overlap if the large sphere had been a box, will NeedsResponse be called on that as an overlap?

Sorry if this is a dumb question, I'm still trying to completely understand what the algorithm is doing there.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: NeedsResponse Overlap Question

Post by Erwin Coumans »

Bullet has 3 stage collision detection:

The very first stage is based on bounding volumes, finding pairs of objects that have overlap of their axis aligned bounding boxes. For each pair of objects that have AABB overlap, the NeedsCollision is called, to make sure the collision is really needed. So even if objects are not exactly overlapping, the NeedsCollision is called when their AABB overlaps.

Other stages are for complex objects (finding the overlapping triangles in a triangle mesh, using a bounding volume hierarchy), and narrow phase, finding the exact contact: closest points and normal.

Hope this helps,
Erwin
thePoet
Posts: 17
Joined: Tue Apr 15, 2008 4:14 pm

Re: NeedsResponse Overlap Question

Post by thePoet »

If NeedsCollision is triggered for bounding box overlap, what triggers NeedsResponse? I was under the impression that occured before one could be completely certain of the collision was "real". I know that you will get this call when an object is entirely within another object, but there are not vertexes overlapping (which is good for me). But I don't understand this phase well enough to know whether there can still be false positives (object a and b don't actually overlap), and if there can be, how far off can they be.
thePoet
Posts: 17
Joined: Tue Apr 15, 2008 4:14 pm

Re: NeedsResponse Overlap Question

Post by thePoet »

Does anyone have an answer to this. I need to figure out decent overlap detection.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: NeedsResponse Overlap Question

Post by Erwin Coumans »

The first stage of culling happens during the approximate/broadphase collision detection. Overlap in this stage is based on axis aligned bounding boxes of the actual collision shapes.

If you are interested in the underlying ideas, method and techniques of Bullet and other physics engines, please read up on the resources, provided in this topic. In particular this thesis is very useful.

Hope this helps,
Erwin
thePoet
Posts: 17
Joined: Tue Apr 15, 2008 4:14 pm

Re: NeedsResponse Overlap Question

Post by thePoet »

The AABB overlap makes sense to me. Some other posts on the forum had me confused, thanks for the pointers.

What I need to add is the ability to detect overlap in the form of one mesh overlapping the space of another. This can include one item being contained in another, so triangle collision isn't quite enough. I don't think that Bullet has the ability to give me this answer by default. Is that correct? If it is, does anyone have any recommendation on where to put this kind of code detection to allow Bullet to do as much work as possible. I was planning on placing it in NeedsResponse (since that would have already performed AABB overlap culling), but now I'm wondering is btConvexTriangleCallback could be used to cull it more. Does anyone have any thoughts on this?