dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
4.04k stars 250 forks source link

Using bitflags for InteractionGroups #384

Closed tguichaoua closed 2 years ago

tguichaoua commented 2 years ago

I suggest using bitflags for the fields of InteractionGroups.

Using binary representation is error-prone and hard to read (you have to count the number of digit to know wich group is selected). Also bitflags provides methods to manipulate flags and is easy to convert from/to u32

// With u32
InteractionGroup::new(0b0101, 0b0100);

// With bitflags
InteractionGroup::new(Group::Group2 | Group::Group0, Group::Group2);