BorisTheBrave wrote:
You've miscounted the cost of conversion. If the api uses V2 consistently, and internally you use b2Vec2, that means every getter must constructing a new vector each time, which will badly hurt garbage collection. The alternative of using b2Vec everywhere is impossible, users cannot cope with destroying vectors manually.
That is a damn good point. I think I'll go with the cached AS3 values route, so that...
Code:
b2body.m_linearVelocity.v2 = b2body.m_linearVelocity.v2.add(someV2);
will become...
Code:
b2body.m_linearVelocity.read().add(someV2).write();
Using proper getters / setters will remain the same...
Code:
b2body.SetLinearVelocity(b2body.GetLinearVelocity().add(someV2));
All fancy vector operations (normalize, dot products, etc.) will take place AS3 side. read() and write() will sync the two.
Vlad: Yes, CS4, Flash 10 only. http://wiki.github.com/jesses/wck/