Page 2 of 3

Re: Chipmunk release 4 comming soon.

Posted: Wed Oct 03, 2007 12:27 am
by Michael Buckley
Per-body gravity is exactly why we wrote a simple cpSpaceStep replacement for our project. After looking at the source, we concluded that it would be too expensive to create a cpSpace for each different gravity vector we wanted. It's not that we're going to need it all of the time, but there are a few levels where we're counting on the player being able to shift the gravity of certain sets of objects.

Re: Chipmunk release 4 comming soon.

Posted: Fri Oct 05, 2007 12:42 pm
by dirkbj
Will release 4 beef up the Ruby bindings support, such as adding some missing convenience methods (e.g., cpvforangle) and layers and groups for shapes?

Any ETA?

Dirk

Re: Chipmunk release 4 comming soon.

Posted: Fri Oct 05, 2007 4:00 pm
by slembcke
Sorry I haven't been very responsive lately. I've been a bit distracted with things. I think that all the functionality changes/fixes are done. I just need to make sure that the documentation (and Ruby binding) is up to date, and make sure that all the projects/build scripts work.

It would take like an afternoon of concerted effort. I know that there are people eagerly awaiting, so I guess I could try shoot for Saturday afternoon.

Re: Chipmunk release 4 comming soon.

Posted: Sat Oct 06, 2007 1:19 am
by dirkbj
He he he... yep, we are all anxious, but take your time... life is busy. We'll survive till you get to it.

Keep it fun.

;)

Re: Chipmunk release 4 comming soon.

Posted: Sat Oct 27, 2007 7:43 am
by vulh102
just wondering what the status on the new release is?
seems it was a while ago anything got posted here

Re: Chipmunk release 4 comming soon.

Posted: Sat Oct 27, 2007 1:40 pm
by slembcke
Well I updated the C documentation and Ruby extension today. Now I just need to update the Ruby Docs and make a release! Got to run out now, but I'll work on it more tonight I think.

Re: Chipmunk release 4 comming soon.

Posted: Sat Oct 27, 2007 8:45 pm
by slembcke
Ok, the changes are in. I just need to type up the release notes and bundle it up.

In the mean time if people could test the non-OS X build files. That would be handy.

Re: Chipmunk release 4 comming soon.

Posted: Mon Oct 29, 2007 9:10 am
by vulh102
Nice :)

will there be some official cermony or at least a update on the homepage?
and, is there a changelog somewhere, im dying to check it out!

XD

Re: Chipmunk release 4 comming soon.

Posted: Sat Nov 03, 2007 4:23 am
by joshcryer
Michael Buckley, feel like discussing your simple gravity model? At least, where did you go about modifying Chipmunk to include one?

Re: Chipmunk release 4 comming soon.

Posted: Sat Nov 03, 2007 2:57 pm
by Michael Buckley
joshcryer wrote:Michael Buckley, feel like discussing your simple gravity model? At least, where did you go about modifying Chipmunk to include one?
Sure. So the first thing I should mention is that I did this with Chipmunk Release 3. I haven't checked to make sure it works in the latest release. The second thing that I should mention is that I did not have to modify Chipmunk in any way. I simply wrote a function which is mostly equivalent to cpSpaceStep (in fact, I used some of the source from cpSpaceStep) and called that instead. I'm not going to post the actual code, because there's a lot of other things going on in it, so I'm going to simplify it quite a bit, even to the point of using a straigt-up array instead of some other data structure.

So basically, the gist of it is to set up a class, I called it PhysicsLayer, which has as its member values a cpv to represent gravity, and an array of pointers to cpBodies which you want to fall under this gravity. You'll want each cpBody to be a member of at most one PhysicsLayer. I then have a class called PhysicsManager which has an array of physicsLayers, a float for the timestep (e.g. 1.0f/60.0f), and a float for the damping value (usually pow(1.0f, -timeStamp). In you also have a cpSpace with no gravity to which you add all of the bodies in all the PhysicsLayers. Then, in the PhysicsManager, you have a method called update (or whatever you want) which runs like this:

Code: Select all

// Assume size is the precomputed length of the array of PhysicsLayers layers.

for(int i = 0; i < size; ++i){
    layers[i]->applyGravity(timeStep, damping);
}

cpSpaceStep(space, timeStep);
return;

And then in your PhysicsManager class, the applyGravity method goes like this:

Code: Select all

// Assume size is the precomputed length of the array of cpBodies bodies, and gravity is a cpv with the gravity value.
for(int i = 0; i < size; ++i){
    cpBodyUpdateVelocity(bodies[i], gravity, damping, timeStep);
}

return;

And that's really all there is to it.