collision between softbody and rigidbody

Post Reply
zjl19870808
Posts: 21
Joined: Tue Nov 03, 2009 8:33 am

collision between softbody and rigidbody

Post by zjl19870808 »

Hello, everyone! When the rigidbody collides with a softbody, it often penetrate the softbody, which isn't expected to happen in BULLET :? ! so how can I avoid it? Thank you!

Jet
zjl19870808
Posts: 21
Joined: Tue Nov 03, 2009 8:33 am

Re: collision between softbody and rigidbody

Post by zjl19870808 »

zjl19870808 wrote:Hello, everyone! When the rigidbody collides with a softbody, it often penetrate the softbody, which isn't expected to happen in BULLET :? ! so how can I avoid it? Thank you!

Jet
IS THERE ANYBODY KNOWS ABOUT IT?
IT SEEMS THAT I SHOULD SOLVE THE PROBLEM MYSELY BY MODIFYING THE COLLISOIN ARITHMETIC!
fishboy82
Posts: 91
Joined: Wed Jun 10, 2009 4:01 am

Re: collision between softbody and rigidbody

Post by fishboy82 »

Use Cluster can avoid this problem but this will make the soft body looks like more rigid.....
zjl19870808
Posts: 21
Joined: Tue Nov 03, 2009 8:33 am

Re: collision between softbody and rigidbody

Post by zjl19870808 »

fishboy82 wrote:Use Cluster can avoid this problem but this will make the soft body looks like more rigid.....
Hi, Thank you very much for your reply. The softbody looks like a rigidbody can be received, so can you tell me some more infomation? Thank you!
fishboy82
Posts: 91
Joined: Wed Jun 10, 2009 4:01 am

Re: collision between softbody and rigidbody

Post by fishboy82 »

Yes ,because Bullet only test softbody's vertex with rigid body for collision detection. So it will be easy for a rigid body's corner to penetrate to a softbody's face. Even worth the rigid body with small size will pass through a soft body's face. But when use Cluster ,bullet will treate the sofrbody like a lot of piece of rigid body's so in this case the collision detection is performed like rigid-rigid body thus will not penetrate
zjl19870808
Posts: 21
Joined: Tue Nov 03, 2009 8:33 am

Re: collision between softbody and rigidbody

Post by zjl19870808 »

fishboy82 wrote:Yes ,because Bullet only test softbody's vertex with rigid body for collision detection. So it will be easy for a rigid body's corner to penetrate to a softbody's face. Even worth the rigid body with small size will pass through a soft body's face. But when use Cluster ,bullet will treate the sofrbody like a lot of piece of rigid body's so in this case the collision detection is performed like rigid-rigid body thus will not penetrate
Hi, Thank you again, I tryed this method by adding

Code: Select all

//psb stand for the soft body
psb->generateClusters(300);
but it didn't work, it seemed that there was no effect at all! I changed the parameter of generateClusters() from 300 to a very large number, such as 30e7, but it still didn't work :?
so, how can I use cluster, is my adding code right?
Thank you, your suggestion will be greatly appreciated!
fishboy82
Posts: 91
Joined: Wed Jun 10, 2009 4:01 am

Re: collision between softbody and rigidbody

Post by fishboy82 »

Hi: you should config the collision algo like this:
psb->m_cfg.collisions = btSoftBody::fCollision::CL_SS+
btSoftBody::fCollision::CL_RS;


You can take bullet's softbody demo for a reference
zjl19870808
Posts: 21
Joined: Tue Nov 03, 2009 8:33 am

Re: collision between softbody and rigidbody

Post by zjl19870808 »

fishboy82 wrote:Hi: you should config the collision algo like this:
psb->m_cfg.collisions = btSoftBody::fCollision::CL_SS+
btSoftBody::fCollision::CL_RS;


You can take bullet's softbody demo for a reference

Sorry to disturb you again, I added that already. Here is my code for creating the softbody

Code: Select all

	setPedMash();//this function set the shape of my softbody, it's a round track, like a torus 
	btSoftBody*	psb=btSoftBodyHelpers::CreateFromTriMesh(pdemo->m_softBodyWorldInfo,PedgVertices,&PedgIndices[0][0],PED_NUM_TRIANGLES);
	btSoftBody*	psb2=btSoftBodyHelpers::CreateFromTriMesh(pdemo->m_softBodyWorldInfo,PedgVertices,&PedgIndices[0][0],PED_NUM_TRIANGLES);//pdemo is an object of softdemo.
	btSoftBody::Material*	pm=psb->appendMaterial();
	btVector3 x(-10,2,0);
	btVector3 x2(10,2,0);
	btVector3 a(SIMD_PI,0,SIMD_HALF_PI);
	btVector3 s(5.0,5.0,5.0);
	
	pm->m_kLST				=	1.0;
	pm->m_flags				-=	btSoftBody::fMaterial::DebugDraw;
	psb->generateBendingConstraints(0.2,pm);
	psb2->generateBendingConstraints(0.2,pm);
	
	psb->m_cfg.piterations	=	20;
	psb2->m_cfg.piterations	=	20;
		
	psb->generateClusters(30e7);
	psb2->generateClusters(30e7);

	psb->m_cfg.collisions	=	btSoftBody::fCollision::CL_SS+
		btSoftBody::fCollision::CL_RS;
	psb2->m_cfg.collisions	=	btSoftBody::fCollision::CL_SS+
		btSoftBody::fCollision::CL_RS;

	psb->scale(s);
	psb2->scale(s);
	psb->rotate(btQuaternion(a[0],a[1],a[2]));
	psb2->rotate(btQuaternion(a[0],a[1],a[2]));
	psb->translate(x);
	psb2->translate(x2);
	psb->setTotalMass(20,true);
	psb2->setTotalMass(20,true);
	psb->generateClusters(64);
	psb2->generateClusters(64);

	psb->setFriction(10);
	psb2->setFriction(10);

	pdemo->getSoftDynamicsWorld()->addSoftBody(psb);
	pdemo->getSoftDynamicsWorld()->addSoftBody(psb2);
	
	btSoftBody::LJoint::Specs	ls;
	ls.erp=0.5f;
	/*ls.position=psb->clusterCom(0);*/
	ls.position=x;psb->appendLinearJoint(ls,pdemo->m_body);psb->appendLinearJoint(ls,psb2);
	/*ls.position=psb2->clusterCom(0);*/
	ls.position=x2;psb2->appendLinearJoint(ls,pdemo->m_body);psb2->appendLinearJoint(ls,psb);
	
	btSoftBody::AJoint::Specs	aspecs;
	aspecs.cfm		=	1;
	aspecs.erp		=	1;
	aspecs.axis		=	btVector3(0,0,1);
	psb->appendAngularJoint(aspecs,pdemo->m_body);
	psb2->appendAngularJoint(aspecs,pdemo->m_body);
	psb->appendAngularJoint(aspecs,psb2);
	psb2->appendAngularJoint(aspecs,psb);
             .....
then, two rigid sphere were created to realize my softbody's deformation as my expectation. but the rigid sphere penetrated my softbody. :?
I attached my SoftBodyDemo.exe! I think it will be helpful to understand my intention. :) In SoftDemo.exe, press the key "End" and "Home" you will see the results.
THank you very much! looking forward you reply!
Attachments
SoftBodyDemo.zip
(270.91 KiB) Downloaded 590 times
User avatar
Garibalde
Posts: 44
Joined: Fri Dec 18, 2009 6:06 pm
Location: Montreal
Contact:

Re: collision between softbody and rigidbody

Post by Garibalde »

I cant run your demo seems to crash. However i had similar problems. it seems that if you change the default position and orientation of the rigid body before attaching to the world you will have problems. therefore leave default position and orientation of the rigidbody add it to the world. Then use setworldtransform to change the position and orientation. This seems to have fixed them problem for me.

Hope this helps.
Garibalde
zjl19870808
Posts: 21
Joined: Tue Nov 03, 2009 8:33 am

Re: collision between softbody and rigidbody

Post by zjl19870808 »

Garibalde wrote:I cant run your demo seems to crash. However i had similar problems. it seems that if you change the default position and orientation of the rigid body before attaching to the world you will have problems. therefore leave default position and orientation of the rigidbody add it to the world. Then use setworldtransform to change the position and orientation. This seems to have fixed them problem for me.

Hope this helps.
Garibalde
Thank you for replying!
I tried and encounter a problem. Several rigidbodies would collide with each other when they were created in default position, they would move in different directions even through btMotionState::setWorldTransform were called(Motionstate were also added when rigidbodies were created), so the whole system would be unstable. It would be even more unstalbe when softbodis were created :( . Did you have the similar problems, thank you and looking forward your replying ...

Jet
User avatar
Garibalde
Posts: 44
Joined: Fri Dec 18, 2009 6:06 pm
Location: Montreal
Contact:

Re: collision between softbody and rigidbody

Post by Garibalde »

If you create multiple bodies in the same position. This is a problem.. Create a rigid body at default and move it before startin the simulation. The reason that all the bodies go flying off is that once you start running the overlapping bodies all have force acting on them from their respective penetrations.. BOOM!!

I was suggesting is create a rigid body with default.. and add to the world then set the transform to the desired location. Start with 2 bodies.. at a predetermined distance apart at first.. see if that works for you.

if you get rigid to rigid collison working then add the soft body. same as above (change one of the rigid bodies to a soft one).

Hope this helps.
Garibalde
zjl19870808
Posts: 21
Joined: Tue Nov 03, 2009 8:33 am

Re: collision between softbody and rigidbody

Post by zjl19870808 »

Garibalde wrote:If you create multiple bodies in the same position. This is a problem.. Create a rigid body at default and move it before startin the simulation. The reason that all the bodies go flying off is that once you start running the overlapping bodies all have force acting on them from their respective penetrations.. BOOM!!

I was suggesting is create a rigid body with default.. and add to the world then set the transform to the desired location. Start with 2 bodies.. at a predetermined distance apart at first.. see if that works for you.

if you get rigid to rigid collison working then add the soft body. same as above (change one of the rigid bodies to a soft one).

Hope this helps.
Garibalde
Thank you for replying. I tryed and found it worked a little . So I changed a another method which realizes the softbodies using rigidbodies by a lot constranits, fortunately it worked well.
Jet
Post Reply