Page 1 of 1

Bullet + Ogre: Making holes in a soft body

Posted: Mon Feb 14, 2011 12:55 am
by rs_kryptik61636
Hi

I'm currently working on a surgical simulator and am using the OGRE engine for rendering and Bullet for the soft body physics. I was looking into mesh cutting. For testing purposes, I've imported the surgical tool mesh and made it a kinematic body and the organ mesh as a soft body. After looking at the Bullet soft body demo code and some of the glue/fracture code (http://code.google.com/p/bullet/issues/detail?id=90), I created the following internal tick callback function:

Code: Select all

void cuttingCallback( btDynamicsWorld *world, btScalar timeStep )
{
	int numManifolds = world->getDispatcher()->getNumManifolds();
	for( int i = 0; i < numManifolds; i++ )
	{
		btPersistentManifold *currentManifold = world->getDispatcher()->getManifoldByIndexInternal(i);
		if(!currentManifold)
			continue;

		for( int p = 0; p < currentManifold->getNumContacts(); p++ )
		{
			btVector3 hitPoint = currentManifold->getContactPoint(p).getPositionWorldOnA();
			ImplicitSphere iSphere(hitPoint,10);
			Globals::psb->refine(&iSphere,0.0001,true);
		}
	}
}


This is just a test function to make holes in the soft body. It doesn't seem to work. I've disabled gravity so that the objects just float in space. Does anyone have any idea what could be wrong? Any help would be appreciated. Thanks.

Re: Bullet + Ogre: Making holes in a soft body

Posted: Sat Mar 26, 2011 1:04 am
by rs_kryptik61636
Update:

I just realized something terrifying as well as sorta fun :lol: . When you use the 'refine' function of a Bullet soft body to cut it, the vertex and index list change (well duh :roll: ). Now as far as I can tell, OGRE and Bullet don't follow the same pattern of specifying triangle indices. OGRE has it's own index list whereas Bullet uses this weird function that I keep coming across:

Code: Select all

#define IDX(_x_,_y_) ((_y_)*maxidx+(_x_))
Creating a new OGRE mesh with the updated vertices is straightforward but it's the index list that's bothering me. I need to figure out Bullet's index list style. I'm going to keep hacking away at this but any help would be greatly appreciated :D

Re: Bullet + Ogre: Making holes in a soft body

Posted: Sat Mar 26, 2011 8:41 am
by xexuxjy
That function is just converting a 2d grid look up into a 1d one.

Re: Bullet + Ogre: Making holes in a soft body

Posted: Mon Mar 28, 2011 11:41 pm
by rs_kryptik61636
Ok, so I've made progress in that I'm able to recreate the OGRE mesh from the 'refine'-d Bullet soft body by iterating over the Bullet faces list for the triangle indices (my texture co-ordinates are a mess but that's another story). What I'm thinking now is since Bullet doesn't maintain contact points for soft bodies as of yet, should I find the node on the cutting instrument which is closest to the mesh and then refine at that node or is there a better way to get contact points?

Re: Bullet + Ogre: Making holes in a soft body

Posted: Mon May 28, 2018 7:12 pm
by engelfaul
Hello,

I am new in this world (Ogre and bullet) can you make holes in a soft body? I cant yet :(