Testing and failing Object duplication
3 posters
Testing and failing Object duplication
Hello everybody.
I´m running some tests with tutorial06_1 in the new version. I´m using sio2ObjectDuplicate this way
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:
This is exactly in btCollisionObject::getBroadphaseHandle()
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
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
Re: Testing and failing Object duplication
Browse on this forum I post an example on how to use sio2ObjectDuplicate...
Re: Testing and failing Object duplication
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
Best,
Matt
Re: Testing and failing Object duplication
I´ve found the problem. It´s a bug in sio2PhysicRemoveObject:
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
At least this works for me.
- 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.
Similar topics
» Problems solved with object duplication
» md2 duplication
» Culling failing on duplicated objects
» Ray Testing
» Objects failing to collide at high velocities, tunneling through floor etc.
» md2 duplication
» Culling failing on duplicated objects
» Ray Testing
» Objects failing to collide at high velocities, tunneling through floor etc.
Permissions in this forum:
You cannot reply to topics in this forum