How do short int based masks work in c++ (for example ones in Bullet)?
CollisionFilterGroups {
DefaultFilter = 1,
StaticFilter = 2,
KinematicFilter = 4,
DebrisFilter = 8,
SensorTrigger = 16,
CharacterFilter = 32,
AllFilter = -1
}
And see that all values are degrees of 2 and I know that:
short is signed integer that takes 2 bytes to store and is from −32,768 to +32,767.
But how to create my own groups: how to calculate mask intersections?
For example how to create in addition to CollisionFilterGroups something like:
MyCollisionFilterGroups {
Cubes= ?,
Boxes= ?,
Spheres= ?
}
Where
Your question is unclear, but I think you're looking to set category and mask bits for the objects in your simulation:
MyCollisionFilterGroups {
Plane= 64,
Box= 128,
Sphere= 256
}
Plane, category bits = Plane, Mask = 0
Box, category bits = Box, mask = Box + Sphere (or Box | Sphere)
Sphere, category bits = Sphere, mask = Box
In a nutshell, create power of two for each filter group, set the category mask for each object to the group enum, and set its mask to the enum of the object types you want it to collide with (or 0 to collide with nothing).