melonjs / melonJS

a fresh, modern & lightweight HTML5 game engine
https://melonjs.org
MIT License
5.91k stars 643 forks source link

Native chipmunk integration #145

Closed melonjs closed 10 years ago

melonjs commented 11 years ago

I was discussion the point as well with Noel, but what about directly integrating chipmunk into melonJS ?

That will for sure break some APIs here and there, but this will bring the benefits of a complete and robust physic engine to manage collision, and has been proven as good enough to provide very satisfying performances (if you followed what @parasyte has been working on since last months).

Furthermore, this should (by side-effect) fix or help with current bugs and limitations like ticket #16, #38, #50, #103

melonjs commented 11 years ago

interesting article (not about chipmunk) : http://www.webappers.com/2012/12/11/a-comparison-of-javascript-physics-engines/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Webappers+%28WebAppers%29

Tokyonono commented 11 years ago

I also recommend reading this article, it is really well written : http://nine-software.com/2012/12/box2d-vs-chipmunk-html5-games/

parasyte commented 11 years ago

Lots of updates to Chipmunk-js since I last used it: https://github.com/josephg/Chipmunk-js/commits/master

parasyte commented 11 years ago

With CocoonJS supporting native Box2d, we might consider using Box2d instead of Chipmunk. But I would actually rather have Chipmunk, because @Tokyonono makes an important observation in his article; Chipmunk is updated more often, and probably better optimized since it is directly ported from C. (And not a port-of-a-port)

I would be ok with writing a wrapper around CocoonJS-Box2d, if that's feasible. A single API for the best of both worlds?

On CocoonJS native Box2d; it's really impressive. Ibon demonstrated it during his presentation at GDC. The first demo was an iPad 3 running CocoonJS with Box2dWeb. The game was obviously slower than 30 fps. The second demo was the same game on an iPad 1 running CocoonJS with native Box2d. That one ran flawlessly smooth.

Tokyonono commented 11 years ago

1/ If the performance of Chipmunk is good enough, we don't have to switch to Box2D, even if it is better supported by CocoonJS. We have to think about the long term. 2/ iPad 1 ... who cares :-)

parasyte commented 11 years ago

Performance of Chipmunk-js on mobile is not terribly impressive, even on recently hardware. I fought with it last November while developing a physics-based game. You can read more on my blog. In particular the following posts:

10 rigid bodies and 10 constraints is enough to bring the frame rate down to about 40 fps (as I recall) on iPhone 4S. Not the most powerful of mobile devices, but if there's anything to take away from this experience, it's that native physics is more important than it first seems. (I would prefer native Chipmunk, but you make the best of what you have available!) My argument here is that Chipmunk-js performance is not acceptable on mobile for these reasons.

The iPad 1 demo was just to show that the performance improvement is exceptional. It's one of those things were you take the lowest common denominator, and beat the competition in every way just to make a point.

Tokyonono commented 11 years ago

I never ran any performance tests, if it is that slow with Chipmunk, we should consider Box2D, but I am really not a big fan of using dead projects... I know what the point of using iPad 1 was, it is just that it shouldn't be a reason to choose one framework over another.

parasyte commented 11 years ago

I agree, and strongly prefer Chipmunk!

But discussing with @obiot last night, I think we came to the same conclusion; We integrate Chipmunk-js "officially", and write a wrapper for CocoonJS's native Box2D. In the end, we'll have a Chipmunk API which performs very well on CocoonJS for mobile, and Chipmunk-js for Desktop environments (where the performance of physics simulation in JavaScript is quite good).

obiot commented 11 years ago

@parasyte 0.9.8 too ?

parasyte commented 11 years ago

@obiot Good call. :)

obiot commented 11 years ago

postponed again, as end of June is in two weeks ;)

truongsinh commented 10 years ago

I wonder why this ticket was closed

obiot commented 10 years ago

because it was duplicated with #235

truongsinh commented 10 years ago

With basic math, I can see that #145 is lower than #235, i.e. #145 is older, i.e #235 was duplicated with this ticket, not vice versa. Or did I miss something?

parasyte commented 10 years ago

@truongsinh #235 supersedes this ticket, that's all.

truongsinh commented 10 years ago

oh ok!