Using collision attributes in complex scenes

My personal understanding is this. When there are many types of objects in the scene, collisions need to be detected between each pair, which may consume a lot of performance.
This area of the document is relatively thin. I checked a lot of information and got a rough idea of how to use it, but I personally think it needs to be verified.

In this case we can use collisionMask and collisionGroup together.
collisionGroup:default is -1, collisions can only occur if they are in the same group :yum:
collisionMask: default is -1, it can set which group to collide with
1)If the value of MeshA’s collisionMask is the same as the value of MeshB’s collisionGroup, it can definitely collide. But that’s not what I want to explain
2)The values of MeshA’s collisionGroup and MeshB’s collisionGroup are equal, but MeshA.collisionMask !== MeshB.collisionGroup, can this situation collide? The answer I got so far is false, The priority of collisionMask is greater than collisionGroup :thinking:
3)collisionMask can specify multiple collisionGroups through the mask’s characteristics. Convert to binary bitwise AND,If the same digits are all 1, they can collide, as follows:

  • Group A: 0b0001 (1)
  • Group B: 0b0010 (2)
  • Group C: 0b0100 (4)
  • Group D: 0b1000 (8)
    box.collisionMask = 0b0110 (6), can Can collide with Group B and Group C
    If collisionMask is ob1111 then it can collide with a b c d

If there is no problem with my understanding, I hope my post can help some people

1 Like

I want to modify the second point. The equal here is incorrect. Refer to the third point. The bitwise AND of the same bits is equal to 1.

1 Like