Updates

July 16, 2007 on 1:21 am | In Actionscript, Physics |

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.

13 Comments »

RSS feed for comments on this post. TrackBack URI

  1. The day I’m able to build something like this is the day I’ll be happy.

    Great work, man.

    Comment by Zeh — July, 16 2007 #

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

    Comment by Nick — July, 16 2007 #

  3. 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.
    -timbot

    Comment by timbot — July, 17 2007 #

  4. @nick, I don’t know yet, we will make a decision when we are close to a release (hopefully soon :-))

    Comment by Michael — July, 17 2007 #

  5. [...] AS3 Physics Previews of Motor Physics Engine by Polygonal Labs July 16th, 2007 — drawk Polygonal labs who has the lion share of cool physics demos with their motor physics engine has posted another excellent physics demo. [...]

    Pingback by [ draw.logic ] AS3 Physics Previews of Motor Physics Engine by Polygonal Labs « — July, 17 2007 #

  6. 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.

    Comment by [draw.logic] — July, 17 2007 #

  7. 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?

    Comment by Oz — July, 18 2007 #

  8. -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.

    Comment by Michael — July, 18 2007 #

  9. 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/

    http://shoughunsecondlife.blogspot.com/

    Comment by Matt Wittingham — October, 20 2007 #

  10. HashMap class is SOOOO much quicker its great!

    Comment by christmas — November, 3 2007 #

  11. 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

    Comment by foca — November, 20 2007 #

  12. Wow! Cool work ;) I play 10 min in this flash :)

    Comment by Simon — April, 22 2008 #

  13. very beautiful work !

    Comment by lol — May, 25 2008 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Proudly powered by WordPress Theme based upon Pool theme by Borja Fernandez.
Entries and comments feeds.