box2d.js icon indicating copy to clipboard operation
box2d.js copied to clipboard

Some bindings are not generated because of missing constructors

Open modeswitch opened this issue 12 years ago • 12 comments

Bindings for b2ContactListener and b2Fixture (probably others) are not generated because those classes do not have constructors. Adding trivial constructors to the C++ code and recompiling fixes the problem.

In general it would be cool to auto-generate these constructors for classes that don't have them.

modeswitch avatar Mar 13 '12 17:03 modeswitch

b2DebugDraw seems to be missing as well.

@kripken Are there any plans for a future build? I would really appreciate it and like to use your version, since it is a direct port and also (to my knowledge) the only one of box2d 2.2. Apparently lots of fixes for kinematic bodies were integrated into that version, which I am dependent on.

follmann avatar Apr 16 '12 09:04 follmann

I am afraid I have very little time to work on this myself, sorry. However I am happy to guide you if you run into problems building.

kripken avatar Apr 17 '12 00:04 kripken

@follmann If it's the same problem I had, it can be fixed by adding a default public constructor to the missing class and rebuilding. b2Fixture and b2ContactListener needed this fix, but there are probably others.

modeswitch avatar Apr 17 '12 00:04 modeswitch

Thanks guys for the quick responses! Is there a build manual that I overlooked? I wouldn't mind getting into the nitty gritty stuff myself. Cheers!

follmann avatar Apr 17 '12 14:04 follmann

There isn't a manual, basically you should just run make and it should build. You will need emscripten to be set up though and adjust paths to it in Makefile. It's a good idea to start with the emscripten tutorial first, then do this.

kripken avatar Apr 17 '12 16:04 kripken

Alright thanks! I'll look into that...

follmann avatar Apr 17 '12 17:04 follmann

Working on this

insidewhy avatar Aug 28 '12 21:08 insidewhy

Got b2ContactListener exposed but BeginContact/EndContact events are not fired.

Okay got it working using Box2D.customiseVTable, for this to work b2ContactListener still needs a public constructor though, I'll commit the change into my branch.

insidewhy avatar Aug 29 '12 15:08 insidewhy

@alankligman My latest patch which was very kindly accepted by @kripken has added in constructors to b2ContactEdge, b2Fixture and b2ContactListener allowing collision events to be intercepted.

It's less ideal than having emscripten generate bindings for classes without constructors but it works. I'm using this port of box2d.js in my gaming engine and it's working out.

insidewhy avatar Oct 05 '12 09:10 insidewhy

Note that we are working on a new bindings approach in emscripten. It will take some time before it's stable, but it should make it easier to improve box2d.js.

@nuisanceofcats btw, is there a link to a demo of your engine? :)

kripken avatar Oct 05 '12 18:10 kripken

@kripken Absolutely! I didn't want to be a spammer and paste it here but since you asked: http://ccg.chilon.net

You need WebGL and Web Workers for it to work. It betrays that notice in your README about box2d.js not being tested as it's using so much of it successfully.

insidewhy avatar Oct 06 '12 09:10 insidewhy

Cool demo, thanks for the link :)

kripken avatar Oct 10 '12 00:10 kripken