Anybody working on Soft Body Self-Collision?

Post Reply
MamboDave
Posts: 5
Joined: Tue Nov 11, 2008 2:20 pm

Anybody working on Soft Body Self-Collision?

Post by MamboDave »

Hi there,

I've recently started using Bullet for my final project at university and have realised that a feature I really need is soft body self-collision. Is anybody working on this? If not I would be really interested in attempting to implement this feature, although the whole reason I chose to use Bullet is because my collision detection skills aren't so hot. Does anybody already have any ideas about how to do this? I can imagine a naive implementation would be to use a ghost object that mirrors the data of a soft body already in the world and perform soft vs soft collisions between these two objects, although I'm guessing this would have its drawbacks.

Thanks a lot and great job on Bullet

Dave
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Anybody working on Soft Body Self-Collision?

Post by Erwin Coumans »

We plan on adding the option for soft body self-collisions.

Are you using collision clusters? It might be a good solution. You just have to exclude collisions between the same cluster. If you are not using collision clusters, just exclude collisions between connected features. The btDbvt acceleration structure can be used.
imagine a naive implementation would be to use a ghost object that mirrors the data of a soft body already in the world and perform soft vs soft collisions between these two objects, although I'm guessing this would have its drawbacks.
You would need to deal with exclusion of the same/connected features. It is probably best to explicitly test for self-collisions, just loop over all active btSoftbody objects, add a 'self-collision' method. You should be able to re-use a lot of the existing collision code.

If you have some time, please try implementing this and contribute your improvements,
Thanks,
Erwin
MamboDave
Posts: 5
Joined: Tue Nov 11, 2008 2:20 pm

Re: Anybody working on Soft Body Self-Collision?

Post by MamboDave »

Hi Erwin,

I'm not using collision clusters as the shapes I am creating are not convex.

I've had a very quick look at adding a self-collision method to btSoftBody using some of the code in the defaultCollisionHandler without excluding checks between connected features but it doesn't seem to have any effect.

Code: Select all

void btSoftBody::selfCollide() {

  btSoftColliders::CollideVF_SS	docollide;

  /* common */ 
  docollide.mrg = getCollisionShape()->getMargin()*2.f;
	
  /* my nodes vs my faces	*/ 
  docollide.psb[0]=this;
  docollide.psb[1]=this;
  docollide.psb[0]->m_ndbvt.collideTT(	docollide.psb[0]->m_ndbvt.m_root, docollide.psb[1]->m_fdbvt.m_root, docollide );

}
Which I am calling from internalSingleStepSimulation:

Code: Select all

void	btSoftRigidDynamicsWorld::internalSingleStepSimulation( btScalar timeStep)
{
	btDiscreteDynamicsWorld::internalSingleStepSimulation( timeStep );

	///solve soft bodies constraints
	solveSoftBodiesConstraints();
	
	for ( int i=0;i<m_softBodies.size();i++)
	{
		btSoftBody*	psb=(btSoftBody*)m_softBodies[i];
		psb->selfCollide();	
	}

	///update soft bodies
	updateSoftBodies();
}
So I'm supposing I can use the same collision policy as CollideVF_SS as I'm still colliding nodes against faces and just create a new collide method for btDbvt which excludes connected features. What I don't understand is why this current method has absolutely no effect. Could this be something to do with the fact that I am dynamically adding nodes and faces to the soft body and am not updating the dbvt trees? I've tried calling initializeFaceTree() after adding each face but it has no effect. Maybe I should try and implement this with one of the demos first...

I'm currently working on a sort of pre-project report but it looks like self-collision is going to be one of the first things I start work on once I have finished in a few weeks time.

Cheers,

Dave
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Anybody working on Soft Body Self-Collision?

Post by Erwin Coumans »

MamboDave wrote: I'm not using collision clusters as the shapes I am creating are not convex.
A concave soft body can have multiple convex collision clusters, check the demos with a torus for example.
Maybe I should try and implement this with one of the demos first...
It would be great if you can try to implement basic self-collisions within the existing Bullet soft body demos (before trying to apply this to dynamically changing soft bodies).

Thanks,
Erwin
Post Reply