cdlm / pharo-storm

Small game framework and FFI bindings to Chipmunk2D physics library
4 stars 1 forks source link

Chipmunk version #1

Open tinchodias opened 5 years ago

tinchodias commented 5 years ago

Hello: Do you know what version of the library matches the Chipmunk Pharo bindings? If so, it would be great to add it to README.

In sthub, @estebanlm mentions the command line to execute:

cmake -DCMAKE_C_FLAGS='-m32 -DCHIPMUNK_FFI' .

but missis the version. According to this repo's commits, in March of 2016 had some examples working so it might be 7.0.1 (https://github.com/slembcke/Chipmunk2D/releases), but maybe some 6.x.

cdlm commented 5 years ago

The slides for my NativeBoost tutorial at ESUG'13 say 6.1.5. Can you check if that works?

tinchodias commented 5 years ago

Thanks!

The library: I downloaded and compiled it but without -m32. This means it's 64 bits, right? I have no experience in FFI but I think this is a risky change. I decided to try like this because -m32 raised some errors and 64bits is well supported now in Pharo. Bad idea?

I download Pharo 70 64 bits like this: curl https://get.pharo.org/64/70+vm | bash.

Storm: I modified the baseline locally to remove external packages Athens-Playground and FFI because I had some loading messages. Looks like this now:

baseline: spec
    <baseline>
    spec for: #common do: [
        spec
            package: 'Storm-Core';
            package: 'Storm-2D' with: [ spec requires: #('Storm-Core') ];
            package: 'Storm-Morphic' with: [ spec requires: #('Storm-2D') ];
            package: 'Storm-Tests' with: [ spec requires: #('Storm-2D') ] ]

I couldn't execute without any example a crash, but this is a proof that some basic calls do work:

space := CmSpace new
    gravity: 0@ -100;
    yourself.

space gravity.
 "(0.0@0.0)"

space damping.
 "0.0"

space step: (1/60) asFloat.
 "a CmSpace((void*)@ 16r7F8B1ABCBB10)"

staticBody := space staticBody.
 "a CmBody((void*)@ 16r7F8B1ABCBC28)"

staticBody angularVelocity.
 "0.0"

staticBody angle.
 "0.0"

staticBody force.
 "(2.2420775429197073e-44@0.0)"

staticBody mass.
 "0.0"

staticBody position.
 "(2.2420775429197073e-44@0.0)"

staticBody rotation.
 "CmVector ( 
x:  2.2420775429197073e-44
y:  0.0
)"

staticBody torque.
 "0.0"
tinchodias commented 5 years ago

I was not exact when I wrote that all examples crash. There is CmExamples>>example1 which raises this error: Instance of ExternalData did not understand #adoptAddress: and can be reproduced with this code:

space := CmSpace new
    gravity: 0@ -100;
    yourself.

ground := CmShape 
    newSegmentBody: space staticBody
        from: -20@5
        to: 20@ -5
        radius: 0.

For sure, I should learn more of FFI to make this work, and only have little time so I still prefer to check if you can guide me to some easy solution.

cdlm commented 5 years ago

I really don't have a clue, I didn't touch that code in 5 years 😅 That was before UFFI even existed…

estebanlm commented 5 years ago

@tinchodias nothing will work from then to now :) too many things has changed. Alvaro Piorno from Argentina made a work to update Storm (the origin of this packages) to its own project Winter: https://github.com/ba-st/Winter (but I think he let Chipmunk outside for now). So... long story short: you will need to work a lot, because everything is made assuming 32bit (and we live now in a 64bit world)

tinchodias commented 5 years ago

@cdlm @estebanlm thanks. I was playing with Roassal's "force based layout" which simulates physics for the nodes and edges of a graph but lacks collision detection... I was curious how could it look if re-implemented with Chipmunk. For the moment, I don't have an excuse to invest time in reviving these bindings but if one day I have, then we talk again :)

tinchodias commented 5 years ago

So, I don't know what do you prefer to do with this issue. Do we close it? A mention of the library version would be useful, anyway. And the link to the slides ;-)