needBroadphaseCollision - need better explanation

Post Reply
Tau
Posts: 25
Joined: Tue May 01, 2012 11:52 am

needBroadphaseCollision - need better explanation

Post by Tau »

Hello, I'm trying to use needBroadphaseCollision to filter collision between moveable objects and player. It works pretty well but there is one problem.

The idea is simple: If an object is still or does not move faster that a threshold ignore collision with players physical body. In this case I use my own code to update player. If the speed of this object breaks that threshold, convert player to rag-doll and let Bullet do the update.

It works well for most objects but i have an object that uses btCompoundShape for its body. When this object is still, (it didn't move for a while) it works.
However when this object starts to move and doesn't break the speed threshold, it gets affected by players physical body (player starts to push this object around).
I added some debug variables and it seems that even when needBroadphaseCollision returns false, there are still contact points generated between player and this object. What am i missing?

Also this appears to happen when the arguments in needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) are:
proxy0 - player, proxy1 - object
It does not happen when:
proxy0 - object, proxy1 - player
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: needBroadphaseCollision - need better explanation

Post by drleviathan »

I briefly looked at a recent version (2017.12.01) of Bullet and didn't see how that would be possible, assuming: (a) setOverlapFilterCallback() has been properly used and (b) all contact points that are actually "solved" pass through the OverlappingPairCache::addOverlappingPair() code bottleneck.

Your "players"... are they using some fancy CharacterController code that happens to generate contact points? I noticed that btKinematicCharacterController will generate contact manifolds to help extract the character from penetration before trying to sweep forward, however as far as I can tell those contact points shouldn't be used by any solver.

My only idea would be to load a "world" in which there are only two objects: the body that uses btCompoundShape and one player. Set a breakpoint on the btManifoldPoint ctor and look at the callstack.
Tau
Posts: 25
Joined: Tue May 01, 2012 11:52 am

Re: needBroadphaseCollision - need better explanation

Post by Tau »

I'm using my own custom character controller as i couldn't use Bullets. My player is a ragdol with btRigidBody bodyparts where linear and angular factors are set to 0 and these limbs are updated based on model animation as long as the player has control over their character. As soon as collision with a fast moving object happens, player loses control over their character, linear an angular factors are set to 1 and i let Bullet handle the ragdol physics.

I wanted to use needBroadphaseCollision to ignore collision with objects that are still or shouldn't affect player. The idea was: as soon as collision between player and object is not ignored, player should lose control over their character and Bullet should take over.
Tau
Posts: 25
Joined: Tue May 01, 2012 11:52 am

Re: needBroadphaseCollision - need better explanation

Post by Tau »

Never mind, solved it by switching from broadphase filter to narrowphase filter. Basically the exact same code but I'm using

mDispatcher::setNearCallback
Post Reply