Creating multiple btPairCatchingGhostObjects

Anis
Posts: 2
Joined: Tue May 08, 2012 8:32 pm

Creating multiple btPairCatchingGhostObjects

Post by Anis »

Hi all,

I have a bug that i just can't fix , i would really appreciate your help.

I'm using bullet for a FPS ( using Ogre), this problem occurs on windows, linux, with release 2.80 && 2.79 of bullet.

I'm creating bullets like this:

Code: Select all

btPairCachingGhostObject * tirGhostObject =new btPairCachingGhostObject();
tirGhostObject->setWorldTransform(startTransform);
btScalar bulletDimension = 0.2f;

btConvexShape * capsule =new btBoxShape(btVector3(bulletDimension,bulletDimension,bulletDimension));
mPhysics->addCollisionShape(capsule);
tirGhostObject->setCollisionShape(capsule);
					tirGhostObject->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);//|btCollisionObject::CF_NO_CONTACT_RESPONSE);
mPhysics->addCollisionObject(tirGhostObject, btBroadphaseProxy::SensorTrigger,//&btBroadphaseProxy::DefaultFilter,
											btBroadphaseProxy::CharacterFilter);

Vector3 orientation(mShootNode->getOrientation().zAxis());
mPhysics->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());


// This one ==========>
mPhysics->getDynamicsWorld()->addCollisionObject(tirGhostObject, btBroadphaseProxy::SensorTrigger,btBroadphaseProxy::CharacterFilter);
<=====================

mPhysics->getDynamicsWorld()->addAction(newTir->getPhysics());
I detect collision with the characters by using the flags spécified up there!

My program randomly crashes (segmentation fault),when i add collision object to my discrete dynamic world (not at the moment when i add them, but after). Sometimes it happens after 10 bullets, sometimes after 3.

If i dont add them to the world (by not adding the line specified , there is no problems in my application

I've tried everything i know, does someone have an idea?
Anis
Posts: 2
Joined: Tue May 08, 2012 8:32 pm

Re: Creating multiple btPairCatchingGhostObjects

Post by Anis »

(Sorry for the double post, but maybe this data could help)

In fact I just realized that i have the same problem with the characters (that i create approximatly the same way that in the character demo), it only has crash problems when i addacollision object from an other thread !
if i shoot 100 times or a create 100 characters the application works well, but if an other thread does it, crashes !

Is there any know problem about multi-threading, (an sfml thread, and a Ogre thread) in bullet?