Rigid bodies not colliding with soft bodies
Posted: Thu Dec 08, 2011 7:45 pm
Hello all,
I'm currently adding Bullet soft bodies to Dynamica as a personal learning exercise (I'll release the code when it's done, along with any documentation that comes out of it). I've made good progress but I'm currently blocked by the fact that soft bodies do not seem to interact with rigid bodies at all inside the plugin. Soft bodies do collide with each other, but not rigid bodies. I was wondering if anyone more familiar with the code might know any "obvious" reasons why this would happen. My soft body object (class bt_soft_body) construction code looks something like this:
I've modified the bt_solver_t constructor code to this:
m_worldInfo is passed in to the bt_soft_body constructor when adding new soft bodies to the solver.
Thanks in advance for any help.
I'm currently adding Bullet soft bodies to Dynamica as a personal learning exercise (I'll release the code when it's done, along with any documentation that comes out of it). I've made good progress but I'm currently blocked by the fact that soft bodies do not seem to interact with rigid bodies at all inside the plugin. Soft bodies do collide with each other, but not rigid bodies. I was wondering if anyone more familiar with the code might know any "obvious" reasons why this would happen. My soft body object (class bt_soft_body) construction code looks something like this:
Code: Select all
bt_soft_body::bt_soft_body(btSoftBodyWorldInfo &worldInfo, const std::vector<float> &triVertexCoords,
const std::vector<int> &triVertexIndices )
{
this->numTriangles = triVertexIndices.size() / 3;
this->numVertices = triVertexCoords.size() / 3;
this->triVertCoords = new btScalar[triVertexCoords.size()];
this->triVertIndices = new int[triVertexIndices.size()];
for(int i = 0; i < triVertexCoords.size(); i ++)
{
this->triVertCoords[i] = static_cast<btScalar>(triVertexCoords[i]);
}
for(int i = 0; i < triVertexIndices.size(); i ++)
{
this->triVertIndices[i] = triVertexIndices[i];
}
this->m_body.reset( btSoftBodyHelpers::CreateFromTriMesh(worldInfo, this->triVertCoords, this->triVertIndices, this->numTriangles ));
btSoftBody::Material* pm = this->m_body->appendMaterial();
pm->m_kLST = 0.5;
this->m_body->scale(btVector3(1,1,1));
this->m_body->setTotalMass(50);
this->m_body->generateBendingConstraints(2, pm);
this->m_body->m_cfg.piterations=2;
this->m_body->m_cfg.kDF = 0.5;
this->m_body->generateClusters(50);
this->m_body->m_cfg.collisions += btSoftBody::fCollision::CL_RS;
this->m_body->m_cfg.collisions += btSoftBody::fCollision::CL_SS;
this->m_body->randomizeConstraints();
}Code: Select all
bt_solver_t::bt_solver_t():
m_broadphase(new btDbvtBroadphase()),
m_solver(new btSequentialImpulseConstraintSolver),
m_collisionConfiguration(new btSoftBodyRigidBodyCollisionConfiguration()),
m_dispatcher(new btCollisionDispatcher(m_collisionConfiguration.get())),
m_dynamicsWorld(new btSoftRigidDynamicsWorld(m_dispatcher.get(),
m_broadphase.get(),
m_solver.get(),
m_collisionConfiguration.get())
),
m_worldInfo()
{
//register algorithm for concave meshes
btGImpactCollisionAlgorithm::registerAlgorithm(m_dispatcher.get());
m_dynamicsWorld->setGravity(btVector3(0, -9.81f, 0));
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
bt_debug_draw* dbgDraw = new bt_debug_draw();
m_dynamicsWorld->setDebugDrawer(dbgDraw);
m_worldInfo.m_broadphase = m_broadphase.get();
m_worldInfo.m_dispatcher = m_dispatcher.get();
m_worldInfo.m_gravity = m_dynamicsWorld->getGravity();
m_worldInfo.m_sparsesdf.Initialize();
}Thanks in advance for any help.