Motor Physics

Finally I added support for arbitrary convex polygons, now supporting contact ids for managing persistent contacts. This is needed for a feature called warm starting which improves the quality of the solver. Furthermore the complexity of the polygon intersection algorithm was reduced from [(N0 + N1)^2] to [2*N0*N1] (N = number of separation axis to be tested) making it nearly twice as fast. Adding lines and circles is pretty straight-forward and shouldn’t take much time.

Contact point calculation also has been drastically improved. Computation now adds almost no overhead because most of the information needed is already computed during the collision detection phase. After all the simulation is very stable, and scales nicely with the amount of bodies since most algorithms are O(n) or O(log(n)). Chris is meanwhile working on different constraint types while I am enhancing the API for user interaction. We hope to get a new demo finished soon.

‘polygon soup’, click and drag to attract objects to mouse cursor

Data Structures

Besides some minor bug fixes, I included a new HashMap class, which is a replacement to the HashTable class (it’s much faster). The HashMap supports perfect hashing (direct lookup) using dictionaries. Think of it as an associative array with the additional capability of using object instances as keys as well.
The existing HashTable on the other hand is a ‘classic’ hash table using an array and linked overflow for resolving collisions. I leave it in the package for now, because it has one advantage over the HashMap – you can directly traverse the value/key pairs using an iterator without making a copy of the complete data set first.

Actually the HashMap class is so simple that you should considering using a Dictionary directly when speed is crucial, but it’s nice to have a common interface for all structures.