Proper way to add and remove a rigid body from the world?

Post Reply
SRGBulletPhysics
Posts: 4
Joined: Sat Aug 09, 2014 6:45 pm

Proper way to add and remove a rigid body from the world?

Post by SRGBulletPhysics »

Hi,

I have a dynamic rigid body which i add and remove from my world frequently. Every time a button is pressed.

I add the object to the world using this call...

Code: Select all

m_dynamicsWorld->addRigidBody( pBody->GetRigidBody(), group, mask );
I remove the object from the world using this call...

Code: Select all

m_dynamicsWorld->removeRigidBody( pBody->GetRigidBody() );
This works almost all of the time but sometimes i get an assert here...

Code: Select all

int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint, bool isPredictive)
{
	if (!isPredictive)
	{
		btAssert(validContactDistance(newPoint));
	}

From what i can tell Bullet physics is interpolating from the coordinates my object was removed from the world at, to the new coordinates the object is being added to the world at. And in doing so is colliding with a kinematic body. Causing the assert above.

The behaviour i wanted was that my object would just appear at the new coordinates. I already know that these new coordinates don't have another object there.
Post Reply