openfl / box2d

Haxe port of Box2D, a popular rigid-body 2D physics engine
Other
95 stars 28 forks source link

Can't edit contacts! (box2dflash 2.1a was outdated, broken, incomplete) #18

Open JoeCreates opened 5 years ago

JoeCreates commented 5 years ago

I wanted to raise this issue mainly to raise awareness as there is no simple fix.

The version of Box2D which this is a port of (2.1a) is not only very out of date, but was broken/incomplete at the time and lost some critical features compared to the even older 2.0.2. C++ box2d has since developed far beyond this version (2.3.1 in 2014) and never lost those critical features.

The main missing feature I came across was that in 2.1a you cannot modify a contact, which is a really big deal. For example, suppose you want to use a listener to change the friction of a contact based on the normal, in cpp this is easy (https://github.com/erincatto/Box2D/blob/master/Box2D/Dynamics/Contacts/b2Contact.h#L120). These variables and methods are not new; they pre-date version 2.1.

But for some reason they were removed from flash 2.1a so now contacts don't even have these properties in flash/haxe 2.1a.

I would recommend the cpp version as a better source as it is not only more up to date with better features, but also isn't critically broken when it comes to editing contacts.

jgranick commented 5 years ago

I did not know that Box2D (the original) had only been updated as recently as 4 years ago. It would be very interesting if we could write A.) a CFFI version for Haxe C++ to use the original but also B.) consider doing a newer port to Haxe for all targets to use.

We could also consider A.) plus a WASM version for JavaScript (maybe someone has already done that)

jgranick commented 5 years ago

Speaking of: https://github.com/kripken/box2d.js/