Collision detection - contradictory contacts

kalesony
Posts: 33
Joined: Tue Sep 25, 2012 12:16 pm
Location: Poland

Collision detection - contradictory contacts

Post by kalesony »

Hi there.

(After calling btCollisionWorld::performDiscreteCollisionDetection(), while iterating over contact manifolds -> contact points) I keep getting contradictory contact points in the same contact manifold - by contradictory I mean positioned "very" close to each other but having "almost" opposite normals. The collsions in my test scenario are cylinder-to-box and most of them seem okay, but pretty often I stumble upon such contradictory cases (which is a stomachache for my dynamics). Clearing the manifold in each step helps to resolve this but it seems a bit of a hack to do that.

Example - see the pic (the 3rd dimension [y] is skipped in the pic since it does not matter here):
1. btAxisSweep3:
  • normalOnB = (0.0668717 -0.0264922 0.99741), posA = (11.471 -5.52159 0.459946), posB = (11.4757 -5.52578 0.462526), lifetime = 179, dist = -0.00299935
    normalOnB = (0.164588 -0.144687 -0.975693), posA = (11.5029 -5.54997 0.46954), posB = (11.503 -5.55004 0.469048), lifetime = 177, dist = -0.000504346
    normalOnB = (0.186085 -0.0986609 -0.977568), posA = (11.5129 -5.5588 0.472527), posB = (11.5155 -5.5611 0.473045), lifetime = 111, dist = -0.000201099
2. btSimpleBroadphase:
  • normalOnB = (0.108489 0.026658 0.99374), posA = (16.7905 -1.38015 0.450758), posB = (16.7861 -1.38025 0.452419), lifetime = 235, dist = -0.00117335
    normalOnB = (0.158828 0.034858 -0.986691), posA = (16.861 -1.37849 0.467574), posB = (16.856 -1.37861 0.46632), lifetime = 153, dist = -0.000440557
    normalOnB = (0.231657 0.00605996 -0.972779), posA = (16.8372 -1.37905 0.461893), posB = (16.8373 -1.37905 0.461451), lifetime = 175, dist = -0.000454278
Is it a bug, a feature or maybe a hint that I am doing things wrong?

Thanks.
You do not have the required permissions to view the files attached to this post.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision detection - contradictory contacts

Post by Erwin Coumans »

Are you using the default collision margins for the collision shapes (0.04) ?

Can you reproduce this in a Bullet demo (say Bullet/Demos/BasicDemo) ?

Thanks!
Erwin
kalesony
Posts: 33
Joined: Tue Sep 25, 2012 12:16 pm
Location: Poland

Re: Collision detection - contradictory contacts

Post by kalesony »

Hi Erwin.

Coll. shapes margins: haven't touched so they must be at their defaults.
Repro.: I can try to devise a minimal set of modifications in this demo which would reproduce the issue, but I could also directly provide the set of collision objects + time-sequence of their world transforms which generated the weird results for me (I can wrap it in a simple app if it helps).

Let me know what you think.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision detection - contradictory contacts

Post by Erwin Coumans »

Anyway for us to reproduce it works, without having to mess with build systems and dependencies.

So modifying the Bullet/Demos/HelloWorld demo, with 2 bodies and transforms, printing the contact details will be fine too.
Thanks!
Erwin
kalesony
Posts: 33
Joined: Tue Sep 25, 2012 12:16 pm
Location: Poland

Re: Collision detection - contradictory contacts

Post by kalesony »

Copy that ;).
kalesony
Posts: 33
Joined: Tue Sep 25, 2012 12:16 pm
Location: Poland

Re: Collision detection - contradictory contacts

Post by kalesony »

Done - I chose the option with pre-recorded set of objects and their transforms. Still, preparing to run it shouldn't take you more than 2 minutes.

Source and data are here: https://dl.dropbox.com/u/39695680/bulle ... _modif.zip

Simply substitute the corresponding source/header files in the BasicDemo project and copy the two data files into the project directory (this is the default working directory for debugging if using Visual Studio). In case you need the data files to be located elsewhere, change the two paths passed in main.cpp as parameters of initCollisionsFromFile and place the data correspondingly.

I have pointed a location to break-point into: look for breakpointHere dummy variable, place the breakpoint and (once it catches) check the contact points for the current manifold, their normals should be contradicting each other.

edit
-
Things I forgot to mention
  • the data files are binary and use floats (32 bit); if need be, I can provide double-based version
    this is a purely collision-based example (no dynamics)
    to get back to the original sample (for whatever reasons) undef MODIFIED in main.cpp
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision detection - contradictory contacts

Post by Erwin Coumans »

Thanks for sharing the repro.

It seems some object dimentions are very small (0.02), that might be an issue.
Another issue might be that contacts are not refreshes/updated/removed properly, due to fast rotation.

I will look at it closer at some stage (busy and travel right now).
kalesony
Posts: 33
Joined: Tue Sep 25, 2012 12:16 pm
Location: Poland

Re: Collision detection - contradictory contacts

Post by kalesony »

Thanks for checking this out, I'm looking forward to hearing further comments on this issue once you have time for a deeper look into this :).

Cheers.