Destroy bodies and joints in the destructor of CollisionWorld and DynamicsWorld
This commit is contained in:
parent
b47201fcdf
commit
345afc1a1d
|
@ -40,6 +40,15 @@ CollisionWorld::CollisionWorld()
|
|||
|
||||
// Destructor
|
||||
CollisionWorld::~CollisionWorld() {
|
||||
|
||||
// Destroy all the collision bodies that have not been removed
|
||||
std::set<CollisionBody*>::iterator itBodies;
|
||||
for (itBodies = mBodies.begin(); itBodies != mBodies.end(); ) {
|
||||
std::set<CollisionBody*>::iterator itToRemove = itBodies;
|
||||
++itBodies;
|
||||
destroyCollisionBody(*itToRemove);
|
||||
}
|
||||
|
||||
assert(mCollisionShapes.empty());
|
||||
assert(mBodies.empty());
|
||||
}
|
||||
|
|
|
@ -59,6 +59,22 @@ DynamicsWorld::DynamicsWorld(const Vector3 &gravity)
|
|||
// Destructor
|
||||
DynamicsWorld::~DynamicsWorld() {
|
||||
|
||||
// Destroy all the joints that have not been removed
|
||||
std::set<Joint*>::iterator itJoints;
|
||||
for (itJoints = mJoints.begin(); itJoints != mJoints.end();) {
|
||||
std::set<Joint*>::iterator itToRemove = itJoints;
|
||||
++itJoints;
|
||||
destroyJoint(*itToRemove);
|
||||
}
|
||||
|
||||
// Destroy all the rigid bodies that have not been removed
|
||||
std::set<RigidBody*>::iterator itRigidBodies;
|
||||
for (itRigidBodies = mRigidBodies.begin(); itRigidBodies != mRigidBodies.end();) {
|
||||
std::set<RigidBody*>::iterator itToRemove = itRigidBodies;
|
||||
++itRigidBodies;
|
||||
destroyRigidBody(*itToRemove);
|
||||
}
|
||||
|
||||
// Release the memory allocated for the islands
|
||||
for (uint i=0; i<mNbIslands; i++) {
|
||||
|
||||
|
@ -82,6 +98,9 @@ DynamicsWorld::~DynamicsWorld() {
|
|||
delete[] mConstrainedOrientations;
|
||||
}
|
||||
|
||||
assert(mJoints.size() == 0);
|
||||
assert(mRigidBodies.size() == 0);
|
||||
|
||||
#ifdef IS_PROFILING_ACTIVE
|
||||
|
||||
// Print the profiling report
|
||||
|
|
Loading…
Reference in New Issue
Block a user