Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Chipmunk for Gideros? — Gideros Forum

Chipmunk for Gideros?

ArtiomArtiom Member
edited January 2014 in General questions
Hi!
I'm developing my game and recently understood that Box2D is not enough for it.
Performance is good in general but I get lower (50-55/60) FPS when have a lot of physics objects using my HTC One. I want to make my game run good on most devices.
What about Chipmunk engine? I hear that it's way faster than Box2D. And I can see that non-pro version is free and open source. Is it hard for Gideros developers make one more physics engine for it? How about making plugin myself, is it possible?

Likes: Artiom

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • 1) With Gideros 2014.01 Box2d was upgraded to 2.3 version, which also improves performance of the physics engine, so may want to try again and see if that helps.

    2) Unfortunately currently we don't have time nor resources to add additional physics engine

    3) Yes you can surely make your own plugin if you are familiar with that specific physics library and C++ and a little of Lua bindings (with latter I can help :) )
  • There are a lot of function there.. Is it possible to make some auto-bindings?
  • Hmm, even better
    there are already bindings
    https://code.google.com/p/lunatic-chipmunk/
    Only need to change initiating to make it behave like Gideros,
    let me try hopefully this weekend ;)
  • Created a plugin for Windows, just to try it out, all compiles, but can't get it to update body positions (as I have never used Chipmunk before maybe I'm doing something wrong)

    Added dll file to post, simply put it in Plugins directory in Gideros installation folder
    and here is my test code (which is NOT working as expected)
    require "chipmunk"
     
    local space = chipmunk.NewSpace() 
    space.gravity = {10, 0}
    space.iterations = 1
     
    local ball = Bitmap.new(Texture.new("ball.png", true))
    ball:setAnchorPoint(0.5, 0.5)
    stage:addChild(ball)
     
    local moi = chipmunk.MomentForBox( 10, 10, 10) 
    ball.body = chipmunk.NewBody(10, moi)
    ball.body.pos = {100, 100}
    ball.body.angle = 0
    ball.body.vel = {10, 10}
     
    local shape = ball.body:NewCircleShape(ball:getWidth()/2, {100,190} )
    space:AddShape(shape)
    space:AddBody(body)
     
     
    stage:addEventListener(Event.ENTER_FRAME, function(e)
    	space:Step(1/60)
    	ball:setPosition(ball.body.pos["x"], ball.body.pos["x"])
    end)
    zip
    zip
    chipmunk.zip
    81K
  • ar2rsawseenar2rsawseen Maintainer
    edited January 2014
    But to answer your question, yes there are also libraries to do autobinding, but I have not used any of them, so can't comment more
    http://lua-users.org/wiki/BindingCodeToLua
  • Thanks for help.
    Yeah, I saw that bindings but I think it's far from full. There just a few classes, no even joints.
  • ar2rsawseenar2rsawseen Maintainer
    edited January 2014
    Yes I thought there were too little classes, but still it could be a great place to start with :)

    So I can share source of that chipmunk plugin, if you need
  • Yes, please.
  • Here it is.
    Basically all I did was write stub file (chipmunk_stub.cpp) to make it a Gideros plugin, put it all into QT and changed some header paths and thats it, desktop plugin was ready :)
    zip
    zip
    lunatic-chipmunk.zip
    136K
  • Thank you. There are a lot of work through. I'll tell you if I have some success.
  • I think you can do a plug-in, I am not sure.

    I used Chipmunk in the past, and I think it is just great, and I don't understand Box2D popularity, Chipmunk is clearly superior unless you want to do crazy joint physics.

    Mostly because of how Chipmunk tracks objects (a spatial hash, while Box2D use a stupid tree that it has to reorganize too frequently).

    You can see the difference of performance when you stick kazillions of similar objects in the same scene, for example trying to simulate a fluid with several thousand circles, chipmunk handles that well, Box2D does not.

    On the other hand, if you want to simulate springs + ropes + crazy joints + crazy scales (ie: a 10 cm object tied to a 200 meter object tied to a spring to a 2km mountain) then Box2D behaves better.

    But for the games I do (when I use physics, that is...) that are usually shmups or resemble shmups, Chipmunk is MUCH, MUCH better.
    I make games for children: http://www.kidoteca.com
  • What????

    (I wrote the above post, and clicked "post comment" when this thread had zero posts... now I turned on the computer, saw this page, and saw that it finally finished submitting O.o)
    I make games for children: http://www.kidoteca.com
  • I would actually be astonished by scripts resuming capabilities :D
  • ArtiomArtiom Member
    edited January 2014
    Btw: I hear that luajit is coming for gideros soon. Will it be possible to create plugin using ffi? That would be a lot simplier.

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • most probably true, and I also saw ffi bind chipmunk code somewhere
  • Yes, I saw it too.
  • ArtiomArtiom Member
    edited April 2014
    Well, I need to say I'm almost done with chipmunk for Gideros. That took two days :)
    It's working and I think quite fast. I compiled chipmunk for Android, took lua bindings and call it thought LuaJIT's FFI. It's not so easy-to-use as internal Box2D but it works good!
    Anyway, I can't recreate that physics on chipmunk that I had on Box2D, so I will not use it. If someone wants to finish my job (ffi bindings need to be changed a little, very easy) you can tell me, may be we'll release a plugin.

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    So what exactly it had differently that you did not like? Just wondering as I never worked with chipmunk
  • @ar2rsawseen,
    I have complex physics character with 60 bodies and 120 different joints.. After 4 hours of experiments I couldn't make same behavior as with Box2D. But for other things I think it would be great.
Sign In or Register to comment.