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.

14 thoughts on “Updates”

  1. Motor is really looking more and more awesome by the day. Have you decided under what kind of license it will be available?

  2. Fantastic! I must admit I’m excited for the coming release of this engine.
    I’ve used that 2-dictionary Hash Map previously for Locators in my code, it works quite nicely. Good point about the iteration of the classic HashMap.

  3. Another great post, I would love to see some 3d flash and motor physics demos. Do you plan on alpha anytime soon? I am hoping it is open source but that is up to you, I think you get more leg and kickback from something like that for as3 libraries. Maybe a book using it and you will be able to watch it grow and change beyond your initial ideas. With 3d games and demos people are starting to integrate physics engines, the sooner that it gets out the earlier you can be the engine of choice in AS3.

  4. Great job as always mike

    some technical questions :)

    What kind of broad-phase collision detection are you doing?

    Could you go into more detail about warm starting?

    how many collision iterations are you running in that demo?

  5. -all still brute-force ;-) but I’m working on different strategies (quad-tree, rdc, sweep&prune, spatial hashing)

    -‘warm-starting’ applies the impulse (which is accumulated) from the previous time step, so it can use an old solution as an initial guess. so the solver is able to spread the cost over several time steps, solving the system of equations as the simulation evolves, until a global solution is found (when all bodies in equilibrium). it’s all explained in GDC 06/07 presentation by Erin Catto (gphysics.com)

    -I’m doing 30 iterations per body. since there are not very expensive, they can easily be increased to 100 iterations if necessary.

  6. OK, for background, Ted just dropped what he was doing (a week before this little “MAX” thing which he is entirely responsible for, and somewhat busy with…) and helped me straighten out a situation. Something that would have potentially taken a couple of days to resolve, he sorted out for me in 10 minutes.

    I just have to acknowledge it, because there have been several times when Ted has gone out of his way to do stuff like this, for both me and others. He deserves a big m/


  7. it`s so beautifull
    how di you change the rotation point to the hittesting point?
    I`m making a phisical engine for a game and I really need to know

  8. Excellent!!!!Please tell me how can i make a thing like this my own… Atleast how can i start.I know AS3 but i am not able to start it.
    this is the one of the most b’ful thing i have ever seen which is made in Flash AS3.

Comments are closed.