sio2PhysicRemoveObject bug fix

View previous topic View next topic Go down

sio2PhysicRemoveObject bug fix

Post  sw on Sun Feb 01, 2009 6:14 am

Code:


void sio2PhysicRemoveObject( SIO2physic *_SIO2physic,
                      SIO2object *_SIO2object )
{
   int i = 0;

   if( !_SIO2object->_btRigidBody && !_SIO2object->_btSoftBody )
   { return; }

   while( i != _SIO2physic->_btSoftRigidDynamicsWorld->getNumCollisionObjects() )
   {
      btCollisionObject *_btCollisionObject = _SIO2physic->_btSoftRigidDynamicsWorld->getCollisionObjectArray()[ i ];
      
      btRigidBody *_btRigidBody = btRigidBody::upcast( _btCollisionObject );
      
      btSoftBody *_btSoftBody  = btSoftBody::upcast( _btCollisionObject );
      
      
      if( _btRigidBody == _SIO2object->_btRigidBody  && _btRigidBody )      ///<<<<<< fixed
      {
         delete _btRigidBody->getCollisionShape();
         
         delete _btRigidBody->getMotionState();
         
         _SIO2physic->_btSoftRigidDynamicsWorld->removeRigidBody( _btRigidBody );
         _SIO2physic->_btSoftRigidDynamicsWorld->removeCollisionObject( _btCollisionObject );
         
         delete _btRigidBody;

         _SIO2object->_btRigidBody = NULL;
         
         break;
      }
      
      else if( _btSoftBody == _SIO2object->_btSoftBody && _btSoftBody)  ///<<<<<< fixed
      {
         _SIO2physic->_btSoftRigidDynamicsWorld->removeSoftBody( _btSoftBody );
         _SIO2physic->_btSoftRigidDynamicsWorld->removeCollisionObject( _btCollisionObject );
         
         delete _btSoftBody;

         _SIO2object->_btSoftBody = NULL;
         
         break;
      }
      
      ++i;
   }
}


avatar
sw

Posts : 73
Join date : 2008-10-12

View user profile

Back to top Go down

Re: sio2PhysicRemoveObject bug fix

Post  sio2interactive on Sun Feb 01, 2009 3:52 pm

You are absolutely right!!!

Tks alot!!!

Cheers,
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 37
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum