Box-Cylinder contact detection: Wrong contactpoints?

AndreasHofmann
Posts: 3
Joined: Tue Sep 17, 2013 1:06 pm

Box-Cylinder contact detection: Wrong contactpoints?

Post by AndreasHofmann »

Hello Everyone,

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 :( finding the first contactpair.

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);
...
Creating the Objects:

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");
			};
					
		}
If you need more code, I can attach my whole Project.
AndreasHofmann
Posts: 3
Joined: Tue Sep 17, 2013 1:06 pm

Re: Box-Cylinder contact detection: Wrong contactpoints?

Post by AndreasHofmann »

Hello again,

I managed to add some example to show you the Problem.
It is just a simple Cylinder moved down onto a box, with an CollisonDetection every time the cylinder is moved.

Still the same problem with "wrong contact point" occurs.

main.h

Code: Select all

int main();
main.cpp

Code: Select all

#include "main.h"
#include "btBulletCollisionCommon.h"
#include <vector>
#include <string>


int main()
{

	int counter=0;
	// Create default CollisionClasses
	btDefaultCollisionConfiguration* p_CollisionConfig = new btDefaultCollisionConfiguration();
	btCollisionDispatcher* p_Dispatcher = new btCollisionDispatcher(p_CollisionConfig);
	btAxisSweep3* p_Broadphase = new btAxisSweep3(btVector3(-1000,-1000,-1000),btVector3(1000,1000,1000));
	btCollisionWorld* p_CollisionWorld = new btCollisionWorld(p_Dispatcher,p_Broadphase,p_CollisionConfig);


	


	// Vector for Objects
	std::vector<btCollisionObject*> v_ColObjects;

	// Create BoxObject
	btCollisionObject* p_BoxObject = new btCollisionObject();

	// Dimensions
	btVector3 halfBoxDimensions;
	halfBoxDimensions.setX(1);
	halfBoxDimensions.setY(0.5);
	halfBoxDimensions.setZ(1);

	btBoxShape* p_BoxShape = new btBoxShape(halfBoxDimensions);
	p_BoxShape->setMargin(0.f);

	p_BoxObject->setCollisionShape(p_BoxShape);

	int id1 = 1;
	p_BoxObject->setUserPointer((void*)&(id1));

	// Collect Object in Vector
	v_ColObjects.push_back(p_BoxObject);

	// Add Box to CollisionWorld
	p_CollisionWorld->addCollisionObject(p_BoxObject);

	// Create CylinderObject
	btCollisionObject* p_CylinderObject = new btCollisionObject();

	// Dimensions
	btVector3 halfCylinderDimensions;
	halfCylinderDimensions.setX(0.5); // Radius
	halfCylinderDimensions.setY(1);
	halfCylinderDimensions.setZ(0.5);  // Radius

	btCylinderShape* p_CylinderShape = new btCylinderShape(halfCylinderDimensions);
	p_CylinderShape->setMargin(0.f);

	p_CylinderObject->setCollisionShape(p_CylinderShape);

	int id2 = 2;
	p_CylinderObject->setUserPointer((void*)&id2);

	// Collect Object in Vector
	v_ColObjects.push_back(p_CylinderObject);

	// Add Cylinder to CollisionWorld
	p_CollisionWorld->addCollisionObject(p_CylinderObject);

	/* Initialize CollisionObjects */ 
	// Box
	btTransform& initbox = btTransform(btMatrix3x3(1,0,0,0,1,0,0,0,1), btVector3(0,-0.5,0));
	v_ColObjects[0]->setWorldTransform(initbox);

	// Cylinder
	btTransform& initcylinder = btTransform(btMatrix3x3(1,0,0,0,1,0,0,0,1), btVector3(0,2,0));
	v_ColObjects[1]->setWorldTransform(initcylinder);


	 /*Changing Position of Cylinder and checking for Contact*/

	 /*writing log*/
	FILE * pFile;
	pFile = fopen ("log.txt","w");
	fprintf (pFile,"Start Simulation\n");
	fclose (pFile);

	for (int i = 0; i < 150; i++)
	{
		counter++;
		FILE * pFile;
		pFile = fopen ("iteration.txt","w");
		fprintf (pFile,"schleife:%i\n",i);
		fclose (pFile);
		// check for contacts
		p_CollisionWorld->performDiscreteCollisionDetection();
		
		//fprintf (pFile,"Kontaktpruefung\n");

		int numManifolds = p_CollisionWorld->getDispatcher()->getNumManifolds();

		FILE * pFile3;
		pFile3 = fopen ("log.txt","a");
		fprintf (pFile3,"Number of Manifolds: %i\n",numManifolds);
		fclose (pFile3);

		if (numManifolds == 0)
		{
			FILE * pFile;
			pFile = fopen ("log.txt","a");
			fprintf (pFile,"No ContactManifold created\n");
			fclose (pFile);
		};
		// checking contactpoints for each each Manifold
		for (int j = 0; j < numManifolds; j++)
		{
			btPersistentManifold* p_ContactManifold = p_CollisionWorld->getDispatcher()->getManifoldByIndexInternal(j);
			p_ContactManifold->setContactBreakingThreshold(0.0);
			p_ContactManifold->setContactProcessingThreshold(0.0);

			FILE * pFile;
			pFile = fopen ("log.txt","a");
			fprintf (pFile,"ContactManifold is created\n");
			fclose (pFile);

			// Get IDs of both Bodies
			btCollisionObject* obA = (btCollisionObject*)p_ContactManifold->getBody0();
			btCollisionObject* obB = (btCollisionObject*)p_ContactManifold->getBody1();
			
			int* bodyA = (int*)(obA->getUserPointer());
			int* bodyB = (int*)(obB->getUserPointer());

			FILE * pFile2;
			pFile2 = fopen ("log.txt","a");
			fprintf (pFile2,"BodyA: %i, BodyB %i\n", *bodyA,*bodyB);
			fclose (pFile2);
			
			// receive number of contactpoints for manifold
			int numContacts = p_ContactManifold->getNumContacts();

			if (numContacts == 0)
			{
				FILE * pFile2;
				pFile2 = fopen ("log.txt","a");
				fprintf (pFile,"No contact found\n");
				fclose (pFile2);

			}

			// Get contactpoints of this Manifold
			for (int k = 0; k < numContacts; k++)
			{
				// Get each contactpointpair
				btManifoldPoint& pt = p_ContactManifold->getContactPoint(k);

				// Get Points
				const btVector3& ptA = pt.getPositionWorldOnA();
				const btVector3& ptB = pt.getPositionWorldOnB();

				FILE * pFile2;
				pFile2 = fopen ("log.txt","a");
				fprintf (pFile,"Point on A: x = %f, y = %f, z = %f\n",(float)ptA.getX(),(float)ptA.getY(),(float)ptA.getZ());
				fprintf (pFile,"Point on B: x = %f, y = %f, z = %f\n",(float)ptB.getX(),(float)ptB.getY(),(float)ptB.getZ());
				fclose (pFile2);
			
			};
		    p_ContactManifold->clearManifold();

		};

		btTransform& changecylinder = btTransform(btMatrix3x3(1,0,0,0,1,0,0,0,1), btVector3(0,(2-0.01*(counter+1)),0));
		v_ColObjects[1]->setWorldTransform(changecylinder);
		
		
	
	
	};
	

	delete p_CollisionWorld;	
	delete p_CollisionConfig;
	delete p_Dispatcher;
	delete p_Broadphase;
	delete p_BoxObject;
	delete p_BoxShape;
	delete p_CylinderShape;
	delete p_CylinderObject;


	return 0;




};
The resulting txt-file is:
  • ...Skipping the first Lines, since no Contact occurs...
    .
    .
    .
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    No contact found
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.046415, y = 0.000000, z = 0.034338
    Point on B: x = -0.046415, y = -0.010000, z = 0.034338
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.046523, y = 0.000000, z = 0.034449
    Point on B: x = -0.046523, y = -0.020000, z = 0.034449
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.046633, y = 0.000000, z = 0.034561
    Point on B: x = -0.046633, y = -0.030000, z = 0.034561
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.046744, y = -0.000000, z = 0.034675
    Point on B: x = -0.046744, y = -0.040000, z = 0.034675
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.046855, y = -0.000000, z = 0.034789
    Point on B: x = -0.046855, y = -0.050000, z = 0.034789
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.046968, y = -0.000000, z = 0.034905
    Point on B: x = -0.046968, y = -0.060000, z = 0.034905
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.047082, y = -0.000000, z = 0.035023
    Point on B: x = -0.047082, y = -0.070000, z = 0.035023
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.047197, y = -0.000000, z = 0.035141
    Point on B: x = -0.047197, y = -0.080000, z = 0.035141
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.047313, y = -0.000000, z = 0.035261
    Point on B: x = -0.047313, y = -0.090000, z = 0.035261
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.047430, y = 0.000000, z = 0.035382
    Point on B: x = -0.047430, y = -0.100000, z = 0.035382
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.047548, y = 0.000000, z = 0.035505
    Point on B: x = -0.047548, y = -0.110000, z = 0.035505
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.047667, y = 0.000000, z = 0.035629
    Point on B: x = -0.047667, y = -0.120000, z = 0.035629
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.047787, y = 0.000000, z = 0.035755
    Point on B: x = -0.047787, y = -0.130000, z = 0.035755
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.047909, y = 0.000000, z = 0.035882
    Point on B: x = -0.047909, y = -0.140000, z = 0.035882
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.150000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.160000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.170000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.180000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000000, y = 0.000000, z = -0.000000
    Point on B: x = -0.000000, y = -0.190000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000000, y = 0.000000, z = -0.000000
    Point on B: x = -0.000000, y = -0.200000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.210000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.220000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    No contact found
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.240000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000000, y = 0.000000, z = -0.000000
    Point on B: x = -0.000000, y = -0.250000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.260000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.270000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.280000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000000, y = -0.000000, z = -0.000000
    Point on B: x = -0.000000, y = -0.290000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000000, y = -0.000000, z = -0.000000
    Point on B: x = -0.000000, y = -0.300000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000001, y = -0.000000, z = 0.000000
    Point on B: x = 0.000001, y = -0.310000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    No contact found
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = -0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.330000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = -0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.340000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000000, y = 0.000000, z = -0.000000
    Point on B: x = -0.000000, y = -0.350000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000000, y = 0.000000, z = -0.000000
    Point on B: x = -0.000000, y = -0.360000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000000, y = 0.000000, z = -0.000000
    Point on B: x = -0.000000, y = -0.370000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.380000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000001, y = 0.000000, z = 0.000001
    Point on B: x = 0.000001, y = -0.390000, z = 0.000001
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000001, y = 0.000000, z = -0.000000
    Point on B: x = -0.000001, y = -0.400000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.410000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.420000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.430000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    No contact found
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    No contact found
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = -0.000000, y = 0.000000, z = -0.000000
    Point on B: x = -0.000000, y = -0.460000, z = -0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.470000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.480000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000000, y = 0.000000, z = 0.000000
    Point on B: x = 0.000000, y = -0.490000, z = 0.000000
    Number of Manifolds: 1
    ContactManifold is created
    BodyA: 1, BodyB 2
    Point on A: x = 0.000001, y = 0.000000, z = 0.000001
    Point on B: x = 0.000001, y = -0.500000, z = 0.000001
AndreasHofmann
Posts: 3
Joined: Tue Sep 17, 2013 1:06 pm

Re: Box-Cylinder contact detection: Wrong contactpoints?

Post by AndreasHofmann »

Well, after some (deep) digging in the forums I found, that the GJK-Algorithm only returns 1 ContactPointPair per Step.

I found, that it is possible to run multiple Iterations per Step with the ->setConvexMultipointIterations(...) and ->setPlaneConvexMultipointIterations(...) methods of the DefaultCollisionConfiguration.
However, when calculating the Contactforces from the given Contactpoints I get an Moment that rotates my Cylinder.

How can I tell Bullet to somehow calculate multiple Contactpoints, that prevent my Cylinder from rotating. (Something like the perturbing around normal as shown by Erwin Coumans in his 2010 GDC presentation bullet.googlecode.com/files/GDC10_Coumans_Erwin_Contact.pdf)

Find attached a small (hopefully) selfexplaning ppt-file of the Problem.

P.S.:

The blue body is the box, the red one the cylinder. Just to be clear.
You do not have the required permissions to view the files attached to this post.