Code: Select all
cpArrayEach(*space\arbiters, @DrawCollisions(), param)
Code: Select all
cpArrayEach(*space\arbiters, @DrawCollisions(), param)
Thanks.slembcke wrote: I'll have to check tomorrow though.
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
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
Sorry. I not sure what you mean?slembcke wrote:No that line shouldn't have been commented out. It was a total performance bug in 5.3.4.
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;
}
Users browsing this forum: No registered users and 12 guests