cpArrayEach is missed on 6.xx

Discuss any Chipmunk bugs here.
Post Reply
aisman
Posts: 145
Joined: Tue Mar 04, 2008 2:21 am
Contact:

cpArrayEach is missed on 6.xx

Post by aisman »

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
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpArrayEach is missed on 6.xx

Post by slembcke »

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/
aisman
Posts: 145
Joined: Tue Mar 04, 2008 2:21 am
Contact:

Re: cpArrayEach is missed on 6.xx

Post by aisman »

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.
aisman
Posts: 145
Joined: Tue Mar 04, 2008 2:21 am
Contact:

Re: cpArrayEach is missed on 6.xx

Post by aisman »

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
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpArrayEach is missed on 6.xx

Post by slembcke »

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/
Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests