Page 1 of 1

Softbody collision problem

Posted: Mon Nov 24, 2014 3:11 pm
by yang
Hi,
I want to know if a softbody is colliding with rigid body or not.
what should I do?

I can get the colliding information of a rigid body by the code below, But when it comes to be a softbody,
"collisionPairs" is always 0 even through it is colliding with a rigid body.

Code: Select all

int collisionPairs = mp_btDynamicsWorld->getDispatcher()->getNumManifolds(); // collision pairs
	for (int i = 0; i < collisionPairs; i++)
	{
		btPersistentManifold* contactManifold =  mp_btDynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
		btCollisionObject* obA = const_cast<btCollisionObject*>(contactManifold->getBody0());
		btCollisionObject* obB = const_cast<btCollisionObject*>(contactManifold->getBody1());
		string *s1 = static_cast<string*>(obA->getUserPointer());
		string *s2 = static_cast<string*>(obB->getUserPointer());
                //..do something
         }

Re: Softbody collision problem

Posted: Tue Nov 25, 2014 4:16 pm
by Flix
No wonder! It's always been like that :)

And that's one of the two reasons why I've stopped using soft bodies some year ago (the other reason is that soft bodies never go to sleep).

P.S. Some user might argue that there could be other ways to check for collisions between rigid bodies and soft bodies (maybe traversing the btSoftBody class fields at each frame), but that was not a good solution for me :oops: