Emscripten Box2D and Rube

General discussion about the R.U.B.E editor
Post Reply
aholla
Posts: 10
Joined: Fri Feb 22, 2013 4:18 pm

Emscripten Box2D and Rube

Post by aholla »

Hi iForce,

I have just seen you have been contributing to the Emscripten version of box2d (https://github.com/kripken/box2d.js), I have see your tests: http://www.iforce2d.net/embox2d/testbed.html and wondered what you though of its performance over box2dweb.

Obviously this would not be the only advantage, as you have mentioned it would be easier to keep up with the C++ version.

Also do you have an implementation using the Rube export. I have tried editing your "loadrube.js" (which works great for box2dweb) but it seems like a lot of the method names have changed.

I am also interested in testing it on different devices, so far with box2dweb, I have found there is a bug that prevents it working on ios (can be fixed with simple hack) but also on other devices, Kindle Fire's and some androids.

Thanks,

Adam
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Emscripten Box2D and Rube

Post by iforce2d »

It's not that the method names have changed, it's more like they never were the same. The main reason I left emscripten for box2dweb was the way it is more suited for working with as a library (try setting up contact listener callbacks...) and easier to customize a bit here and there when necessary. I did not realize at first that the Emscripten port of Box2D was really only meant as a benchmark and a proof of concept. If it had shown outstandingly better performance I might have stuck with it, but it seemed to be roughly on par with box2dweb. Finally, the existing user base of box2dweb is much greater, so when considering which would be more useful for the most people (as a RUBE export) it was really only box2dweb that stood out.

On the other hand, the Emscripten port will give you all the joints available in the C++ version.

If you are interested in performance, I came across a fast port that has a lot of hand tuning: https://github.com/illandril/box2dweb-closure
It has departed from the original box2dweb somewhat, but should be still mostly the same to use iirc.

I have not noticed any showstopper bugs related to iOS with box2dweb, but it does run pretty slow :D
aholla
Posts: 10
Joined: Fri Feb 22, 2013 4:18 pm

Re: Emscripten Box2D and Rube

Post by aholla »

Hey thanks for the reply, I read this post which compares various methods of running box 2d and the emscripten version does appear very similar to the box2dweb version but it looks like there might be less garbage collection (smaller spikes). http://blog.j15r.com/blog/2011/12/15/Bo ... erformance

Thanks for the link to the closure version, im looking and getting that compiled within my project and will post back when/if i get it working.

As for bugs... the "Math.MIN_VALUE" or something similar is returned as 0 on ios < 6, box2dweb uses lots or "x * Math.MIN_VALUE" which means a lot of stuff is multiplied by 0 which means it just does not run. Also on Kindle devices it does not run but i'm am not sure what this is related to. There may also be an issue with Math.INFINITY, different interpreters return different values
Post Reply