Ruby Gem for Chipmunk

Discuss new features and future development.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Ruby Gem for Chipmunk

Post by slembcke »

Well, you wouldn't be custom compiling anything so much as you would be adding a second library that contained the normally inlined functions as a dependency.

Another acceptable option would be to just do something like this:

Code: Select all

#define MAKE_REF(name) __typeof__(name) *_##name = name;
MAKE_REF(cpvadd); // makes a variable named _cpvadd that contains the function pointer for cpvadd()
MAKE_REF(cpvneg);
MAKE_REF(cpvsub);
MAKE_REF(cpvmult);
MAKE_REF(cpvdot);
MAKE_REF(cpvcross);
MAKE_REF(cpvperp);
MAKE_REF(cpvrperp);
MAKE_REF(cpvproject);
MAKE_REF(cpvrotate);
MAKE_REF(cpvunrotate);
MAKE_REF(cpvlengthsq);
MAKE_REF(cpvlerp);
MAKE_REF(cpvnormalize);
MAKE_REF(cpvnormalize_safe);
MAKE_REF(cpvclamp);
MAKE_REF(cpvlerpconst);
MAKE_REF(cpvdist);
MAKE_REF(cpvnear);
MAKE_REF(cpvdistsq);

MAKE_REF(cpBBNew);
MAKE_REF(cpBBintersects);
MAKE_REF(cpBBcontainsBB);
MAKE_REF(cpBBcontainsVect);
MAKE_REF(cpBBmerge);
MAKE_REF(cpBBexpand);

MAKE_REF(cpBodyWorld2Local);
MAKE_REF(cpBodyLocal2World);
MAKE_REF(cpBodyApplyImpulse);
That would make function pointers in global symbol name aliases that point to static instances of the functions. I would assume that you would be able to load these pointers the same way as you would a regular function pointer. Try pasting that into chipmunk.c to see if you can reference the functions that way. That's a simple enough solution for me to maintain that I'd be willing to add it. It might even end up being useful to somebody else too.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
shawn42
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am
Contact:

Re: Ruby Gem for Chipmunk

Post by shawn42 »

That didn't work for me. (btw it looks like you forgot to check a file into svn)

I don't know how to tell FFI to call a pointer to a function.

What does work is something along the lines of:
cpVect fficpv(const cpFloat x, const cpFloat y)
{
return cpv(x,y);
}

Now lets me bind to fficpv. Maybe you can define a macro that you use for defining static inlines that also creates another version of the function that calls the inlined?

I'll look deeper into calling those function pointers from FFI in the meantime.
shawn42
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am
Contact:

Re: Ruby Gem for Chipmunk

Post by shawn42 »

So it turns out that I am able to get that data and use it as a function pointer. So your MAKE_REF solution would work fine for me. :D

Also, when are you planning on doing another release?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Ruby Gem for Chipmunk

Post by slembcke »

The current plan is to make a new official release as soon as the documentation is up to date. I was hoping to have finished that this weekend... but It's still not quite done yet.

Google Code is read only for the moment. Something about network maintenance. I'll commit add the FFI references and the fixed CMake files once it's back up.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
shawn42
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am
Contact:

Re: Ruby Gem for Chipmunk

Post by shawn42 »

If you are getting ready for a release, can I beg of you to put in a version method? As of now, there is no way that I know of to dynamically determine the verison of chipmunk a user has. :shock:
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Ruby Gem for Chipmunk

Post by slembcke »

shawn42 wrote:If you are getting ready for a release, can I beg of you to put in a version method? As of now, there is no way that I know of to dynamically determine the verison of chipmunk a user has. :shock:
Oh! I had meant to do that a long long time ago actually. I'll add a string for that.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
shawn42
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am
Contact:

Re: Ruby Gem for Chipmunk

Post by shawn42 »

Great! :D
shawn42
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am
Contact:

Re: Ruby Gem for Chipmunk

Post by shawn42 »

Looks like you've missed a few:
MAKE_REF(cpBBClampVect);
MAKE_REF(cpBBWrapVect);

If you'd like to give me commit rights to add these, I do not mind maintaining them, else I can send them to you as I find them.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Ruby Gem for Chipmunk

Post by slembcke »

cpBBClampVect and cpBBWrapVect are defined in cpBB.c and are not static.

Also... I never realized the naming on my AABB functions was so screwy... Whatever, they rarely get used anyway.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
shawn42
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am
Contact:

Re: Ruby Gem for Chipmunk

Post by shawn42 »

Right you are. Maybe I shouldn't write code at 2am baby feedings.... :oops:
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests