Mesh modification in real time

Post Reply
segovia
Posts: 13
Joined: Fri Oct 17, 2014 5:43 pm

Mesh modification in real time

Post by segovia »

I am working on a surgical simulation using BulletPhysics and so far the physics and collisions are working well.

I would now like to be able to drill holes into a bone. The bone is a mesh loaded from an .obj file. Does BulletPhysics have some built-in classes/functions that could help in this regard? I could not find anything in the demos that would help me with this. Basically, I would like to refine the mesh where the drill bit hits the bone, and then push some vertices below the surface of the bone to create the hole. (Meshmixer has an extrusion tool that does just that, but it doesn't seem to have an API.)

If not, I would appreciate any suggestion on how to proceed with this (other libraries, what algorithms to use, ...). Thanks!
User avatar
drleviathan
Posts: 680
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Mesh modification in real time

Post by drleviathan »

The shape of an object in Bullet is determined by the pointer btCollisionObject::m_collisionShape and btRigidBody derives from btCollisionObject.

When you build a btRigidBody you must pass a shape pointer to the constructor, however the base class btCollisionObject provides an API for swapping the old shape out for a new one. So you could build a new bone shape (one with the hole) and then use btCollisionObject::setCollisionShape() to feed it to the relevant btRigidBody instance.

I don't see any Bullet Demos that swap different shapes in on the fly, however it should work in theory since shapes can be shared so they don't really store any "state" for the RigidBody's that use them. That said, if you swap in bad shapes that suddenly interpenetrate with objects in the world I suspect you'll experience pops and glitches.
segovia
Posts: 13
Joined: Fri Oct 17, 2014 5:43 pm

Re: Mesh modification in real time

Post by segovia »

Thanks, that's great information that I was going to need eventually.

My most pressing concern, however, is how to modify the mesh. Do you have any recommendation as to what algorithm to use? I'm contemplating filling the whole volume with tiny cubic voxels and eliminating the ones that the drill bit encounters and rebuilding the mesh from the remaining voxels (although I still have no idea how I would do all that), but if I could just deal directly with the mesh instead, that would be great...
c6burns
Posts: 149
Joined: Fri May 24, 2013 6:08 am

Re: Mesh modification in real time

Post by c6burns »

If you go the voxel route, one example usage which is screenshotted right on the front page is a drill operating on a tooth:
http://www.volumesoffun.com/polyvox-about/
segovia
Posts: 13
Joined: Fri Oct 17, 2014 5:43 pm

Re: Mesh modification in real time

Post by segovia »

That looks promising. It looks like I'll have to voxelize the mesh first (probably offline) as that doesn't seem to be handled by that library, but a quick preliminary search found some interesting links that might help me with that.

Thanks!
Post Reply