I am using Bullet for (only) collision detection in an engineering environment. Therefor the ContactPoints need to be "quite" accurate.
I hand over the position and the orientation of an object to Bullet and want receive PointA and PointB and the normalvector if there is penetration.
Just like in Collision Callbacks and Triggers Tutorial (http://bulletphysics.org/mediawiki-1.5. ... d_Triggers)
However if i have an Cylinder in Y-Direction, that is falling down, due to gravitational force, on a box ( not calculated with bullet!), the contactpoints seems to be wrong. My time-discretization is 1E6 Hz (very high but needed atm.);
First I get one pair of contactpoints and after some short time two, then three and finally four pairs of contactpoints. And therefor my ContactLaw (F = c*x^e and M = r x F; r = distance from contactpair to CenterofMass/CoM) calculates an Moment

In particular I have a CylinderY which CoM/Frame starts at x = 0, y = 2, z = 0 and Radius in x = 1, Radius in z = 1 and halfHeigth = 1;
My Objects do all have a margin of 0.f, although other margins did not remove this problem.
The first contactpair I find is:
BodyA: x= -0.421760, y= -0.500000, z = -0.311039
BodyB: x= -0.421761, y= -0.465362, z = -0.311038
This seems to be strange since I would expect the Pair to be like
BodyA: x= 0, y= -0.500000, z =0
BodyB: x= 0, y= -0.465362, z = 0
or that there are more pairs found at first contact (like 4 or 8 ).
Has anyone ever had the same problem and how many contactpoints should the gjk-dispatcher find for an CylinderY-Box-Contact?
I hope you understood my problem.
Thanks in advance,
Andreas
P.S.: I add snippets from my code, so you can hopefully understand what I am doing.
DefaultCollisionObjects:
Code: Select all
...
_p_CollisionConfiguration = new btDefaultCollisionConfiguration();
_p_Dispatcher = new btCollisionDispatcher(_p_CollisionConfiguration);
_p_BroadphaseInterface = new btAxisSweep3(btVector3(-1000,-1000,-1000),btVector3(1000,1000,1000)); // min and max dimension of the world
_p_BulletCollisionWorld = new btCollisionWorld(_p_Dispatcher, _p_BroadphaseInterface, _p_CollisionConfiguration);
...
Code: Select all
if (strcmp(p_collisionshape[i].a, "sphere") == 0)
{
// Neues Sphere Shape erstellen und dem CollisionObject zuweisen
btSphereShape* _p_CollisionShape = new btSphereShape((btScalar)p_collisionshape[i].b);
_p_CollisionShape->setMargin(0.f);
_p_CollisionObject->setCollisionShape(_p_CollisionShape);
if(debugflag)
{
debuglog("CollisionObjekt wurde erstellt\n Typ ist Sphere\n","Log.txt","a");
};
}
else if (strcmp(p_collisionshape[i].a, "box") == 0)
{
btVector3 halfboxdimensions;
halfboxdimensions.setX(p_collisionshape[i].b);
halfboxdimensions.setY(p_collisionshape[i].c);
halfboxdimensions.setZ(p_collisionshape[i].d);
// Neues Box Shape erstellen und dem CollisionObject zuweisen
btBoxShape* _p_CollisionShape = new btBoxShape(halfboxdimensions);
_p_CollisionShape->setMargin(0.f);
_p_CollisionObject->setCollisionShape(_p_CollisionShape);
if(debugflag)
{
debuglog("CollisionObjekt wurde erstellt\n Typ ist Box\n","Log.txt","a");
};
}
else if (strcmp(p_collisionshape[i].a, "cylinder") == 0)
{
// Neues Cylinder Shape erstellen und dem CollisionObject zuweisen
if (p_collisionshape[i].e == 0)
{
btVector3 halfcylinderdimensions;
halfcylinderdimensions.setX(p_collisionshape[i].d);
halfcylinderdimensions.setY(p_collisionshape[i].b);
halfcylinderdimensions.setZ(p_collisionshape[i].c);
btCylinderShapeX* _p_CollisionShape = new btCylinderShapeX(halfcylinderdimensions);
_p_CollisionShape->setMargin(0.f);
_p_CollisionObject->setCollisionShape(_p_CollisionShape);
if(debugflag)
{
debuglog("CollisionObjekt wurde erstellt\n Typ ist Cylinder\n Zylinderachse: X\n","Log.txt","a");
};
}
else if (p_collisionshape[i].e == 1)
{
btVector3 halfcylinderdimensions;
halfcylinderdimensions.setX(p_collisionshape[i].b);
halfcylinderdimensions.setY(p_collisionshape[i].d);
halfcylinderdimensions.setZ(p_collisionshape[i].c);
btCylinderShape* _p_CollisionShape = new btCylinderShape(halfcylinderdimensions);
_p_CollisionShape->setMargin(0.f);
_p_CollisionObject->setCollisionShape(_p_CollisionShape);
if(debugflag)
{
debuglog("CollisionObjekt wurde erstellt\n Typ ist Cylinder\n Zylinderachse: Y\n","Log.txt","a");
};
}
if (p_collisionshape[i].e == 2)
{
btVector3 halfcylinderdimensions;
halfcylinderdimensions.setX(p_collisionshape[i].b);
halfcylinderdimensions.setY(p_collisionshape[i].c);
halfcylinderdimensions.setZ(p_collisionshape[i].d);
btCylinderShapeZ* _p_CollisionShape = new btCylinderShapeZ(halfcylinderdimensions);
_p_CollisionShape->setMargin(0.f);
_p_CollisionObject->setCollisionShape(_p_CollisionShape);
if(debugflag)
{
debuglog("CollisionObjekt wurde erstellt\n Typ ist Cylinder\n Zylinderachse: Z\n","Log.txt","a");
};
}
else
{
if(debugflag)
{
debuglog("ungueltige Wahl der Zylinderachse\n","Error.txt","a");
};
}
}
else
{
if(debugflag)
{
debuglog("CollisionObjekt wurde nichts zugeordnet\n","Error.txt","a");
};
}