Hello, in my project I am creating a btCollisionWorld, and I sometimes need to delete it and substitute it with another one (e.g. when a scene changes) now, how to delete a btCollisionWorld properly when I don't need it anymore? I am currently initializing it with:
Code: Select all
// Initialize physical world
btCollisionConfiguration* mConfiguration = new btDefaultCollisionConfiguration();
physicalWorld = new btCollisionWorld(
new btCollisionDispatcher(mConfiguration),
new btDbvtBroadphase(),
mConfiguration
);
physicalWorld->setForceUpdateAllAabbs(true);
But somehow the code for deletion doesn't free all the space (about 3MB for an empty btCollisionWorld from my tests) that is allocated at creation. The code I am using to delete it is the following:
Code: Select all
// Delete all objects from physicalWorld
std::vector<btCollisionObject*>::iterator coIt;
for (coIt= collisionObjects.begin(); coIt != collisionObjects.end(); ++coIt) {
physicalWorld->removeCollisionObject(coIt);
}
delete physicalWorld;
What am I doing wrong? Moreover, in between creation and deletion I also add btCollisionObjects whose shape is a triangle mesh shape o a GImpact mesh shape, do I have to manually delete the shape for each object or this is handled automatically? And what about meshes, I have to delete them by hand?
Thank you
Tunnuz