takahiyn / bullet

Automatically exported from code.google.com/p/bullet
0 stars 0 forks source link

Ray-cast against box produces wrong results in many cases #250

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. cast a ray (zero-radius sphere) towards a box with small rotation
2.
3.

What is the expected output? What do you see instead?

ray cast detection is missed or wrong.

What version of the product are you using? On what operating system?
2.73 Windows VC9, Debug or Release builds

Please provide any additional information below.

Sample code is provided below.  Additional test cases follow the code.

------------------------------------------------------
    btBoxShape      boxShape( btVector3( 25.0f, 25.0f, 5.0f ));

    float           expectedDist = 8.75039520e+001f;
    btVector3       fromPtGood( 2.73382816e+001f, 5.56533546e+001f, -
8.17149582e+001f );
    btVector3       toPtGood( -1.54871780e+002f, -3.84807281e+002f, 
7.97370300e+002f );
    btVector3       fromPt( 2.73385315e+001f, 5.56533546e+001f, -
8.17149048e+001f );
    btVector3       toPt( -1.54875488e+002f, -3.84807281e+002f, 
7.97369507e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -
4.95289341e-002f, 5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -
4.95289341e-002f, -5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 
0.00000000e+000f, 0.00000000e+000f));

    btDbvtBroadphase                  broadphase;
    btDefaultCollisionConfiguration   collisionConfiguration;
    btCollisionDispatcher             dispatcher
(&collisionConfiguration);
    btCollisionWorld                
    collisionWorld( &dispatcher, &broadphase, 
&collisionConfiguration );

    btVector3                       
    localInertia(0,0,0);
    btDefaultMotionState     motionState( boxTransform );
    btRigidBody::btRigidBodyConstructionInfo rbInfo( 0.0f, 
&motionState, &boxShape, localInertia );

    btRigidBody rigidBody( rbInfo );
    collisionWorld.addCollisionObject( &rigidBody );
    collisionWorld.performDiscreteCollisionDetection();

    btTransform fromXform;
    fromXform.setIdentity();
    fromXform.setOrigin(fromPt);

    btTransform toXform;
    toXform.setIdentity();
    toXform.setOrigin(toPt);

    btSphereShape sphere(0.0f);

    btCollisionWorld::ClosestConvexResultCallback cb( fromPt, toPt );

    collisionWorld.convexSweepTest( &sphere, fromXform, toXform, cb );
    float dist = 1000.0f * cb.m_closestHitFraction;
    SDG_ASSERTF( fabs(dist - expectedDist) < 5.0f, "Distance is %f, 
expected %f", dist, expectedDist );

more test cases in attached file

Original issue reported on code.google.com by jacob.la...@gmail.com on 8 Jul 2009 at 9:11

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thanks a lot for the report. 

A degenerate case in GJK was detected, and after computing the penetration 
(EPA) a 
second GJK calculation is performed without margins. This often gets a valid 
result, 
and it fixes your test case.

Can you test Bullet-2.75-rc4.zip and see if it fixes your issue?
http://bullet.googlecode.com/files/bullet-2.75-rc4.zip

If you have other remaining failing cases, not covered by this fix, please let 
us 
know.
Thanks a lot for the reproduction case!
Erwin

Original comment by erwin.coumans on 9 Jul 2009 at 10:30

GoogleCodeExporter commented 9 years ago
If you changed the GJK code from 2.73 to 2.75 the test cases I provided may no 
longer work - the bug is sensitive to the exact numerical result.

I cannot post the code with anomoly detection, but it was simply a ray cast 
from the 
camera, which I then manually flew around the small slightly-rotated box with 
dimensions in the above code.  I maintained ray-cast distance for three frames, 
and 
then when the first two frames agreed to within 5 units, but the third frame 
disagreed by five units or more, I dumped the ray points to the log file.  The 
failure can occur when the ray misses the box altogether, or when it hits the 
back 
side of the box.

My forum post described the mechanism by which the GJK algorithm failed.

Original comment by jacob.la...@gmail.com on 9 Jul 2009 at 10:35

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

I could reproduce your issue, and fixed some bug:
http://code.google.com/p/bullet/source/detail?r=1703

Can you please try it again with Bullet 2.75 RC4?
http://bullet.googlecode.com/files/bullet-2.75-rc4.zip

Thanks a lot,
Erwin

Original comment by erwin.coumans on 9 Jul 2009 at 10:47

GoogleCodeExporter commented 9 years ago
Actually we were on 2.74.  I took the two files you changed and added them to 
our 
2.74 build.  The problem still felt like it existed, so I reran the above test 
case.  It passed, but then I tested one of the cases from the provided set that 
didn't entirely miss the detection, but that hit the back side, and it still 
triggers with your new code:

    float           expectedDist = 1.61861923e+002f;
    btVector3       fromPtGood( -1.11049032e+001f, 7.54205246e+001f, -
1.53496719e+002f );
    btVector3       toPtGood( -1.10374928e+001f, -3.03465973e+002f, 
7.71946533e+002f );
    btVector3       fromPt( -1.14326353e+001f, 7.54204025e+001f, -1.53496384e+002f );
    btVector3       toPt( -1.13277369e+001f, -3.03464966e+002f, 7.71947327e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

Original comment by jacob.la...@gmail.com on 9 Jul 2009 at 10:59

GoogleCodeExporter commented 9 years ago
It is best to switch to Bullet 2.75 RC4, instead of 2.74.

I haven't checked in detail yet, but this 'back side' problem might be a bug in 
the 
btContinuousConvexCast. 

Replacing btContinuousConvexCast by btGjkConvexCast in 
btCollisionWorld::objectQuerySingle reports roughly the expected distance.

void    btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const 
btTransform& convexFromTrans,const btTransform& convexToTrans,
                      btCollisionObject* collisionObject,
                      const btCollisionShape* collisionShape,
                      const btTransform& 
colObjWorldTransform,
                      ConvexResultCallback& resultCallback, 
btScalar allowedPenetration)
{
    if (collisionShape->isConvex())
    {
        //BT_PROFILE("convexSweepConvex");
        btConvexCast::CastResult castResult;
        castResult.m_allowedPenetration = allowedPenetration;
        castResult.m_fraction = 
resultCallback.m_closestHitFraction;//btScalar(1.);//??

        btConvexShape* convexShape = (btConvexShape*) collisionShape;
        btVoronoiSimplexSolver  simplexSolver;
        btGjkEpaPenetrationDepthSolver  gjkEpaPenetrationSolver;

        //btContinuousConvexCollision convexCaster1
(castShape,convexShape,&simplexSolver,&gjkEpaPenetrationSolver);
        btGjkConvexCast convexCaster1
(castShape,convexShape,&simplexSolver);
        //btSubsimplexConvexCast convexCaster3
(castShape,convexShape,&simplexSolver);

Thanks again for the test case, I'll look into it further.

Original comment by erwin.coumans on 9 Jul 2009 at 11:09

GoogleCodeExporter commented 9 years ago
I test your second test, but it works fine here: it doesn't hit the backside 
here 
(see attached screenshot)

Can you please check attached file, replacing this demo?
bullet-2.75-svn\Demos\GjkConvexCastDemo\LinearConvexCastDemo.cpp

Thanks,
Erwin

Original comment by erwin.coumans on 10 Jul 2009 at 12:30

Attachments:

GoogleCodeExporter commented 9 years ago
In your test case you changed the swept sphere to have radius 1.0f.  If I set 
it 
back to zero the test case still triggers.  I replaced btContinuousConvexCast 
by 
btGjkConvexCast in btCollisionWorld::objectQuerySingle as you suggested, and it 
fixes that particular test case, but the detection bugs still exist.  

I didn't test all of the cases I supplied because I have an interactive method 
of 
checking that is simpler: we are using the ray cast to move our camera closer 
to the 
character when he backs up against a wall.  So all I have to do is rotate the 
entire 
world slightly and then slide against the wall.  I see nasty flashing every 
time the 
camera pops through the wall, and still do even with the above fix.

Original comment by jacob.la...@gmail.com on 10 Jul 2009 at 5:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Some degeneracies are detected, but not handled properly. The distance seems to 
grow 
instead of shrink in some cases, so let's try to use the previous iteration 
values 
instead.

Could you please try to replace bullet-2.75-
svn\src\BulletCollision\NarrowPhaseCollision/btGjkPairDetector.cpp by attached 
file 
and see if it improves things?

Thanks for the feedback,
Erwin

Original comment by erwin.coumans on 10 Jul 2009 at 8:34

Attachments:

GoogleCodeExporter commented 9 years ago
Things are noticeably better, but not perfect:  here are some more misses

.\World.cpp(353): ERROR: app: 1140: Anomaly detected frame 491: distance went 
from 
195.956284 to 196.524689 to 0.000000
.\World.cpp(385): ERROR: app: 1140: 
    float           expectedDist = 1.95956284e+002f;
    btVector3       fromPtGood( -2.00534897e+001f, 6.60758133e+001f, -
1.88519119e+002f );
    btVector3       toPtGood( 3.83275795e+000f, -2.72245392e+002f, 
7.52207092e+002f );
    btVector3       fromPt( -2.00940342e+001f, 6.60485077e+001f, -1.88470612e+002f );
    btVector3       toPt( 3.87384796e+000f, -2.63189880e+002f, 7.55470703e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 1210: Anomaly detected frame 561: distance went 
from 
194.903793 to 195.066483 to 0.000000
.\World.cpp(385): ERROR: app: 1210: 
    float           expectedDist = 1.94903793e+002f;
    btVector3       fromPtGood( -1.98839836e+001f, 6.56139984e+001f, -
1.87122559e+002f );
    btVector3       toPtGood( 3.93905640e+000f, -2.79555481e+002f, 
7.51113892e+002f );
    btVector3       fromPt( -1.97844200e+001f, 6.55513153e+001f, -1.86954407e+002f );
    btVector3       toPt( 4.03804779e+000f, -2.79679504e+002f, 7.51259521e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 1232: Anomaly detected frame 583: distance went 
from 
189.671097 to 190.074310 to 0.000000
.\World.cpp(385): ERROR: app: 1232: 
    float           expectedDist = 1.89671097e+002f;
    btVector3       fromPtGood( -1.88997784e+001f, 6.47843399e+001f, -
1.85024750e+002f );
    btVector3       toPtGood( 5.36416245e+000f, -2.28875366e+002f, 
7.70575806e+002f );
    btVector3       fromPt( -1.88850613e+001f, 6.47646942e+001f, -1.84984924e+002f );
    btVector3       toPt( 5.43029213e+000f, -2.22218857e+002f, 7.72640381e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 1268: Anomaly detected frame 619: distance went 
from 
188.038651 to 187.946259 to 0.000000
.\World.cpp(385): ERROR: app: 1268: 
    float           expectedDist = 1.88038651e+002f;
    btVector3       fromPtGood( -1.80911102e+001f, 6.44520721e+001f, -
1.83742096e+002f );
    btVector3       toPtGood( 6.21186638e+000f, -2.24153854e+002f, 
7.73395630e+002f );
    btVector3       fromPt( -1.80728321e+001f, 6.44639893e+001f, -1.83778671e+002f );
    btVector3       toPt( 6.22287750e+000f, -2.25089966e+002f, 7.73072876e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 1270: Anomaly detected frame 621: distance went 
from 
0.000000 to 0.000000 to 188.227966
.\World.cpp(385): ERROR: app: 1270: 
    float           expectedDist = 0.00000000e+000f;
    btVector3       fromPtGood( -1.80420036e+001f, 6.44721603e+001f, -
1.83803406e+002f );
    btVector3       toPtGood( 6.24720573e+000f, -2.25927002e+002f, 
7.72792053e+002f );
    btVector3       fromPt( -1.79938335e+001f, 6.44740677e+001f, -1.83808151e+002f );
    btVector3       toPt( 6.28943253e+000f, -2.26695679e+002f, 7.72553162e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 1309: Anomaly detected frame 660: distance went 
from 
184.241196 to 184.462585 to 0.000000
.\World.cpp(385): ERROR: app: 1309: 
    float           expectedDist = 1.84241196e+002f;
    btVector3       fromPtGood( -1.42699022e+001f, 6.32468643e+001f, -
1.79918823e+002f );
    btVector3       toPtGood( 9.96748447e+000f, -2.33796753e+002f, 
7.74635620e+002f );
    btVector3       fromPt( -1.41259575e+001f, 6.31793251e+001f, -1.79705261e+002f );
    btVector3       toPt( 1.01113701e+001f, -2.33871796e+002f, 7.74846863e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 1576: Anomaly detected frame 927: distance went 
from 
146.307144 to 146.303406 to 0.000000
.\World.cpp(385): ERROR: app: 1576: 
    float           expectedDist = 1.46307144e+002f;
    btVector3       fromPtGood( -1.42458048e+001f, 5.15115738e+001f, -
1.43709885e+002f );
    btVector3       toPtGood( 1.60935654e+002f, -2.14272705e+002f, 
8.04269165e+002f );
    btVector3       fromPt( -1.43006849e+001f, 5.15105515e+001f, -1.43695969e+002f );
    btVector3       toPt( 1.61620453e+002f, -2.14273743e+002f, 8.04146118e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 1615: Anomaly detected frame 966: distance went 
from 
148.667770 to 148.528793 to 0.000000
.\World.cpp(385): ERROR: app: 1615: 
    float           expectedDist = 1.48667770e+002f;
    btVector3       fromPtGood( -1.49454422e+001f, 5.16571274e+001f, -
1.43895615e+002f );
    btVector3       toPtGood( 1.63858734e+002f, -2.65471985e+002f, 
7.87475647e+002f );
    btVector3       fromPt( -1.49480324e+001f, 5.16614380e+001f, -1.43899612e+002f );
    btVector3       toPt( 1.63701920e+002f, -2.68013733e+002f, 7.86630493e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 1632: Anomaly detected frame 983: distance went 
from 
149.655884 to 149.636414 to 0.000000
.\World.cpp(385): ERROR: app: 1632: 
    float           expectedDist = 1.49655884e+002f;
    btVector3       fromPtGood( -1.49705248e+001f, 5.16951141e+001f, -
1.43934982e+002f );
    btVector3       toPtGood( 1.62551697e+002f, -2.85915466e+002f, 
7.80456177e+002f );
    btVector3       fromPt( -1.49715776e+001f, 5.16959076e+001f, -1.43935898e+002f );
    btVector3       toPt( 1.62527771e+002f, -2.86266968e+002f, 7.80330933e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 1752: Anomaly detected frame 1103: distance went 
from 
111.910339 to 112.145607 to 0.000000
.\World.cpp(385): ERROR: app: 1752: 
    float           expectedDist = 1.11910339e+002f;
    btVector3       fromPtGood( -9.21623230e+000f, 4.09629135e+001f, -
1.11675995e+002f );
    btVector3       toPtGood( 1.73987656e+002f, -1.96630432e+002f, 
8.42252563e+002f );
    btVector3       fromPt( -9.17674255e+000f, 4.09111137e+001f, -1.11470367e+002f );
    btVector3       toPt( 1.74052475e+002f, -1.96132294e+002f, 8.42590088e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

Original comment by jacob.la...@gmail.com on 10 Jul 2009 at 9:04

GoogleCodeExporter commented 9 years ago
I tried the first 3 tests in your latest report, but they all work fine here.

Can you please test it with the unmodified bullet-2.75-rc4b.zip
http://code.google.com/p/bullet/downloads/detail?name=bullet-2.75-rc4b.zip

and the attached demo?
Thanks,
Erwin

Original comment by erwin.coumans on 10 Jul 2009 at 9:35

Attachments:

GoogleCodeExporter commented 9 years ago
Well we use VC9, which isn't supported out of the box.  The VC8 project files 
convert without fuss, but we changed the projects to build static libraries 
with the 
multithreaded DLL MSVC runtimes.

RC4b demos don't build with our VS9 solutions - there are problems with 
BT_ACTIVE_ALT and Glut keyboard input.  The core libraries that built are also 
extremely unstable in our app - hopefully that's due to not having a clean 
build, 
and not due to changes in bullet.  Unfortunately upgrading to the newest 
release is 
more work than I can take on right now.

Original comment by jacob.la...@gmail.com on 10 Jul 2009 at 11:11

GoogleCodeExporter commented 9 years ago
Hope you can test with a clean 2.75 build soon.

VC8 projectfiles convert and build fine under VC9/2008 here.
What kind of problems do you face with BT_ACTIVE_ALT and Glut?
Thanks,
Erwin

Original comment by erwin.coumans on 11 Jul 2009 at 3:11

GoogleCodeExporter commented 9 years ago
Ok - I just used the Visual Studio wizard to convert the VC8 projects, rather 
than 
trying to use the ones we had already fixed from 2.74.  I use the DebugDll and 
ReleaseDll configurations.  The demo code does not execute without setting 
"Include 
Manifest" option to "yes", but that was the only change I made, other than 
changing 
the output directory of the libraries and pdb files.  I rebuilt our code, and 
it is 
very unstable.  As soon as physics objects are removed from the simulation 
world, 
bullet crashes.  Maybe related to some optimization changes regarding caches?

Anyhow you still have problem cases:

world.cpp(353): ERROR: app: 5832: Anomaly detected frame 3056: distance went 
from 
52.091866 to 47.150066 to 58.095310
world.cpp(385): ERROR: app: 5832: 
    float           expectedDist = 5.20918655e+001f;
    btVector3       fromPtGood( 1.55340853e+001f, 8.71350098e+000f, -
5.60373383e+001f );
    btVector3       toPtGood( -1.53415497e+002f, -1.49659546e+002f, 
9.16777466e+002f );
    btVector3       fromPt( 1.65483646e+001f, 9.66428471e+000f, -6.18775749e+001f );
    btVector3       toPt( -1.52401215e+002f, -1.48708755e+002f, 9.10937256e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 6141: Anomaly detected frame 3365: distance went 
from 
176.729355 to 176.639511 to 0.000000
world.cpp(385): ERROR: app: 6141: 
    float           expectedDist = 1.76729355e+002f;
    btVector3       fromPtGood( 3.55838089e+001f, 2.74296627e+001f, -
1.70801620e+002f );
    btVector3       toPtGood( -2.46330841e+002f, -1.60159714e+002f, 
7.70117249e+002f );
    btVector3       fromPt( 3.55836563e+001f, 2.74330273e+001f, -1.70800995e+002f );
    btVector3       toPt( -2.46176544e+002f, -1.63520462e+002f, 7.69487305e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 6147: Anomaly detected frame 3371: distance went 
from 
177.116928 to 177.070770 to 0.000000
world.cpp(385): ERROR: app: 6147: 
    float           expectedDist = 1.77116928e+002f;
    btVector3       fromPtGood( 3.55831146e+001f, 2.74442635e+001f, -
1.70798798e+002f );
    btVector3       toPtGood( -2.45636002e+002f, -1.74747086e+002f, 
7.67299438e+002f );
    btVector3       fromPt( 3.55830345e+001f, 2.74458523e+001f, -1.70798477e+002f );
    btVector3       toPt( -2.45556580e+002f, -1.76332932e+002f, 7.66980042e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 6170: Anomaly detected frame 3394: distance went 
from 
176.214844 to 176.255280 to 184.359161
world.cpp(385): ERROR: app: 6170: 
    float           expectedDist = 1.76214844e+002f;
    btVector3       fromPtGood( 3.55853004e+001f, 2.74056892e+001f, -
1.70805618e+002f );
    btVector3       toPtGood( -2.47820404e+002f, -1.36211395e+002f, 
7.74130493e+002f );
    btVector3       fromPt( 3.55853767e+001f, 2.74040833e+001f, -1.70805878e+002f );
    btVector3       toPt( -2.47897446e+002f, -1.34605667e+002f, 7.74384033e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

Original comment by jacob.la...@gmail.com on 13 Jul 2009 at 5:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
How are the physics objects removed from the simulation world? In current 
Bullet 2.75 
RC* rigid bodies have to be removed using 'removeRigidBody' and not 
'removeCollisionObject'. We'll override the 'removeCollisionObject' to deal 
with the 
different kind of objects (softbody/rigidbody/softbody etc) for the final 2.75 
release.

Are the convex cast problems reduced/more rare now? I'll check the remaining 
cases.
Thanks for the help,
Erwin

Original comment by erwin.coumans on 13 Jul 2009 at 5:26

GoogleCodeExporter commented 9 years ago
Thanks.  Changing to removeRigidBody cured the crashes.  Yes the cast problems 
are 
definitely more rare - your fixes are working, I guess it's just a matter of 
hunting 
down the remaining problem cases.  On that last set of numbers I posted, I'm 
not 
sure the first one was anything meaningful - the anomaly detection isn't 
perfect.  
But I think the remaining ones were really problems

Original comment by jacob.la...@gmail.com on 13 Jul 2009 at 5:53

GoogleCodeExporter commented 9 years ago
There is another degeneracy issue, that causes 'overshoot' during the 
iterations of 
the convex cast.

As a small test, can you please try changing this line in bullet-2.75-
svn\src\BulletCollision\NarrowPhaseCollision\btContinuousConvexCollision.cpp

From
lambda = lambda + dLambda;
into
lambda = lambda + dLambda*btScalar(0.9);

And see how that goes?
Thanks,
Erwin

Original comment by erwin.coumans on 13 Jul 2009 at 6:18

GoogleCodeExporter commented 9 years ago
after your fix:

world.cpp(353): ERROR: app: 5734: Anomaly detected frame 4991: distance went 
from 
134.449936 to 138.448929 to 129.426361
world.cpp(385): ERROR: app: 5734: 
    float           expectedDist = 1.34449936e+002f;
    btVector3       fromPtGood( -2.35940819e+001f, 2.78535957e+001f, -
1.34232330e+002f );
    btVector3       toPtGood( 9.54580841e+001f, -2.16485443e+002f, 
8.28119873e+002f );
    btVector3       fromPt( -2.29960136e+001f, 2.66261387e+001f, -1.29397873e+002f );
    btVector3       toPt( 9.60561523e+001f, -2.17712891e+002f, 8.32954285e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 6538: Anomaly detected frame 5795: distance went 
from 
90.484779 to 95.182228 to 85.087486
world.cpp(385): ERROR: app: 6538: 
    float           expectedDist = 9.04847794e+001f;
    btVector3       fromPtGood( -2.08689690e+001f, 1.90155392e+001f, -
9.27966919e+001f );
    btVector3       toPtGood( 1.20978592e+002f, -1.35178741e+002f, 
8.85003784e+002f );
    btVector3       fromPt( -2.01034870e+001f, 1.81833363e+001f, -8.75199814e+001f );
    btVector3       toPt( 1.21745438e+002f, -1.35920883e+002f, 8.90294556e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 6553: Anomaly detected frame 5810: distance went 
from 
51.084034 to 46.517834 to 58.059227
world.cpp(385): ERROR: app: 6553: 
    float           expectedDist = 5.10840340e+001f;
    btVector3       fromPtGood( -1.52805176e+001f, 1.29495487e+001f, -
5.42732811e+001f );
    btVector3       toPtGood( 1.26576859e+002f, -1.40593597e+002f, 
9.23628235e+002f );
    btVector3       fromPt( -1.62700233e+001f, 1.40205517e+001f, -6.10944939e+001f );
    btVector3       toPt( 1.25587570e+002f, -1.39507675e+002f, 9.16809326e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 7103: Anomaly detected frame 6360: distance went 
from 
86.553925 to 86.557899 to 0.000000
world.cpp(385): ERROR: app: 7103: 
    float           expectedDist = 8.65539246e+001f;
    btVector3       fromPtGood( -1.55749550e+001f, 1.48578682e+001f, -
8.89207993e+001f );
    btVector3       toPtGood( 6.17528343e+001f, -2.03792648e+002f, 
8.83807617e+002f );
    btVector3       fromPt( -1.55733557e+001f, 1.48578644e+001f, -8.89209290e+001f );
    btVector3       toPt( 6.01552277e+001f, -2.03789337e+002f, 8.83933960e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 7108: Anomaly detected frame 6365: distance went 
from 
86.542023 to 86.543633 to 0.000000
world.cpp(385): ERROR: app: 7108: 
    float           expectedDist = 8.65420227e+001f;
    btVector3       fromPtGood( -1.55685530e+001f, 1.48578548e+001f, -
8.89212952e+001f );
    btVector3       toPtGood( 5.53570747e+001f, -2.03779358e+002f, 
8.84297852e+002f );
    btVector3       fromPt( -1.55676260e+001f, 1.48578529e+001f, -8.89213638e+001f );
    btVector3       toPt( 5.44315262e+001f, -2.03777420e+002f, 8.84365173e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 7151: Anomaly detected frame 6408: distance went 
from 
86.532417 to 86.532425 to 0.000000
world.cpp(385): ERROR: app: 7151: 
    float           expectedDist = 8.65324173e+001f;
    btVector3       fromPtGood( -1.55606499e+001f, 1.48578386e+001f, -
8.89218369e+001f );
    btVector3       toPtGood( 4.74620667e+001f, -2.03762955e+002f, 
8.84844421e+002f );
    btVector3       fromPt( -1.55606441e+001f, 1.48578377e+001f, -8.89218445e+001f );
    btVector3       toPt( 4.74565048e+001f, -2.03762939e+002f, 8.84844727e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 7164: Anomaly detected frame 6421: distance went 
from 
86.532387 to 86.532379 to 0.000000
world.cpp(385): ERROR: app: 7164: 
    float           expectedDist = 8.65323868e+001f;
    btVector3       fromPtGood( -1.55606108e+001f, 1.48578377e+001f, -
8.89218445e+001f );
    btVector3       toPtGood( 4.74230423e+001f, -2.03762894e+002f, 
8.84846924e+002f );
    btVector3       fromPt( -1.55606098e+001f, 1.48578377e+001f, -8.89218445e+001f );
    btVector3       toPt( 4.74217987e+001f, -2.03762894e+002f, 8.84847046e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

world.cpp(353): ERROR: app: 7175: Anomaly detected frame 6432: distance went 
from 
86.532379 to 86.532372 to 0.000000
world.cpp(385): ERROR: app: 7175: 
    float           expectedDist = 8.65323792e+001f;
    btVector3       fromPtGood( -1.55606031e+001f, 1.48578377e+001f, -
8.89218445e+001f );
    btVector3       toPtGood( 4.74152565e+001f, -2.03762894e+002f, 
8.84847412e+002f );
    btVector3       fromPt( -1.55606031e+001f, 1.48578377e+001f, -8.89218445e+001f );
    btVector3       toPt( 4.74149284e+001f, -2.03762894e+002f, 8.84847412e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

Original comment by jacob.la...@gmail.com on 13 Jul 2009 at 8:47

GoogleCodeExporter commented 9 years ago
thanks for testing this, let's not apply this (it increases the number of 
iterations, 
making things slower)

I made some more fixes in the GJK degeneracy handling, can you please test with 
latest RC5/trunk 1707?
http://code.google.com/p/bullet/downloads/detail?name=bullet-2.75-rc5.zip

Thanks for your time,
Erwin

Original comment by erwin.coumans on 13 Jul 2009 at 10:11

GoogleCodeExporter commented 9 years ago
Ok my game's camera feels very well behaved now - no obvious glitches due to 
missed 
collisions.

I ran the test case I've been using to produce the anomaly reports and it shows 
a 
couple of hits.  I'm not sure if they're real or not - you should probably 
check in 
your sample if the rays are supposed to hit or not.

.\World.cpp(353): ERROR: app: 2111: Anomaly detected frame 981: distance went 
from 
138.245560 to 138.207092 to 0.000000
.\World.cpp(385): ERROR: app: 2111: 
    float           expectedDist = 1.38245560e+002f;
    btVector3       fromPtGood( -6.28600717e-001f, 6.50421600e+001f, -
1.31427277e+002f );
    btVector3       toPtGood( -2.62895737e+001f, -3.25972473e+002f, 
7.88596558e+002f );
    btVector3       fromPt( -7.76597202e-001f, 6.50429382e+001f, -1.31431076e+002f );
    btVector3       toPt( -2.64283314e+001f, -3.26750793e+002f, 7.88261414e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

.\World.cpp(353): ERROR: app: 6980: Anomaly detected frame 5850: distance went 
from 
131.116455 to 131.004242 to 0.000000
.\World.cpp(385): ERROR: app: 6980: 
    float           expectedDist = 1.31116455e+002f;
    btVector3       fromPtGood( 6.41912613e+001f, 6.45311356e+001f, -
1.06974014e+002f );
    btVector3       toPtGood( -3.84681915e+002f, -3.75022400e+002f, 
6.71028564e+002f );
    btVector3       fromPt( 6.41908493e+001f, 6.45329590e+001f, -1.06973228e+002f );
    btVector3       toPt( -3.84266174e+002f, -3.76842468e+002f, 6.70237366e+002f );
    btTransform     boxTransform( btMatrix3x3(  9.97260928e-001f, -4.95289341e-002f, 
5.49316593e-002f, 5.22642322e-002f, 9.97404277e-001f, -4.95289341e-002f, -
5.23359589e-002f, 5.22642322e-002f, 9.97260928e-001f ),
                                 btVector3 (0.00000000e+000f, 0.00000000e+000f, 
0.00000000e+000f));

Original comment by jacob.la...@gmail.com on 13 Jul 2009 at 11:02

GoogleCodeExporter commented 9 years ago
Those failures pointed out more issues, more degeneracy handling in Bullet GJK 
implementation are fixed now.

Can you test again with RC5b?

Thanks!
Erwin

Original comment by erwin.coumans on 14 Jul 2009 at 2:18

GoogleCodeExporter commented 9 years ago
Everything looks perfect now.  Thanks for resolving this Erwin.

Original comment by jacob.la...@gmail.com on 14 Jul 2009 at 4:30

GoogleCodeExporter commented 9 years ago
Great, if you encounter further issues, can you open a new issue so we can 
close this 
one?

>>Bullet collision detection leaks like a sieve!

Would you mind replying on this forum posting that your collision/raycast 
issues have 
been improved/resolved in Bullet?

I'll open an issue to create some unit tests :)
Thanks a lot!
Erwin

Original comment by erwin.coumans on 14 Jul 2009 at 5:51

GoogleCodeExporter commented 9 years ago

Original comment by erwin.coumans on 14 Jul 2009 at 8:49