Collision filtering problem

Started by
3 comments, last by Krohm 11 years, 2 months ago
In my game using bullet physics I have a btGhostObject, a bunch of btRigidBodys and a static btCollisionObject. The btCollisionObject should collide with the btRigidBodys all the time and the btGhostObject should collide with every object except for one of the btRigidBodys. Right now I have my code set up like this:
//add the ghostobject which should collide with everything except rigbody1
dynamicsWorld->addCollisionObject(ghostObj, btBroadphaseProxy::KinematicFilter, btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::KinematicFilter);
//add the btRigidBody which should collide with other btRigidBodys
dynamicsWorld->addRigidBody(rigbody1, btBroadphaseProxy::KinematicFilter, btBroadphaseProxy::DefaultFilter);
//add the btRigidBody which should collide with everything
dynamicsWorld->addRigidBody(rigbody);
//add the btCollisionObject which should collide with everything
dynamicsWorld->addRigidBody(collObj);
As far as I know this should work but it doesn't, ghostObj is still detecting collisions with rigbody1. As far as I know I'm using the mask system properly, perhaps I'm not using bitwise operations correctly?
Advertisement
Anyone?

anyways I figured out something that I think might be wrong with bullet and was wondering if I was wrong:

when I change the mask for ghostObj to btBroadphaseProxy::DefaultFilter|btBroadphaseProxy::StaticFilter it still doesn't work and seems to be detecting collision with something that doesn't exist because collObj is he only thing marked as static and they surely aren't touching.
Ok, let me take a look at the masks...
Kinematic=4
All=-1
Default=1

[font='courier new', courier, monospace]ghostObj group=0000 0000 0000 0100 against=1111 1111 1111 10111[/font]
[font='courier new', courier, monospace]rigidBody1 group=0000 0000 0000 0100 against=0000 0000 0000 00001[/font]

(edit: whoops I messed up the bits)
They should not be colliding. Take a look at manifold pointers

Notes.
  • Don't use [font='courier new', courier, monospace]btCollisionObject [/font]and [font='courier new', courier, monospace]btRigidBody[/font] in the same simulation. It's not forbidden but I don't think it's good practice. Use static rigidbodies instead.
  • When needing to filter against a specific object, I suggest to NOT use a specific collision group. It would make everything run short of bits quite fast. Either extend [font='courier new', courier, monospace]btGhostObject [/font]to ignore a specific collision object, or just let it work the same way and ignore its manifolds.

when I change the mask for ghostObj to btBroadphaseProxy::DefaultFilter|btBroadphaseProxy::StaticFilter it still doesn't work and seems to be detecting collision with something that doesn't exist because collObj is he only thing marked as static and they surely aren't touching

Not sure what you mean there. A collision manifold will get reported as long as their AABBs overlap in broadphase tests.

Previously "Krohm"

Not sure what you mean there. A collision manifold will get reported as long as their AABBs overlap in broadphase tests.

Oh I see. In that case I must be detecting collisions wrong. I had assumed that ghostObj->getNumOverlappingObjects() would return the number of objects that the ghost object was actually colliding with, I had no idea that it only took into account the AABB. Does anyone know how to actually check if there is an actual collision using a ghost object?

Problem is they shouldn't be reported anyway I think. They're in different groups. Have you checked manifold pointers?

Previously "Krohm"

This topic is closed to new replies.

Advertisement