Hi,
It seems there is no simple API to compute ClosestPoints between two objects. Using btGjkPairDetector is the only way to do this ? SweepTest ignore objects penetrating at start of the path and sometime these may be needed, computing these intersections by the way should be faster, shouldnt be ?
Thanks
Romain
ClosestPoint
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: ClosestPoint
Another simple way of computing the closest points is using the collision dispatcher and the following 3 lines of code:
Then you can get access to the contact points (closest points) using
Is that what you need?
Cheers,
Erwin
Code: Select all
btCollisionAlgorithm* algo = collisionWorld->getDispatcher()->findAlgorithm(&objects[0],&objects[1]);
btManifoldResult contactPointResult(&objects[0],&objects[1]);
algo->processCollision(&objects[0],&objects[1],collisionWorld->getDispatchInfo(),&contactPointResult);
Code: Select all
btManifoldArray manifoldArray;
algo->getAllContactManifolds(manifoldArray);
int numManifolds = manifoldArray.size();
for (i=0;i<numManifolds;i++)
{
btPersistentManifold* contactManifold = manifoldArray[i];
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
int numContacts = contactManifold->getNumContacts();
for (int j=0;j<numContacts;j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
btVector3 ptA =pt.getPositionWorldOnA();
btVector3 ptB = pt.getPositionWorldOnB();
}
}
Cheers,
Erwin
-
- Posts: 15
- Joined: Tue Jan 06, 2009 10:04 am
Re: ClosestPoint
Yes that's it. Thanks for the reply. The other point concerns the SweepTest which seems to compute closestPoints at start of the cast but does not provide the result of this start collector, this should be great if we could have cast results at start added to the "along the path" results.