![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
My code is now condensed by 50% as all my collision detection stuff is out the window. (Of course I understand that Chipmunk itself actually makes the code bigger, but it's not my code, so I don't count it!)
However, I wanted to know if this was a correct way of going about things.
I am using a struct array to store body information (mass, velocity, force, etc), in my own Euler integrated gravity system.
So something like this.
body mybody[numbodies];
mybody.vx += foox; mybody.vy += fooy;
(where foo is part the gravity equation)
What I've done is simply added a cpBody and cpShape pointer to this struct. Then what I do is something like this after running my Eular integrated method:
mybody.mycpBody->v.x = mybody.vx; mybody.mycpBody->v.y = mybody.vy;
I run cpSpaceStep.
Then I push the values back: mybody.vx = mybody.mycpBody->v.x; mybody.vy = mybody.mycpBody->v.y;
Then run the calculation again.
It works great!
![Smile :)](./images/smilies/icon_e_smile.gif)
Thanks for any input (code style is welcome too of course).