Determining near-phase collisions in callback

Hieran_Del8
Posts: 11
Joined: Mon Nov 12, 2012 3:20 pm

Determining near-phase collisions in callback

Post by Hieran_Del8 »

I need a filter for determining particular game objects intersecting, and I think supplying a near-phase callback by:

Code: Select all

mDispatcher->setNearCallback(MyNearCallback);
is the answer. It's to filter out friendly fire and convert collisions of projectiles/ships/planets into damage/explosions/whatever. I'm already using masks for the basic collision filtering of objects (like facilities don't collide with the planets they're on, etc.).

In composing "MyNearCallback", though, I'm not entirely sure how to determine if a near-phase collision occurred between the objects. Would I use the collision pair's algorithm to get the array of all contact manifolds? I.E.:

Code: Select all

collisionPair.m_algorithm->getAllContactManifolds(manifoldArray);
And then once I have that, is it a manner of checking the size of the array, or the number of contact points of an individual manifold?

The key here is I don't want the simulation to affect the objects in the world if particular game conditions are satisfied.

Any pointers appreciated!
kalesony
Posts: 33
Joined: Tue Sep 25, 2012 12:16 pm
Location: Poland

Re: Determining near-phase collisions in callback

Post by kalesony »

Well, I cannot say I am a Bullet guru but you seem to have taken the wrong way of achieving your goals. I believe you should rather:
1. filter in broadphase-callback (so that the undesired collision pairs are not generated at all); not sure how much one can gain that way but near-callback is called for all the generated pairs
2. processing of the actual collisions can be easily done by simply iterating over all the contact manifolds; if any contact point within a certain manifold has negative distance -> collision

And now the links:
Ad 1. http://www.bulletphysics.com/ftp/pub/te ... Manual.pdf [page 22]
Ad 2. http://www.bulletphysics.org/mediawiki- ... d_Triggers