the Collision Demo GJKPairDetector return no result

lansea
Posts: 1
Joined: Tue Mar 06, 2007 2:28 pm

the Collision Demo GJKPairDetector return no result

Post by lansea »

I change the Collision Demo code test the two box collision, I set the two box transform to Identity, the code is:
tr[0].setIdentity();
tr[1].setIdentity();
btVector3 boxHalfExtentsA(1.0000004768371582f,1.0000004768371582f,1.0000001192092896f);
btVector3 boxHalfExtentsB(3.2836332321166992f,3.2836332321166992f,3.2836320400238037f);
btBoxShape* boxA = new btBoxShape(boxHalfExtentsA);
btBoxShape* boxB = new btBoxShape(boxHalfExtentsB);

I run the demo ,the gjkOutput.m_hasResult return false, (the boxA inside boxB), is that right?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

The CollisionDemo only shows the direct use of GJK. It doesn't pass any penetration depth solver. Therefore it can only measure distance and shallow penetrations (not deeper then the sum of the total collision margin.

Code: Select all

btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0);
You can pass a penetration depth solver as last argument (which is 0 in the demo). You can use another demo like SimpleCollisionDemo or EPAPenDepthDemo to measure penetrations (and distance).

Hope this helps,
Erwin