GDC 2006 Download

You can download my GDC tutorial here:

GCD 2006 Slides and Code

27 Responses to “GDC 2006 Download”

  1. Billy Zelsnack Says:

    Awesome man. This is an excellent starting point for people. An instant classic. I’m definitely adding this to the short list of places to point people looking to do their own physics.

  2. Erwin Coumans Says:

    Very useful presentation. If you want to check out a 3D implementation, you can refer to Bullet Physics Engine. It uses the described iterative impulse method, and from today is includes the clamping on the accumulated impulse.

    Keep up the good work!
    Erwin
    http://bullet.sourceforge.net

  3. Richard Says:

    This is fantastic. I’m definitely want to role some of these ideas into my own impulse engine. Thanks!

  4. Billy Zelsnack Says:

    I need to read the bit about ‘accumulated impulse’ a bit better. I glanced at your code last night and was amazed to find that you are not only not randomizing your iteration order, but are solving a pairs contacts together. Madness! haha. You may have inspired me to put together a bit of a demo using both your techniques and my techniques. If your stuff is rock solid stable and my stuff is rock solid stable then with their powers combined they will be stable^2 of course!

  5. Erin Catto Says:

    Thanks for the friendly feedback everyone!

    Billy: yes, I don’t play with the constraint order. Doing so thrashes the cache too much and my experiments didn’t show much benefit compared to the cache hit. Aside from the demo, keep in mind a more optimized version where all the constraint data is packed together for streaming.

  6. Binh Nguyen Says:

    Nice article!
    It’s a kind of amazing that you can do it without forming a LCP.

  7. Dirk Says:

    He solves a LCP for my understanding. What he basically does is solving blockwise for

    J *W * JT * impulse = -J * v

    What is the same like the PGS method, with the exception that the external forces are integrated in beforehand. Note that J * W * JT equals the collision matrix K (s. Mirtich for example). There was a discussion recently on the Bullet forum regarding the equivalence between sequential impulses and the Gauss-Seidel method…

  8. Musha Says:

    Your physics simulator is awesome!
    But…
    How can they be added more shapes to the simulator? (circles, triangles, others)
    Could you discuss about this theme please?

    Thanks in advance!

  9. Administrator Says:

    I plan to add more shapes GDC next year. However, I would encourage you to give it a shot. It’s the best way to learn.

  10. Musha Says:

    Thanks!

    My knowledge on physics is limited :(
    I want to learn it but I miss the base

    I will try

  11. Kevin Glass Says:

    This really is fantastic stuff. I’ve just ported it to Java so I can hopefully use it in my next game. I’m going to attempt to add more shapes, starting with circles - hopefully this isn’t going to screw my mind up too much :)

    The port can be found at http://www.cokeandcode.com/phys2d. I’ll be releasing my version of the source as soon as I’m happy it’s right :)

    Thanks for the great presentation!

    Kev

  12. GBGames Says:

    The notice at the top of the source files says:
    /*
    * Copyright (c) 2006 Erin Catto http://www.gphysics.com
    *
    * Permission to use, copy, modify, distribute and sell this software
    * and its documentation for any purpose is hereby granted without fee,
    * provided that the above copyright notice appear in all copies.
    * Erin Catto makes no representations about the suitability
    * of this software for any purpose.
    * It is provided “as is” without express or implied warranty.
    */

    That means that no matter how the source gets relicensed, you just need that one line, right? If I license it under my own proprietary license or under the GPL, so long as the copyright notice is there, it’s fine, right?

  13. GBGames Says:

    Does the code compile cleanly in VC++ (which is what I presume you used)? I get an error in g++:

    ArbIter arb = arbiters.find(newArb);
    (*arb).Update(newArb.contacts, newArb.numContacts);

    world.cpp: In member function ‘void World::BroadPhase()’:
    world.cpp:112: error: passing ‘const Arbiter’ as ‘this’ argument of ‘void Arbiter::Update(Contact*, int)’ discards qualifiers

    Since arbiters is a set, and sets have immutable members, it looks like Update needs to be made const, but obviously Update is doing things that const functions can’t do, right?

    Has this code changed since the initial tutorial? Has anyone else encountered this problem?

  14. raigan Says:

    i got it to compile iusing codeblocks with the MSVC++ toolkit 2003 compiler.

    i initially tried using gcc (with codeblocks) and got:
    Arbiter.h:24: error: `struct FeaturePair::::Edges’ invalid; an anonymous union can only haveon-static data members

    switching compilers “fixed” that.. however, i’m still getting used to codeblocks so it might be that i haven’t got things setup properly.

  15. GBGames Says:

    raigan: Yeah, I encountered that problem as well. Unions must be named in C++, which I guess some compilers allow.

  16. raigan Says:

    ah, cool — i figured using the MSVC compiler was probably better anyway since the original was a vcproj..

  17. Erin Catto Says:

    Yes, just include the copyright line in any redistribution.

    I’ve only built Box2D with MSVC++ 2003. However, both the errors above seem like a compiler problems:
    - ArbIter is a non-const iterator.
    - FeaturePair has no static data members.

  18. GBGames Says:

    Actually, I did some research on the set problem. Neither g++ nor MSVC++ are wrong when it comes to how each implements sets.

    Effective STL by Scott Meyers says that sets can make use of immutable keys. Technically, only the parts relevant to ordering should be immutable, but an implementation can make the entire key immutable without violating the standard.

    The safe and portable way to modify entries in a set:

    ArbIter arb = arbiters.begin();
    while (arb != arbiters.end())
    {
    // Erase key from set, modify it, then add it again.
    Arbiter newArb((*arb).body1, (*arb).body2);
    newArb.PreStep(inv_dt);
    arbiters.erase(arb++);
    arbiters.insert(newArb);
    }

    You basically create a copy of the key, modify it, then erase the original from the set and insert the new, modified version.

  19. Cade Says:

    Hey Erin, I ported your code to VB.NET :)
    http://www.mdxinfo.com/resources/resources.rigidBodyPhysics/rigidBodyPhysics.rar

  20. Erin Catto Says:

    Thanks GBGames, I’ll fix that in the next revision.

  21. GBGames Says:

    I know that the slides talk about removing bouncy simulations, but is it possible to tweak some parameters for the bodies to get the velocity to remain the same when it bounces off? If I turn off gravity after a body starts to fall, I was hoping to see boxes bounce up into the air at the same speed as it hit, but there seems to be some dampening. Most likely it is just a problem with not understanding the calculations being performed, but maybe the calculations are incompatible with what I am trying to do?

  22. Erin Catto Says:

    Box2D uses inelastic collisions, so there should be no bounce. The penetration recovery does add some bounce. Here’s a version that does not add bounce:
    http://www.gphysics.com/files/Box2D.zip

    It is possible to simulate restitution by adding a target relative velocity to the velocity constraint.

  23. Nick Terry Says:

    The power point slides don’t make it clear why penalty force physics simulation is undesirable. From my naive perspective, the accumulated impulses makes the impulses act more like penalty forces.

  24. Administrator Says:

    Penalty forces say “push here and push hard,” without regard to the resulting motion.

    Accumulated impulses are computed implicitly to satisfy motion requirements.

    In other words:

    Penalty method
    force -> motion

    Accumulated impulse method
    motion -> impulses

    Now the accumulated impulse method uses Baumgarte stabilization to remove position error and this seems like a penalty method. However, it still operates as a motion requirement that leads to an impulse.

  25. Clay Says:

    Hi, nice work! I want to add some 2D physics to my game engine and this looks like a nice start. I have a few questions about the code though…

    1) Why use STL set? Why not a linked list?

    2) Why the weird pointer arithmatic in Arbiter.update() ? Surely

    Contact* cNew = newContacts + i;

    can be re-written as

    Contact* cNew = newContacts[i]; ?

    I’m a little rusty on C++ :) I hope you don’t mind me posting questions about the source to your blog?

    Thanks
    ~ Clay

  26. Clay Says:

    I’ve converted this to the D programming language

    http://www.dsource.org/projects/arcgames/browser/trunk/physics/demo.zip

    /me waits patiently for next years version which I hope will include polygons :)

  27. nornagon Says:

    I made a quick fix that seems to compile under g++. The Makefile is horribly naïve, so if it doesn’t compile, you know why ;P

    http://2-2-dihexanol.net/~nornagon/box2d.tar.bz2

Leave a Reply