Open Genbox opened 7 years ago
I've created a generic doubly linked list that is circular to avoid branches in code. The enumerator simply iterates the list using the count to void infinite circulation.
It is 2x as slow when iterating, but much faster when removing nodes. We allocate 2x the memory for the linked list as well since it needs a container to hold the references.
Note that I tested with a version that is non-generic and got identical results.
To simplify the code, Velcro Physics uses simple lists instead of the linked lists Box2D uses. However, operations such as Contains() and Remove() on List are O(n) operations, which slows down the engine considerably when working with many fixtures on a body.