Code: Select all
ps->space = cpSpaceNew( )
cpSpaceResizeStaticHash( ps->space, size, count )
cpSpaceResizeActiveHash( ps->space, size, count )
ps->space->iterations = iterations
ps->staticbody = cpBodyNew( INFINITY, INFINITY )
' ... Sometime later in the code ...
var points = child->values/2
dim pnt(0 to points-1) as cpVect
for i = 0 to points-1
pnt(i).x = cdbl( *child->value[i*2] ) : pnt(i).y = cdbl( *child->value[(i*2)+1] )
next i
var tbody = cpBodyNew( mass, cpMomentForPoly( mass, points, @pnt(0), cpvzero ) )
tbody->p = center
var tshape = cpPolyShapeNew( tbody, points, @pnt(0), cpvzero )
tshape->e = e
tshape->u = f
tshape->group = group
cpSpaceAddBody( ps->space, tbody )
cpSpaceAddShape( ps->space, tshape )
When I put segments and circles into the simulation, there is absolutely no problem.
Any help would be nice. If you need to see more code, I can post more.
Thanks,
-Oz
:: EDIT ::
I should mention the size and count are 30 and 1000, respectively
::EDIT ::
I just ran a few more tests, and it seems that the polygon's collision detection is really random/not reliable. seems to collide when the shape/collision is on certain angles, but not always. Is this a chipmunk bug?