unsigned int physics_shape_add_poly(Entity ent, unsigned int nverts, const Vec2 *verts, Scalar r) { unsigned int i; cpVect *cpverts; cpShape *shape; cpverts = malloc(nverts * sizeof(cpVect)); for (i = 0; i < nverts; ++i) cpverts[i] = cpv_of_vec2(verts[i]); nverts = cpConvexHull(nverts, cpverts, NULL, NULL, 0); shape = cpPolyShapeNew2(NULL, nverts, cpverts, cpvzero, r); free(cpverts); return _shape_add(ent, PS_POLYGON, shape); }
cpShape * cpPolyShapeNew(cpBody *body, int numVerts, const cpVect *verts, cpVect offset) { return cpPolyShapeNew2(body, numVerts, verts, offset, 0.0f); }