Erwin Coumans wrote:
VicariousEnt wrote:
Perhaps it could be an optional parameter in the WorldImporter loadFile() function?
Yes, we can add a flag/setting to the btBulletWorldImporter, to create collision objects for objects with mass 0.
This will of course require the btCollisionObjects to be added to the DynamicWorld as well as the RigidBodies and Constraints that are right now. This brings up one other issue. The WorldImporter is automatically adding these object types to the DynamicWorld but it never removes them. btBulletWorldImporter::deleteAllData() should really remove the objects from the DynamicWorld that it added before it deletes them. This isn't an issue if you're already manually removing all objects from the DynamicsWorld before the WorldImporter is destroyed (and calling deleteAllData()), but it is if you want to be able to use multiple btBulletWorldImporters and be able to load and remove groups of collision without recreating the DynamicsWorld as I am. Plus it forces you to be very careful with the order in which you destroy the Importer and World.
I've altered the function myself to do this but I would imagine this change should be propagated into the next release. I did it like this (the blue is the new stuff)...
void btBulletWorldImporter::deleteAllData()
{
int i;
for (i=0;i<m_allocatedCollisionShapes.size();i++)
{
delete m_allocatedCollisionShapes[i];
}
m_allocatedCollisionShapes.clear();
if(m_dynamicsWorld)
{
for (i=0;i<m_allocatedRigidBodies.size();i++)
{
m_dynamicsWorld->removeRigidBody(btRigidBody::upcast(m_allocatedRigidBodies[i]));
delete m_allocatedRigidBodies[i];
}
}
else
{ for (i=0;i<m_allocatedRigidBodies.size();i++)
{
delete m_allocatedRigidBodies[i];
}
} m_allocatedRigidBodies.clear();
if(m_dynamicsWorld)
{
for (i=0;i<m_allocatedConstraints.size();i++)
{
m_dynamicsWorld->removeConstraint(m_allocatedConstraints[i]);
delete m_allocatedConstraints[i];
}
}
else
{ for (i=0;i<m_allocatedConstraints.size();i++)
{
delete m_allocatedConstraints[i];
}
} m_allocatedConstraints.clear();
.
.
. nothing else changed from here
I could add this to the Issue list if you like, assuming you agree that this is a problem.