I am building a contact simulator with collision detection by bullet physics.
As I tested collision between static plane vs primitives (sphere, box, cone, cylinder), I found that position of contact points are counter-intuitive when the surface of plane and surface of primitives are faced.
Fox box, I expected center of lower surface would be a contact point but actually, one of the corner is the contact point,
and for cylinder, contact point is not a center of lower surface, but edge of the lower surface.
I've obtained contacts as follows:
Code: Select all
// bullet collision detecting
collisionWorld_->performDiscreteCollisionDetection();
// search colliding objects
int numManiforlds = collisionDispatcher_->getNumManifolds();
for (int i = 0; i < numManiforlds; i++) {
btPersistentManifold *contactManifold = collisionDispatcher_->getManifoldByIndexInternal(i);
const auto *bulletObjectA = contactManifold->getBody0();
const auto *bulletObjectB = contactManifold->getBody1();
int objectIndexA = bulletObjectA->getWorldArrayIndex();
int objectIndexB = bulletObjectB->getWorldArrayIndex();
int numContacts = contactManifold->getNumContacts();
for (int j = 0; j < numContacts; j++) {
btManifoldPoint &pt = contactManifold->getContactPoint(j);
...(get position from pt.getPositionsWorldOnA(), and pt.getPositionWorldOnB)
}
}
But, for instance, the best scenario for me is getting 1 collision point at the center of lower surface.
(even better if I can get 4 collision points for box vs plane situation which are the corner points of lower surface of box.)
I found I can get 4 collision point between box vs box collision, but in this case, collision point of cylinder and cone are not the center of lower surface.
Is there any way to do what I want?
FYI, I attached screenshot from my visualization tool.