Wednesday, February 25, 2009

2.0.2b1 Released!

Since 2.0.2b0, there have been a good deal of changes to pybox2d:

  • Code structure completely reorganized
  • Doxygen comments converted to docstrings (should be a bit more friendly now, but still a bit C++'ish in places)
  • Lists and tuples may be used anywhere in place of b2Vec2's, and all of the tests have been updated to reflect this
  • Save/load state (pickling support for worlds)
  • Bug fix: Seg faults during DebugDraw/etc callbacks
  • Bug fix: userData reference counting causing leaks
  • Bug fix: getType() didn't work on line joints
  • Bug fix: TestSegment now returns from (-1,0,1) and not a bool
  • b2PolygonDef.setVertices() added, supports either b2Vec2 or list/tuple, so no need to specify. Old setVertices_tuple/b2Vec2() are deprecated.
  • New pretty printing style. It takes up a good deal of space, but it's actually readable.
  • New examples: bezier edges with thin line segments, a simple belt, basic pickling example (might needs some updating)
  • (Optionally compilable) C++ assertion failures turned into Python exceptions
    Additional properties and accessors to make coding easier (see below)
  • Many tests were updated and rewritten to be cleaner
  • Added b2CheckPolygonDef and deprecated the Python ported version. This version adds (optional) additional checks to ensure that your shape is convex and properly sized to not have strange results
  • Added GetVertices() for b2EdgeShapes. Creating one b2ChainDef results in many b2EdgeShapes, so this properly loops through each connected shape and gets the vertices in order
  • Box2D source updated, b2GravityController fixed
  • A fix for not allowing b2Body/Joint/Controller/Shapes as dictionary keys. Don't know how I missed this one. Still won't be picklable unfortunately.
  • Basic iterators have been added: b2World (iterates over bodies), b2Body (iterates over shapes), b2Controller (iterates over bodies), b2PolygonShape (iterates over vertices)
There are several code-breaking features that you might run into:

  • The library is now called Box2D (and not the cumbersome Box2D2)
  • Controllers now follow the factory style (see the buoyancy test for more information)
  • b2Distance updated (see here if this affects you)
  • b2Body.GetShapeList() used to return only first shape, now returns actual list
  • b2World.GetBodyList/Joint() used to return only first body, now returns actual list
  • All occurences of the ugly 'm_' have been removed. This might require some changes in your code, since this applies to all b2Joint.m_* and others, not just testbed stuff.

The following are the additional properties added. Most are just for convenience and make the definition (e.g., b2ShapeDef) symmetric with the output (e.g., b2Shape). Ones with * are changeable; the rest are read-only:
b2Worldgravity*, jointList, bodyList, groundBody, worldAABB, doSleep
b2Shapefilter*, friction*, restitution*, density*
b2Jointtype, userData, body1, body2, collideConnected
b2CircleShape radius, localPosition
b2PolygonShapevertices, coreVertices, normals
b2Body massData*, position*, angle*, linearDamping, angularDamping, allowSleep*, isSleeping, IsRotationFixed, isBullet*, angularVelocity*, linearVelocity*, shapeList

Basic epydoc documentation is now available here. The testbed is no longer included in the installer, so please download it separately here.

Releasing for all these operating systems all by myself is time consuming, confusing, and tough at times. I'm sure I got something wrong, so please go easy on me. :) Do let me know if something doesn't work for you, though.