Removing all affector from an ICollisionObject does not delete them. kk
Removing all affector from an ICollisionObject does not delete them.

--- a/source/collisionobject.cpp
+++ b/source/collisionobject.cpp
@@ -17,15 +17,15 @@
 

 ICollisionObject::ICollisionObject()

 {

-    static u32 collisionObjectID;

-    collisionObjectID++;

-

-    uniqueID = collisionObjectID;

-

-    attributes = 0;

-

-    IncludeNodeOnRemoval = true;

-    LiquidSimulationEnabled = true;

+  static u32 collisionObjectID;

+  collisionObjectID++;

+  

+  uniqueID = collisionObjectID;

+  

+  attributes = 0;

+

+  IncludeNodeOnRemoval = true;

+  LiquidSimulationEnabled = true;

 }

 

 void ICollisionObject::updateObject()

@@ -187,175 +187,175 @@
 

 void ICollisionObject::removeAffectors()

 {

-    list<ICollisionObjectAffector*>::Iterator it = affectors.begin();

-

-    for(; it != affectors.end(); )

-    {

-        #ifdef IRRBULLET_DEBUG_MODE

-            printf("irrBullet: Removing animator (BODY: %i)\n", this->getUniqueID());

-        #endif

-        delete (*it);

-        (*it) = 0;

-

-        it = affectors.erase(it);

+  list<ICollisionObjectAffector*>::Iterator it = affectors.begin();

+  

+  for(; it != affectors.end(); )

+    {

+#ifdef IRRBULLET_DEBUG_MODE

+      printf("irrBullet: Removing animator (BODY: %i)\n", this->getUniqueID());

+#endif

+      //delete (*it);

+      //(*it) = 0;

+      

+      it = affectors.erase(it);

     }

 }

 

 void ICollisionObject::remove()

 {

-    dynamicsWorld->addToDeletionQueue(this);

+  dynamicsWorld->addToDeletionQueue(this);

 }

 

 

 

 btCollisionObject* ICollisionObject::getPointer() const

 {

-    return object;

+  return object;

 }

 

 

 bool ICollisionObject::mergesSimulationIslands() const

 {

-    return getPointer()->mergesSimulationIslands();

+  return getPointer()->mergesSimulationIslands();

 }

 

 

 const vector3df ICollisionObject::getAnisotropicFriction() const

 {

-    const btVector3 friction = getPointer()->getAnisotropicFriction();

-

-    return vector3df(friction.getX(), friction.getY(), friction.getZ());

+  const btVector3 friction = getPointer()->getAnisotropicFriction();

+

+  return vector3df(friction.getX(), friction.getY(), friction.getZ());

 }

 

 

 bool ICollisionObject::hasAnisotropicFriction() const

 {

-    return getPointer()->hasAnisotropicFriction();

+  return getPointer()->hasAnisotropicFriction();

 }

 

 

 f32 ICollisionObject::getContactProcessingThreshold() const

 {

-    return f32(getPointer()->getContactProcessingThreshold());

+  return f32(getPointer()->getContactProcessingThreshold());

 }

 

 

 bool ICollisionObject::hasContactResponse() const

 {

-    return getPointer()->hasContactResponse();

+  return getPointer()->hasContactResponse();

 }

 

 

 EActivationState ICollisionObject::getActivationState() const

 {

-    EActivationState state = EAS_SLEEPING;

-    switch(getPointer()->getActivationState())

-    {

-        case 1:

-            state = EAS_ACTIVE;

-            break;

-        case 2:

-            state = EAS_SLEEPING;

-            break;

-        case 3:

-            state = EAS_WANTS_DEACTIVATION;

-            break;

-        case 4:

-            state = EAS_DISABLE_DEACTIVATION;

-            break;

-        case 5:

-            state = EAS_DISABLE_SIMULATION;

-    }

-

-    return state;

+  EActivationState state = EAS_SLEEPING;

+  switch(getPointer()->getActivationState())

+    {

+    case 1:

+      state = EAS_ACTIVE;

+      break;

+    case 2:

+      state = EAS_SLEEPING;

+      break;

+    case 3:

+      state = EAS_WANTS_DEACTIVATION;

+      break;

+    case 4:

+      state = EAS_DISABLE_DEACTIVATION;

+      break;

+    case 5:

+      state = EAS_DISABLE_SIMULATION;

+    }

+  

+  return state;

 }

 

 

 bool ICollisionObject::isActive() const

 {

-    return getPointer()->isActive();

+  return getPointer()->isActive();

 }

 

 

 irr::f32 ICollisionObject::getRestitution() const

 {

-    return f32(getPointer()->getRestitution());

+  return f32(getPointer()->getRestitution());

 }

 

 

 irr::f32 ICollisionObject::getFriction() const

 {

-    return f32(getPointer()->getFriction());

+  return f32(getPointer()->getFriction());

 }

 

 

 const vector3df ICollisionObject::getInterpolationLinearVelocity() const

 {

-    const btVector3 vel = getPointer()->getInterpolationLinearVelocity();

-

-    return vector3df(vel.getX(),vel.getY(),vel.getZ());

+  const btVector3 vel = getPointer()->getInterpolationLinearVelocity();

+  

+  return vector3df(vel.getX(),vel.getY(),vel.getZ());

 }

 

 

 const vector3df ICollisionObject::getInterpolationAngularVelocity() const

 {

-    const btVector3 vel = getPointer()->getInterpolationAngularVelocity();

-

-    return vector3df(vel.getX(),vel.getY(),vel.getZ());

+  const btVector3 vel = getPointer()->getInterpolationAngularVelocity();

+

+  return vector3df(vel.getX(),vel.getY(),vel.getZ());

 }

 

 

 u32 ICollisionObject::getIslandTag() const

 {

-    return u32(getPointer()->getIslandTag());

+  return u32(getPointer()->getIslandTag());

 }

 

 

 u32 ICollisionObject::getCompanionId() const

 {

-    return u32(getPointer()->getCompanionId());

+  return u32(getPointer()->getCompanionId());

 }

 

 

 f32 ICollisionObject::getHitFraction() const

 {

-    return f32(getPointer()->getHitFraction());

+  return f32(getPointer()->getHitFraction());

 }

 

 

 ECollisionFlag ICollisionObject::getCollisionFlags() const

 {

-    return ECollisionFlag(getPointer()->getCollisionFlags());

+  return ECollisionFlag(getPointer()->getCollisionFlags());

 }

 

 bool ICollisionObject::checkCollideWith(ICollisionObject* const collObj) const

 {

-    return getPointer()->checkCollideWith(collObj->getPointer());

+  return getPointer()->checkCollideWith(collObj->getPointer());

 }

 

 irr::u32 ICollisionObject::getNumAffectors() const

 {

-    u32 num = 0;

-

-    list<ICollisionObjectAffector*>::ConstIterator it = affectors.begin();

-

-    for(; it != affectors.end(); it++)

-    {

-        num++;

-    }

-

-    return num;

+  u32 num = 0;

+

+  list<ICollisionObjectAffector*>::ConstIterator it = affectors.begin();

+

+  for(; it != affectors.end(); it++)

+    {

+      num++;

+    }

+  

+  return num;

 }

 

 ICollisionObjectAffector* ICollisionObject::getAffector(irr::u32 index)

 {

-    list<ICollisionObjectAffector*>::ConstIterator it = affectors.begin();

-

-    it += index;

-    ICollisionObjectAffector* affector = (*it);

-    if(affector)

-        return affector;

-    return 0;

+  list<ICollisionObjectAffector*>::ConstIterator it = affectors.begin();

+  

+  it += index;

+  ICollisionObjectAffector* affector = (*it);

+  if(affector)

+    return affector;

+  return 0;

 }

 

 /*bool ICollisionObject::hasCollidedWithAttribute(irr::c8 *attributeName) const

@@ -384,25 +384,25 @@
 

 ICollisionObject::~ICollisionObject()

 {

-    #ifdef IRRBULLET_DEBUG_MODE

-        switch(this->getObjectType())

-        {

-            case ECOT_RIGID_BODY:

-                printf("irrBullet: Deleting rigid body (%i)\n", this->getUniqueID());

-                break;

-            case ECOT_SOFT_BODY:

-                printf("irrBullet: Deleting soft body (%i)\n", this->getUniqueID());

-                break;

-            default:

-                break;

-        }

-    #endif

-    removeAffectors();

-

-    if(object)

-        delete object;

-

-    if(attributes)

-        attributes->drop();

+#ifdef IRRBULLET_DEBUG_MODE

+  switch(this->getObjectType())

+    {

+    case ECOT_RIGID_BODY:

+      printf("irrBullet: Deleting rigid body (%i)\n", this->getUniqueID());

+      break;

+    case ECOT_SOFT_BODY:

+      printf("irrBullet: Deleting soft body (%i)\n", this->getUniqueID());

+      break;

+    default:

+      break;

+    }

+#endif

+  removeAffectors();

+  

+  if(object)

+    delete object;

+  

+  if(attributes)

+    attributes->drop();

 }