In the btBroadphaseProxy.h file we have the collisiongroups defined:
Code: Select all
enum CollisionFilterGroups
{
DefaultFilter = 1,
StaticFilter = 2,
KinematicFilter = 4,
DebrisFilter = 8,
SensorTrigger = 16,
CharacterFilter = 32,
AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
};
My intention now is to implement custom collision filtering in order to bypass this limit in order to allow a much higher number of collisiongroups.
On the bullet wiki i was able to read that we can create a custom Broadphase filter callback for this purpose:
Code: Select all
//Global Filter Callback which is used by the physicsworld in order to implement custom collision filtering
struct PhysicsWorldFilterCallback : public btOverlapFilterCallback
{
// return true when pairs need collision
virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) const
{
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
//<<<<<<<<<<< add some additional logic here that modified 'collides' >>>>>>>>>>
return collides;
}
};
Both btBroadphaseProxy instances (proxy0 and proxy1) seem to provide limited information about the actual collisionobjects which are being tested. (Besides the collisiongroups and collisinfiltermask which we want to extend in the first place.)
Is it possible to somehow inject additional data into this callback which is stored in the proxy instances? (Like pointers to some object which hold additional filtering information, additional bitmasks, etc...)
Or is it easily possible to extend the bitmask from short int (16 bit) to an integer (32 bit) or long (64 bit)?
How is this custom callback intended to be used?