In the following piece of code the polygonal object passes the bottom stationary line !!! and chipmunk does not detect the collision.
Surprisingly if we change the second dimension of the last item in vertices array to 7 then it works fine !!!!
cpVect vt[4] = {cpv(-19,5), cpv(-15,-3), cpv(10, -5), cpv(10, 5)}; ==> cpVect vt[4] = {cpv(-19,5), cpv(-15,-3), cpv(10, -5), cpv(10, 7)};
I would appreciate if someone can tell me what is wrong with my code.
Thank you
uhs
Code: Select all
staticBody = cpBodyNew(INFINITY, INFINITY);
cpResetShapeIdCounter();
space = cpSpaceNew();
cpSpaceResizeStaticHash(space, 100.0, 999);
cpSpaceResizeActiveHash(space, 100.0, 999);
space->gravity = cpv(0, -100);
cpBody *body;
cpShape *shape;
shape = cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(-320,240), 0.0f);
shape->e = 1.0; shape->u = 1.0;
cpSpaceAddStaticShape(space, shape);
shape = cpSegmentShapeNew(staticBody, cpv(320,-240), cpv(320,240), 0.0f);
shape->e = 1.0; shape->u = 1.0;
cpSpaceAddStaticShape(space, shape);
shape = cpSegmentShapeNew(staticBody,cpv(-320,-240), cpv(320,-240), 0.0f);
shape->e = 1.0; shape->u = 1.0;
cpSpaceAddStaticShape(space, shape);
cpVect vt[4] = {cpv(-19,5), cpv(-15,-3), cpv(10, -5), cpv(10, 5)}; //if we change the last 5 to 7 then it works fine !!!
body = cpBodyNew(60, cpMomentForPoly(60, 4, vt, cpvzero));
body->p = cpv(140.0,40.8);
cpSpaceAddBody(space, body);
shape = cpPolyShapeNew(body, 4, vt, cpvzero);
cpSpaceAddShape(space, shape);