Collisions With Multiple Rays

Please don't post Bullet support questions here, use the above forums instead.
ayrton04
Posts: 2
Joined: Fri Oct 07, 2011 11:22 am

Collisions With Multiple Rays

Post by ayrton04 »

Hello,

I am using Bullet to carry out about approximately 650 ray collision tests against many (up to 20 or so) meshes, each of which has perhaps 500 faces, as fast as possible (and repeatedly). The collision data needs to be reasonably accurate.

I've noticed that when I have only a single mesh in the scene, the collision testing is very fast, but when more meshes are added to the scene, performance drops. This is, of course, expected, but I was hoping that using filter masks and groups would solve the problem, as I could weed out collisions against meshes that aren't in the field of view. The masks and groups correctly stop collisions from occurring, but don't seem to help performance. Only removing objects from the collision world seems to have any effect on performance. Does this seem correct?

Also, I was hoping someone could give me some tips as to how to make my use of the engine more efficient. I currently do something like this:

Initialization:

Code: Select all

m_pCollisionConfiguration = new btDefaultCollisionConfiguration();

m_pDispatcher =  new btCollisionDispatcher(m_pCollisionConfiguration);

m_pBroadphase = new btDbvtBroadphase();
Then, for each mesh:

Code: Select all

m_pCollisionWorld->addCollisionObject(itModelIterator->second->m_pModelInUse->GetCollisionObject());
Then, for each ray start and end point:

Code: Select all

btCollisionWorld::ClosestRayResultCallback hCallback(hStartPt, hEndPt);

m_pCollisionWorld->rayTest(hStartPt, hEndPt, hCallback);
ayrton04
Posts: 2
Joined: Fri Oct 07, 2011 11:22 am

Re: Collisions With Multiple Rays

Post by ayrton04 »

Hmm...I suspect that nobody knows the answer to this, and that's probably because I made an unrelated coding error that was causing me to carry out my collision test once for every model in my scene. Once I removed it, it went much, much faster. :oops:

Thanks anyway!