I'm currently using btPairCachingGhostObject to track spherical regions in a world in order to apply a force field to nearby objects. In my current design, the ghost objects are paired with rigid body spheres that do collied with each other. The rigid body spheres have a smaller radius that the ghost spheres that track them.
Ideally, each ghost sphere would only collide with other rigid by spheres excluding the one it is tracking. If there are N spheres and N ghosts (1 per sphere), each ghost would only be able to collide with N-1 rigid spheres. I can have the ghost object ignore each other with collision flags, but having each ghost object ignore 1 other object isn't feasible with flags, so I was wondering if there's an alternate mechanism I can use to implement this behavior.
GhostObject and ignoring collisions with a single object
-
moniker
- Posts: 6
- Joined: Mon Oct 18, 2010 8:02 pm
-
karwosts
- Posts: 6
- Joined: Thu Oct 14, 2010 2:00 am
Re: GhostObject and ignoring collisions with a single object
Well when a collision is triggered you can get a callback containing the two objects that are colliding.
Can you just do your ignoring outside of bullet? IE if each object knows what it isn't supposed to be colliding with, when the collision callback fires, you check the unit that it is colliding against, and then throw out the collision if you don't want it?
http://www.bulletphysics.org/mediawiki- ... d_Triggers
Also you could use here btCollisionObject::getUserPointer()/setUserPointer() functions to store a pointer to your own object/entity data. These aren't used by bullet, but it allows you to store a pointer to your own data that can be retrieved when you see a collision object in a callback.
I don't know all the right methods to do everything I've described, but this should get you started with an idea what to look at.
Can you just do your ignoring outside of bullet? IE if each object knows what it isn't supposed to be colliding with, when the collision callback fires, you check the unit that it is colliding against, and then throw out the collision if you don't want it?
http://www.bulletphysics.org/mediawiki- ... d_Triggers
Also you could use here btCollisionObject::getUserPointer()/setUserPointer() functions to store a pointer to your own object/entity data. These aren't used by bullet, but it allows you to store a pointer to your own data that can be retrieved when you see a collision object in a callback.
I don't know all the right methods to do everything I've described, but this should get you started with an idea what to look at.