Ruby Gem for Chipmunk

Discuss new features and future development.

Re: Ruby Gem for Chipmunk

Postby slembcke » Tue Dec 01, 2009 5:35 pm

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/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Ruby Gem for Chipmunk

Postby shawn42 » Tue Dec 01, 2009 9:53 pm

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

Re: Ruby Gem for Chipmunk

Postby shawn42 » Wed Dec 02, 2009 9:43 am

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?
shawn42
 
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am

Re: Ruby Gem for Chipmunk

Postby slembcke » Wed Dec 02, 2009 10:36 am

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/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Ruby Gem for Chipmunk

Postby shawn42 » Wed Dec 02, 2009 1:22 pm

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:
shawn42
 
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am

Re: Ruby Gem for Chipmunk

Postby slembcke » Wed Dec 02, 2009 4:20 pm

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/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Ruby Gem for Chipmunk

Postby shawn42 » Wed Dec 02, 2009 8:23 pm

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

Re: Ruby Gem for Chipmunk

Postby shawn42 » Wed Dec 02, 2009 9:47 pm

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.
shawn42
 
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am

Re: Ruby Gem for Chipmunk

Postby slembcke » Thu Dec 03, 2009 10:25 am

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/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Ruby Gem for Chipmunk

Postby shawn42 » Thu Dec 03, 2009 3:36 pm

Right you are. Maybe I shouldn't write code at 2am baby feedings.... :oops:
shawn42
 
Posts: 11
Joined: Fri Nov 20, 2009 11:18 am

Previous

Return to Features/Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron