Birch-san / box2d-wasm

Box2D physics engine compiled to WebAssembly. Supports TypeScript and ES modules.
263 stars 21 forks source link

JSContactListenerWithoutSolveCallbacks has no constructor #35

Closed BlueNebulaDev closed 2 years ago

BlueNebulaDev commented 2 years ago

I suspect that this line should contain void JSContactListenerWithoutSolveCallbacks();: https://github.com/Birch-san/box2d-wasm/blob/b8c98364a085a0dd1371707778c28576365bdb96/box2d-wasm/Box2D.idl#L52

Birch-san commented 2 years ago

yeah, I think you're right.

JSContactListenerWithoutSolveCallbacks was a quick, untested attempt of mine to satisfy this TODO from box2d.js:
https://github.com/kripken/box2d.js/blob/1e6e9da36a3160a9f40cda4cddcb4f83abb4d82c/Box2D_v2.3.1.idl#L33-L35

hmm, I also see that their [JSImplementation="b2ContactListener"]s clash.

I think the best solution is to just delete JSContactListenerWithoutSolveCallbacks — the performance problem it was designed to solve (eliminating WASM->JS calls) is not a problem nowadays.

if you construct a b2ContactListener, I'm not sure (because of the clash) whether you'll end up with a JSContactListener or a JSContactListenerWithoutSolveCallbacks. if it's the former (i.e. solve callbacks are included), then I think this isn't very consequential (because you can implement the solve callbacks as a no-op if you want to ignore them). but if it's calling the latter, then solve callbacks won't be called, which is a bigger problem.

are you trying to use solve callbacks, and are they not working?

BlueNebulaDev commented 2 years ago

I've been using JSContactListener and PreSolve and PostSolve are called, so everything works correctly with that class.

Birch-san commented 2 years ago

v7.0.0 deletes JSContactListenerWithoutSolveCallbacks.