Bodies hang up when collided with CCD body.

drawtree
Posts: 7
Joined: Sat May 07, 2011 2:02 am

Bodies hang up when collided with CCD body.

Post by drawtree »

Sometimes bodies collided with CCD body hangup for a while. Sometimes it recovers after a few seconds, or remains hung.
I said it's 'sometimes' because I can't reproduce them always, but sometime. (with very high ratio)
Can I confirm is this a bug or my misconfiguration or environmental problem?

To reproduce:
Open BulletPhysics Demo, and find Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp
Replace this method with my one, compile and execute.

Code: Select all

void	CcdPhysicsDemo::shootBox(const btVector3& destination)
{
	if (m_dynamicsWorld)
	{
		float mass = 1.f;
		btTransform startTransform;
		startTransform.setIdentity();
		btVector3 camPos = getCameraPosition();
		startTransform.setOrigin(camPos);

		setShootBoxShape ();


		btRigidBody* body = this->localCreateRigidBody(mass, startTransform,m_shootBoxShape);
		body->setLinearFactor(btVector3(1,1,1));
		//body->setRestitution(1);

		btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
		linVel.normalize();
		linVel*=m_ShootBoxInitialSpeed;

		////////////////////////////////
		// Here's bug reproduction code.
		////////////////////////////////
		linVel	=	btVector3(-553.138611, -665.362610, 3905.295410);
		
		body->getWorldTransform().setOrigin(camPos);
		body->getWorldTransform().setRotation(btQuaternion(0,0,0,1));
		body->setLinearVelocity(linVel);
		body->setAngularVelocity(btVector3(0,0,0));
		body->setContactProcessingThreshold(1e30);

		///when using m_ccdMode, disable regular CCD
		if (m_ccdMode==USE_CCD)
		{
			body->setCcdMotionThreshold(0.0001);
			body->setCcdSweptSphereRadius(0.4f);
		}
	}
}
It doesn't happen 'always'. However you will meet the situation soon by repeating reset and right click. I meet about once for 10 times.



I'll have another code can reproduce similar problem 'always'. However I can't sure about these problems are same because the code is using

Code: Select all

		setLinearFactor(btVector3(1.0, 1.0, 0.0));
		setAngularFactor(btVector3(0.0, 0.0, 1.0));
to limit their behavior in 2D. However I'll post the code later because it needs time to separate the code from my product code.