fix in box-box contact generation: choose better contact point location (along contact normal) when objects are swapped.

move debugDrawWorld to btCollisionWorld.
improved CollisionInterfaceDemo, show how to perform a closest point query for objects that are not in the collision world.
removed a bit of garbage from the debug drawer
This commit is contained in:
erwin.coumans
2009-12-18 00:54:52 +00:00
parent 6425af9a6c
commit fcd2b93a22
7 changed files with 619 additions and 501 deletions

View File

@@ -1,4 +1,3 @@
/*
* Box-Box collision detection re-distributed under the ZLib license with permission from Russell L. Smith
* Original version is from Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith.
@@ -424,6 +423,7 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
output.addContactPoint(-normal,pointInWorld,-*depth);
#else
output.addContactPoint(-normal,pb,-*depth);
#endif //
*return_code = code;
}
@@ -593,21 +593,30 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
if (maxc < 1) maxc = 1;
if (cnum <= maxc) {
if (code<4)
{
// we have less contacts than we need, so we use them all
for (j=0; j < cnum; j++) {
//AddContactPoint...
//dContactGeom *con = CONTACT(contact,skip*j);
//for (i=0; i<3; i++) con->pos[i] = point[j*3+i] + pa[i];
//con->depth = dep[j];
for (j=0; j < cnum; j++)
{
btVector3 pointInWorld;
for (i=0; i<3; i++)
pointInWorld[i] = point[j*3+i] + pa[i];
output.addContactPoint(-normal,pointInWorld,-dep[j]);
}
} else
{
// we have less contacts than we need, so we use them all
for (j=0; j < cnum; j++)
{
btVector3 pointInWorld;
for (i=0; i<3; i++)
pointInWorld[i] = point[j*3+i] + pa[i]-normal[i]*dep[j];
//pointInWorld[i] = point[j*3+i] + pa[i];
output.addContactPoint(-normal,pointInWorld,-dep[j]);
}
}
}
else {
// we have more contacts than are wanted, some of them must be culled.
@@ -632,7 +641,13 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
btVector3 posInWorld;
for (i=0; i<3; i++)
posInWorld[i] = point[iret[j]*3+i] + pa[i];
output.addContactPoint(-normal,posInWorld,-dep[iret[j]]);
if (code<4)
{
output.addContactPoint(-normal,posInWorld,-dep[iret[j]]);
} else
{
output.addContactPoint(-normal,posInWorld-normal*dep[iret[j]],-dep[iret[j]]);
}
}
cnum = maxc;
}