cpArrayEach is missed on 6.xx

Discuss any Chipmunk bugs here.

cpArrayEach is missed on 6.xx

Postby aisman » Tue May 10, 2011 6:10 am

Hello slembke,

I miss a cpArrayEach() on Chipmunk 6.x.x
Chipmunk4PB: The fastest way to write games together with PureBasic and the Chipmunk physics engine.
User avatar
aisman
 
Posts: 144
Joined: Tue Mar 04, 2008 2:21 am

Re: cpArrayEach is missed on 6.xx

Postby slembcke » Tue May 10, 2011 10:25 am

Yes. There are no publicly accessible cpArrays in Chipmunk's API. So I made cpArray private. I didn't actually use cpArrayEach() anywhere in Chipmunk's code anymore so I removed it.

What do you need it for? I made official APIs for all the uses of cpArrayEach() that I knew of, so hopefully there is a better way to do what you want.
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: cpArrayEach is missed on 6.xx

Postby aisman » Sun May 15, 2011 3:39 am

Ok. I will update the PureBasic wrapper to Chipmunk 6.x.x.
Thanks.
Chipmunk4PB: The fastest way to write games together with PureBasic and the Chipmunk physics engine.
User avatar
aisman
 
Posts: 144
Joined: Tue Mar 04, 2008 2:21 am

Re: cpArrayEach is missed on 6.xx

Postby aisman » Wed Jul 13, 2011 2:28 am

slembcke wrote:Yes. There are no publicly accessible cpArrays in Chipmunk's API. So I made cpArray private. I didn't actually use cpArrayEach() anywhere in Chipmunk's code anymore so I removed it.

What do you need it for? I made official APIs for all the uses of cpArrayEach() that I knew of, so hopefully there is a better way to do what you want.

Hello slembcke,

That's not right. You use it on your demos.
But not really the Chipmunk API function: cpArrayEach. You use the code of the cpArrayEach directly without a function call.

Look here:
drawSpace.c (line 475-483)
Code: Select all
         for(int i=0; i<arbiters->num; i++){
            cpArbiter *arb = (cpArbiter*)arbiters->arr[i];
            if(arb->state != cpArbiterStateFirstColl) continue;
            
            for(int i=0; i<arb->numContacts; i++){
               cpVect v = arb->contacts[i].p;
               glVertex2f(v.x, v.y);
            }
         }


Code: Select all
void
cpArrayEach(cpArray *arr, cpArrayIter iterFunc, void *data)
{
   for(int i=0; i<arr->num; i++)
      iterFunc(arr->arr[i], data);
}
Chipmunk4PB: The fastest way to write games together with PureBasic and the Chipmunk physics engine.
User avatar
aisman
 
Posts: 144
Joined: Tue Mar 04, 2008 2:21 am

Re: cpArrayEach is missed on 6.xx

Postby slembcke » Wed Jul 13, 2011 7:55 am

drawSpace.c is not part of the Chipmunk API. It also includes chipmunk_private.h to get at some of the low level information that it uses. I rarely if ever use the private API even in my own games because I don't want to maintain them against changes that I make to Chipmunk's internals.

cpArray is a terrible dynamic array implementation. It only implements a tiny fraction of what would be considered useful for a generic implementation. Only the parts that are actually needed by Chipmunk. If you want to write your binding using the private API that's fine, I do with Objective Chipmunk a little. Just don't directly expose the private API because it might change in the future.
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


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron