I had a look at Bullet today and tried to integrate it into my existing application. Basically I want to use it for collision detection purposes. I'm trying to build an app simulating burr hole drilling in the skull. The simulation is based on a voxel data sturcture. Forces and Erosion of voxels (when the drill, abstractly represented by a cylinder) are computed during contact of the drill with the voxels. I have a huge amount of voxles in the simulation, ranging from 20,000 to 14,000,00 voxels. I tried i created a collision object with a box shape for each voxel and a a collision object with a cylinder shape for the drill. I would want to detect collisions between the drill and the voxels in the scene. The voxels do not have any kinematic properties - basically they don't move around and collide with other voxels. Only the drill is moveable in the simulation.
My problem is that I can not assign as many voxels as I have in the simulation to the collision world. The app crashes when i add about 8100 voxels to the collision world. I tried to add only 8000 objects to the collision wolrd, but the app still crashes when i compute the collisions unsing performDiscreteCollisionDetection.
I'm using bt32BitAxisSweep3 in the collision world, but it doen't seem to make things better. Is there a chance I could use bullet in my app, or is this just out of scale for bullet?
Here's the source code where I create the collision environment and add the objects to the world:
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
btVector3 worldAabbMin(-1000,-1000,-1000);
btVector3 worldAabbMax(1000,1000,1000);
bt32BitAxisSweep3* broadphase = new bt32BitAxisSweep3(worldAabbMin,worldAabbMax);
m_collisionWorld = new btCollisionWorld(dispatcher,broadphase,collisionConfiguration);
m_cylinder = new btCollisionObject();
btVector3 cylinderSize = btVector3(m_cylinderRadius/2.0,m_cylinderRadius/2.0,m_cylinderLength/2.0);
m_cylinderShape = new btCylinderShape(cylinderSize);
m_boxShape = new btBoxShape(btVector3(m_collisonVoxelCloud->m_voxelSizeX,m_collisonVoxelCloud->m_voxelSizeY,m_collisonVoxelCloud->m_voxelSizeZ));
m_cylinder->setCollisionShape(m_cylinderShape);
m_collisionWorld->addCollisionObject(m_cylinder);
Voxel* v;
for( int i=0; i<8000; i++)
{
v = m_collisonVoxelCloud->m_voxels;
//points->InsertNextPoint(v->m_pos.x, v->m_pos.y, v->m_pos.z);
// bullet physics
btCollisionObject* voxel = new btCollisionObject();
btVector3 voxelPos = btVector3(v->m_pos.x, v->m_pos.y,v->m_pos.z);
voxel->getWorldTransform().setOrigin(voxelPos);
voxel->setCollisionShape(m_boxShape);
m_collisionWorld->addCollisionObject(voxel);
}
Here's the code when I compute the collisions:
btTransform cylinderTransform = m_cylinder->getWorldTransform();
btVector3 cylinderPos = btVector3(m_deviceGlobalPos.x, m_deviceGlobalPos.y, m_deviceGlobalPos.z);
cylinderTransform.setOrigin(cylinderPos);
m_collisionWorld->performDiscreteCollisionDetection();
many object for collision detection results in crash
-
- Posts: 1
- Joined: Wed Jun 04, 2008 7:55 pm
-
- Posts: 20
- Joined: Fri Jun 15, 2007 5:03 pm
Re: many object for collision detection results in crash
First thing I'd do is make sure your voxels aren't colliding with each other.
for your voxel collision object:
voxel->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT);
and for your drill object:
drill->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
hope that helps,
bino
for your voxel collision object:
voxel->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT);
and for your drill object:
drill->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
hope that helps,
bino