cpArrayEach 5.3.4 vs 5.3.3

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

cpArrayEach 5.3.4 vs 5.3.3

Post by aisman »

This works with 5.3.3 but no longer with 5.3.4 (Source = PureBasic syntax):

Code: Select all

cpArrayEach(*space\arbiters, @DrawCollisions(), param)
maybe the reason is the direct access to on of the PRIVATE variable (*space\arbiters)
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 5.3.4 vs 5.3.3

Post by slembcke »

I made cpArray entirely private in 6.0 as all of the instances of cpArrays have been marked as private in Chipmunk for some time now. It's also a pretty worthless structure outside of Chipmunk as I only implemented the bare minimum of what I needed.

I'm not sure if I changed anything in 5.3.4 though. I'll have to check tomorrow though.
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 5.3.4 vs 5.3.3

Post by aisman »

slembcke wrote: I'll have to check tomorrow though.
Thanks.
Some more hints for you:
The source of my part of the purebasic program is the same on both chipmunk versions.
I checked the purebasic 5.3.4 port of the chipmunk lib with the orginal 5.3.4 too but i did not find relevant changes there.

/edit
I compare the chipmunk sources and I think the 'relevant' changes been there:

Code: Select all

cpShape *
cpSpaceAddShape(cpSpace *space, cpShape *shape)
{
	cpBody *body = shape->body;
	if(!body || cpBodyIsStatic(body)) return cpSpaceAddStaticShape(space, shape);            // <<<< 5.3.4
//	if(!body || body == &space->staticBody) return cpSpaceAddStaticShape(space, shape);  // <<<< 5.3.3
But I changed this line back to 5.3.3 and is is not successful.

/edit2:
Here are an extract from the PureBasic source (you can see here the summary of called Chipmunk APIs)

Code: Select all

XIncludeFile "..\include\Chipmunk4PB_v0.4.pbi"

cpInitChipmunk()
cpResetShapeIdCounter()

;{/// PHYSIC ENVIRONMENT
*staticBody=cpBodyNew(#INFINITY, #INFINITY)
*space=cpSpaceNew()
cpv(*space\gravity, 0, 2600)
cpSpaceResizeStaticHash(*space, 30.0, 999)
cpSpaceResizeActiveHash(*space, 200.0, 99)
;}

vecA.cpVect : cpv(vecA, -200, -200)
vecB.cpVect : cpv(vecB, -200, 200)
*shape=cpSegmentShapeNew(*staticBody, vecA, vecB, 0.0)
*shape\e=1.0
*shape\u=1.0
cpSpaceAddStaticShape(*space, *shape)

Repeat
  cpSpaceHashEach(*space\activeShapes, @DrawShape(), *datas)
  cpSpaceHashEach(*space\staticShapes, @DrawShape(), *datas)
  
  cpArrayEach(*space\arbiters, @DrawCollisions(), param)
  
  ticks+1
  steps.f=3.0
  dt.f=1.0/60.0/steps
  
  For i=0 To steps
    cpSpaceStep(*space, dt)
    cpBodyUpdatePosition(*staticBody, dt)
    cpSpaceRehashStatic(*space)
  Next
Until 

End


Procedure DrawCollisions(*arbiter.cpArbiter, *datas)
  For i=0 To *arbiter\numContacts-1
    *contacts.cpContact=*arbiter\contacts+SizeOf(cpContact)*i
    Circle(*contacts\p\x, *contacts\p\y, 2, #Red)
  Next
  Debug "Collision n"
EndProcedure
kindly regards
aisman
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 5.3.4 vs 5.3.3

Post by slembcke »

No that line shouldn't have been commented out. :oops: It was a total performance bug in 5.3.4.
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 5.3.4 vs 5.3.3

Post by aisman »

slembcke wrote:No that line shouldn't have been commented out. :oops: It was a total performance bug in 5.3.4.
Sorry. I not sure what you mean?

Mean you this:

Code: Select all

cpShape *
cpSpaceAddShape(cpSpace *space, cpShape *shape)
{
	cpBody *body = shape->body;
//	if(!body || cpBodyIsStatic(body)) return cpSpaceAddStaticShape(space, shape);
	
	cpAssert(!cpHashSetFind(space->activeShapes->handleSet, shape->hashid, shape),
		"Cannot add the same shape more than once.");
	cpAssertSpaceUnlocked(space);
	
	cpBodyActivate(body);
	cpBodyAddShape(body, shape);
	
	cpShapeCacheBB(shape);
	cpSpaceHashInsert(space->activeShapes, shape, shape->hashid, shape->bb);
		
	return shape;
}
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 5.3.4 vs 5.3.3

Post by slembcke »

Correction:
That shouldn't have been commented out in 5.3.3. It was a performance bug that was fixed in 5.3.4.
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 5.3.4 vs 5.3.3

Post by aisman »

I have still the not working cpArrayEach(...) prob.
The function call is not performing.
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 5.3.4 vs 5.3.3

Post by aisman »

After some checks I belive it is a problem on my wrapper for PureBasic.
(Nativ chipmunk works correct).
Sorry for efforts.
Chipmunk4PB: The fastest way to write games together with PureBasic and the Chipmunk physics engine.
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests