Page 1 of 1

Filtering CompoundCompound collision contact points.

Posted: Thu May 15, 2014 6:40 am
by Khanovich
Hi All,

I'm having an issue where I'm using bullet Narrow Phase collision detection on two btCompoundShape objects that were created using Bullet Convex Decomposition. Because bullet convex decomposition seems to be very liberal about how many convex hull's it creates, I'm having an issue where these objects are colliding and creating a ton of unnecessary contact points at their edges.

Basically, I have two btCompoundShapes defined as obj0Wrap and obj1Wrap, and my code looks like the following:

Code: Select all

algo = dispatcher->findAlgorithm(&obj0Wrap, &obj1Wrap);
btManifoldResult contactPointResult(&obj0Wrap, &obj1Wrap);
bulletNPAlgorithm->processCollision(&obj0Wrap, &obj1Wrap, getPrimitive(0)->getWorld()->getBulletCollisionWorld()->getDispatchInfo(), &contactPointResult);
btManifoldArray manifoldArray;
bulletNPAlgorithm->getAllContactManifolds(manifoldArray);
This is where the problem arises. When I traverse the manifoldArray I have over 99 entries in there, and almost all give valid contact points with some penetration during collisions. This seems to be unnecessary, as many of these contact points are redundant, as they are edges for nearby convex shapes from each of the compound parents.

Is there no built-in bullet method to prevent btCompoundShapes ConvexChildren from interacting with each other in such a manner? Are there any well known ways of dealing with filtering contact points?

Many thanks,
Khan

Re: Filtering CompoundCompound collision contact points.

Posted: Fri May 16, 2014 11:02 am
by Flix
Khanovich wrote:Is there no built-in bullet method to prevent btCompoundShapes ConvexChildren from interacting with each other in such a manner? Are there any well known ways of dealing with filtering contact points?
First of all, I've used compounds of convex hull shapes quite frequently in the past, and I never needed to bother about this issue (I think it shouldn't happen very frequently that inner child shapes of two compound bodies collide, since a repulsion between the two bodies should occur early when extern compound children touch... at least this is what I hope it should happen). However I use HACD with a low number of child shapes whenever possible.

Anyway, in the default Bullet ConvexDecompositionDemo, a "gCompoundChildShapePairCallback" is used to filter child shapes (well, actually it does nothing in the Demo, but it is used). Is this what you're looking for ?

Re: Filtering CompoundCompound collision contact points.

Posted: Fri May 16, 2014 5:04 pm
by Khanovich
The collision that occurs looks good, but the problem is that I am still having 100 different contact pairs passed for two compound objects colliding. Having your physics solver do 100 contacts for a single shape is a pretty hefty price in performance, which is my main concern.

Re: Filtering CompoundCompound collision contact points.

Posted: Sat May 17, 2014 9:17 am
by Flix
Khanovich wrote:The collision that occurs looks good, but the problem is that I am still having 100 different contact pairs passed for two compound objects colliding. Having your physics solver do 100 contacts for a single shape is a pretty hefty price in performance, which is my main concern.
Yes, I know, using compound shapes can considerably increase the number of colliding shapes. That's the price to pay. What I usually do to improve performance is:
1) Using a limited number of child shapes.
2) When one compound rigid body moves and must "carry" another body, I always use a fixed constraint between the two bodies (without enabling collisions between the two bodies). Adding a constraint is far better then leaving contact points alive when the bodies can't go to sleep.

However what about the "gCompoundChildShapePairCallback" ? Does it work or not ?

P.S. Out of theme, but I think that a btConfigurableCompoundShape, in which each child shape can be enabled/disabled at runtime, could be useful in a huge amount of scenarios from the user perspective (even if it should not have any performance gain: just as a form of improved usability for the end user).

Re: Filtering CompoundCompound collision contact points.

Posted: Thu Mar 16, 2017 6:53 am
by hyyou
I know .... it was 3 years ago .....
Flix wrote:However what about the "gCompoundChildShapePairCallback" ? Does it work or not ?
It works, thank!

Edit: Don't forget to set "gCompoundCompoundChildShapePairCallback" too.