Filtering CompoundCompound collision contact points.

Post Reply
Khanovich
Posts: 6
Joined: Thu May 15, 2014 6:28 am

Filtering CompoundCompound collision contact points.

Post 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
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Filtering CompoundCompound collision contact points.

Post 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 ?
Khanovich
Posts: 6
Joined: Thu May 15, 2014 6:28 am

Re: Filtering CompoundCompound collision contact points.

Post 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.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Filtering CompoundCompound collision contact points.

Post 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).
hyyou
Posts: 96
Joined: Wed Mar 16, 2016 10:11 am

Re: Filtering CompoundCompound collision contact points.

Post 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.
Post Reply