Skip to content

Collision Filtering

Adnan Munawar edited this page May 17, 2021 · 4 revisions

AMBF allows multi-level collision filtering that includes disabling the collision for all the objects in a single ADF file to finer control between objects within a single ADF or even multiple ADF files.

For a specific ADF file, A.yaml, there is a global boolean flag called ignore inter-collision. If set to true, no objects described in the A.yaml file would collide with each other. This flag has no effect on the objects from another ADF file from colliding with objects in A.yaml.

For finer collision filtering, each object (rigid body, soft body etc) has an optional array field called collision groups. This array can be allocated with positive integer indices. All the objects in the scene (defined using a single or multiple ADF files) that have a common collision group index will collide, and the ones that do not have a common collision group index will not collide with each other. If the collision groups array for an object is empty, it means it has no collision filtering is defined and will collide with all the objects in the scene (and with objects in the scene defined via the same ADF file if ignore inter-collision: False).

Of course, the collision groups can be set to achieve more advanced collision filtering, here is an example. (NOTE: all the rest of object attributes have been omitted for clarity.)

body1:
  collision groups: [0]

body2:
  collision groups: [0, 1]

body3:
  collision groups: [1, 2]

body4:
  collision groups: [2]

In the minimal example above, the following collision filtering ensues:

COLLISION ENABLED:


body1 with body2 (both contain collision group `0`)
body2 and body3 (both contain collision group `1`)
body3 and body4 (body contain collision group `2`)

COLLISION NOT ENABLED:

body1 with body3 (no common collision group)
body1 with body4 (no common collision group)
body2 with body4 (no common collision group) 

In the example above, the four bodies can be defined in a single ADF or multiple ADF files.

You can set both the ignore inter-collision flag and collision groups via the ambf_addon or manually edit the ADF file(s).