FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Testing and failing Object duplication

3 posters

Go down

Testing and failing Object duplication Empty Testing and failing Object duplication

Post  iphoniac Thu Dec 11, 2008 5:57 am

Hello everybody.

I´m running some tests with tutorial06_1 in the new version. I´m using sio2ObjectDuplicate this way

Code:

   SIO2object *_Object1 = ( SIO2object * )sio2ResourceGet( sio2->_SIO2resource, SIO2_OBJECT, ObjectName);
   SIO2object *_Object = sio2ObjectDuplicate(_Object1, dupname);
   _Object->pos->x = 0.0;
   _Object->pos->y = 0.0;
   _Object->pos->z = 0.0;   
   _Object->type = 1;

   if( sio2ObjectMapBuffer( _Object1 ) )
   {     
      
      _Object->buf = _Object1->buf;
      
      sio2PhysicAddRigidBody( sio2->_SIO2physic,
                            _Object );
      
      _Object->buf = NULL;
      
      sio2ObjectUnmapBuffer( _Object1 );
   }

   _Object->_btRigidBody->setActivationState(ACTIVE_TAG);
   sio2ObjectBindMatrix( _Object );


The first thing I noticed was that after object duplication, the type of the new object is not set so I had to set it manually to 1 as you can see If I want my object to appear on screen.

After that when I try to erase that object, I get an EXC_BAD_ACCESS error. This is the stack:

Code:

Thread 0 Crashed:
0  tutorial06_1                     0x00164bd5 btCollisionObject::getBroadphaseHandle() + 9 (btCollisionObject.h:249)
1  tutorial06_1                     0x00191771 btCollisionWorld::removeCollisionObject(btCollisionObject*) + 17 (btCollisionWorld.cpp:202)
2  tutorial06_1                     0x00232b76 btSoftRigidDynamicsWorld::removeSoftBody(btSoftBody*) + 48 (btSoftRigidDynamicsWorld.cpp:113)
3  tutorial06_1                     0x001633b8 sio2PhysicRemoveObject(SIO2physic*, SIO2object*) + 326

This is exactly in btCollisionObject::getBroadphaseHandle()
Code:

   SIMD_FORCE_INLINE btBroadphaseProxy*   getBroadphaseHandle()
   {
      return m_broadphaseHandle;
   }

In execution time I´ve proved that m_broadphaseHandle is not null (at least at creation time).

Did I missed something in the object duplication code? Is this a bug? a feature?

Cheers,
Iphoniac

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Testing and failing Object duplication Empty Re: Testing and failing Object duplication

Post  sio2interactive Thu Dec 11, 2008 6:01 am

Browse on this forum I post an example on how to use sio2ObjectDuplicate...
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

Testing and failing Object duplication Empty Re: Testing and failing Object duplication

Post  iphoniac Thu Dec 11, 2008 6:21 am

You mean This?

I´ve used the same scheme...

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Testing and failing Object duplication Empty Re: Testing and failing Object duplication

Post  iphoniac Thu Dec 11, 2008 12:29 pm

Somebody duplicating objects can give me a clue?

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Testing and failing Object duplication Empty Re: Testing and failing Object duplication

Post  matt Thu Dec 11, 2008 1:20 pm

You're probably trying to remove the object in the collision callback which leads to problems if the object gets notified for another collision later (obj1 hits obj2 and obj2 hits obj1) in the loop. Better remember the object and remove it after the physics loop.

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Testing and failing Object duplication Empty Re: Testing and failing Object duplication

Post  iphoniac Fri Dec 12, 2008 4:10 am

I´ve found the problem. It´s a bug in sio2PhysicRemoveObject:
Code:

      if( _btRigidBody == _SIO2object->_btRigidBody )
      {
         delete _btRigidBody->getCollisionShape();
         delete _btRigidBody->getMotionState();
         
         _SIO2physic->_btSoftRigidDynamicsWorld->removeRigidBody( _btRigidBody );
         _SIO2physic->_btSoftRigidDynamicsWorld->removeCollisionObject( _btCollisionObject );
         
         delete _btRigidBody;
         _btCollisionObject = _btRigidBody = NULL;
         
         break;
      }
      
      else if( _btSoftBody == _SIO2object->_btSoftBody )
      {
         _SIO2physic->_btSoftRigidDynamicsWorld->removeSoftBody( _btSoftBody );
         _SIO2physic->_btSoftRigidDynamicsWorld->removeCollisionObject( _btCollisionObject );
         
         delete _btSoftBody;
         _btCollisionObject = _btSoftBody = NULL;
         
         break;
      }

      }

If the object doesn´t have _btSoftBody, both _btSoftBody and _SIO2object->_btSoftBody are NULL so the condition is true and code fails in removeSoftBody( _btSoftBody );

THe object can have rigid body or soft body, so the right code should be this
Code:

      if( _btRigidBody && (_btRigidBody == _SIO2object->_btRigidBody ))
      {
         delete _btRigidBody->getCollisionShape();
         delete _btRigidBody->getMotionState();
         
         _SIO2physic->_btSoftRigidDynamicsWorld->removeRigidBody( _btRigidBody );
         _SIO2physic->_btSoftRigidDynamicsWorld->removeCollisionObject( _btCollisionObject );
         
         delete _btRigidBody;
         _btCollisionObject = _btRigidBody = NULL;
         
         break;
      }
      else if(_btSoftBody && ( _btSoftBody == _SIO2object->_btSoftBody ))
      {
         _SIO2physic->_btSoftRigidDynamicsWorld->removeSoftBody( _btSoftBody );
         _SIO2physic->_btSoftRigidDynamicsWorld->removeCollisionObject( _btCollisionObject );
         
         delete _btSoftBody;
         _btCollisionObject = _btSoftBody = NULL;
         
         break;
      }

At least this works for me.

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Testing and failing Object duplication Empty Re: Testing and failing Object duplication

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

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