Quick bulletin that I’m working on porting Erin’s recent changes to Box2D, which will eventually become the bulk of 2.1. It’s a pretty big job, which I’m doing at once, so there’ll be nothing compilable for a while. I’ve done maybe 10%.
I have a few changes planned for 2.1 beyond mirroring the C++. Box2DFlashAS3 will be breaking compatibility with the C++ and backwards compatibility in both API and implementation.
These changes will be put in place after porting is largely complete.
- The API will be changed to AS3 coding conventions. No b2- prefixes (namespaces are good enough), and lowerCamelCase instead of UpperCamelCase. The b2Vec class will be scourged of inconsistent methods, though letter-style overloading will remain (e.g. b2MulX vs b2MulMV).
- The API will reflect AS3 idioms better. Get/set properties will be available in addition to the method style. Fixed sized arrays will be reduced in prominence. Function callbacks will be available for some methods. Definitions objects will become optional.
- The source will transition to using Vector.<> rather than Array internally. A release using Array will be provided using a sed script, but the HEAD version won’t be.
- Broadphases will be swappable. There’ll be two implementations initially: the old SAP, and the new Dynamic tree one. This is mainly because I’m curious as the performance difference.
- Possibly will keep the edge shape as a distinct shape type from polygon (they are being merged in the C++). I think the connectivity information will come in handy for various reasons (such as ensuring leakproof raycasting).
- Performance will suffer. Box2DFlashAS3 has extensive inlining, and I do not have time to recreate all this for the new code. This might for the basis for a later project, along with RVO.
Between these changes, and the C++ API changes, this release will be fairly non-backwards compatible. I would recommend upgrading existing projects only for devoted users. Just to spell it out, here is a small sample of how the differences might be.
2.0:
var bd:b2BodyDef = new b2BodyDef();
var body:b2Body = myWorld.CreateBody(bd);
var cd:b2CircleDef = new b2CircleDef();
cd.radius = 5;
cd.density = 1;
cd.restitution = 0.5;
body.CreateShape(cd);
body.SetMassFromShapes();
2.1:
var body:Body = myWorld.createBody();
var f:Fixture = body.createFixture2(Circle.create(5), 1);
f.restitution = 0.5;
body.setMassFromShapes();
This is ALL PLANS. Meaning, it’s open to negotiation, and I have no guarantees that I’ll get round to everything. I’m particularly keen to hear the Java porter’s opinions.
How can you help? Uh, well atm you cannot, unless you are willing to port a file or two, and you have both good C++ and AS3. I’ll let you know later – I’ll need a new TestBed formed, and then debuggers to unearth why the new TestBed doesn’t work.
Comments diabled – please comment on the forum here.