I noticed that in Bullet examples (except in the Gimpact demo) the
btDefaultCollisionConfiguration object is never deleted.
In my code, I delete it by doing:
Code: Select all
bt_collision_configuration = new btDefaultCollisionConfiguration()
bt_dispatcher = new btCollisionDispatcher(bt_collision_configuration);
bt_broadphase = new bt32BitAxisSweep3(worldAabbMin,worldAabbMax, max_objects);
bt_collision_world = new btCollisionWorld(bt_dispatcher, bt_broadphase, bt_collision_configuration);
[.... do some collision detection....]
if(bt_collision_world) delete bt_collision_world;
if(bt_broadphase) delete bt_broadphase;
if(bt_dispatcher) delete bt_dispatcher;
if(bt_collision_configuration) delete bt_collision_configuration; // ***THE MISSING PART IN DEMOS??**
free it! I had to modify the btDefaultCollisionConfiguration creator and destructor, so that
it deletes correctly the embedded pool allocators, but I fear that I 'broke' some optimization
(I see that aligned allocations were used..). I simply modified lines like the following
Code: Select all
void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
m_persistentManifoldPool = new (mem) btPoolAllocator(
sizeof btPersistentManifold),DEFAULT_MAX_OVERLAPPING_PAIRS);
Code: Select all
m_persistentManifoldPool = new btPoolAllocator(
sizeof(btPersistentManifold),DEFAULT_MAX_OVERLAPPING_PAIRS);
to the obvious delete m_collisionAlgorithmPool.)
I don't know if I missed something, or is it simply a 'work in progress' class
which still needed some finishing...
Alessandro Tasora