Monday, December 28, 2009

End of the year status

Hello to the loyal couple of you who continue to refresh this lonely blog. :)

I scrapped the branch I started on 6 months ago of the new version of pybox2d. The upstream library Box2D (now also hosted on Google Code) has seen a good deal of changes since then.

The most notable changes are:
  • The new dynamic tree-based broadphase
  • This makes it such that there will no longer be a maximum proxy count. So, you won't see b2_maxProxies assertion errors when you try to create too many colliding shapes.
  • Normalized and simplified class interfaces
  • The improved interface makes for an easier time in creating Pythonic properties.
  • Kinematic bodies
  • These special bodies are essentially static in that they don't respond to collisions, but they can have their velocities set. I'd imagine they would be most useful as, for example, rotating platforms in some side-scroller.
  • The removal of shape definitions and the addition of fixtures
  • I don't see this as offering much benefit to us on the Python end, but it allows shapes to be created and used without being attached to bodies. It makes for a great deal of changes for those attempting to port their code to the most recent version.
  • One-sided platforms
  • No more SetMassFromShapes() nonsense
  • New collision callback system
  • Weld and friction joints
  • Controllers have been removed
  • This is unfortunate, but was anyone actually using them?

Here are some things I'm trying to do with the upcoming version of pybox2d:
  • Unit tests
  • I'm attempting to use unit tests (suggestions would be welcome on this, as I'm fairly new to it) as I go along to ensure all of the properties work and I don't break things along the way.
  • Hide all getters and setters, while keeping things accessible in properties
  • I like this a lot, but I hate seeing the ugly __ClassName_GetterHere-type things when doing a dir(). Should I just skip the hiding and make it semi-private with _Getter to avoid the lengthy name-mangling? Should I re-implement __dir__ to hide these? I would just rather not have users calling the functions when there are perfectly good properties in place.
  • Properly downcast joints/shapes
  • So calls like b2Joint.downcast() (or previously getAsType()) are no longer necessary.
  • Custom __setattr__?
  • I've been toying with the possibility of using a custom setattr to keep the user from trying to set shadow class instance variables that don't exist in the real class. Maybe I'll make it an option or decide after performance tests.
  • Eventual 64-bit and Python 3.x compatibility
  • Pythonic-ish initializers?
  • I've also been considering having the ability to do, for example:
    body.CreateFixture(b2FixtureDef(shape=b2CircleShape(radius=1), density=1, friction=0.3))
    Any interest in that? It's simple sugar, but it could be useful.
  • Scrapping deprecated stuff, hiding unusable classes, pickling, etc.



Any thoughts? What would you like to see in the new version? Yell at me and tell me what I'm doing wrong before I get too far into it.