InteractionGroups are another way of filtering interactions.
InteractionGroups form tree structures which are checked along side InteractionFilters
when deciding if two Shapes should interact.
InteractionGroups are assigned to any Interactor (not just Shapes), and two Shapes will
interact only if the most recent common ancestor in the InteractionGroup tree permits it.
For the purposes of the search, if any Interactor has no InteractionGroup assigned, we
search up the Compound tree first.
_Group1 / | / Group2 Group3 / | \ | Group1 Body1 / Cmp1 | / \ Group3
/ \ / / \ | ==> Shp1 Group2 |
---|
Shp1 Shp2 Body2 Cmp2 / \ Shp4
| | Shp2 Shp3
Shp3 Body3
|
Shp4
If we look at which InteractionGroup is used for which Shape following this rule, then the left graph can be transformed into an InteractionGroup tree on the right and we get that the MRCA (Most recent common ancestors) are such that:
MRCA(Shp1, Shp3) == Group1; MRCA(Shp2, Shp3) == Group2; MRCA(Shp4, # ) == null;If we were to set up the groups such that
Group1.ignore = false
and
Group2.ignore = true
; then shapes 1 and 3 would not be permitted to
interact, whilst shapes 2 and 3 would be permitted.
As the MRCA for shape 4 with any other is null, then the value of Group3's ignore field is irrelevant, but the existance of Group3 is not as it serves to otherwise prevent Shape 4 from being permitted to interact with shapes 2 and 3.
InteractionGroup's can be fairly expressive, but they are strictly less powerful than InteractionFilters. InteractionGroup's have their place however as there is no limit to the number of Groups you can use.
Constructor
Variables
read onlygroups:InteractionGroupList
Immutable set of children of Interaction groups.
You cannot assign or remove children in this manner, you must do it via setting
the childs parent group to this/null.
This list is immutable.
read onlyinteractors:InteractorList
Set of active interactors using this group.
Active interactors meaning those that are part of a Space.
This list is immutable.