void PhysicsShapePolygon::updateScale()
{
    cpFloat factorX = _newScaleX / _scaleX;
    cpFloat factorY = _newScaleY / _scaleY;

    auto shape = _cpShapes.front();
    int count = cpPolyShapeGetCount(shape);
    cpVect* vects = new cpVect[count];
    for(int i=0;i<count;++i)
        vects[i] = cpPolyShapeGetVert(shape, i);

    for (int i = 0; i < count; ++i)
    {
        vects[i].x *= factorX;
        vects[i].y *= factorY;
    }

    // convert hole to clockwise
    if (factorX * factorY < 0)
    {
        for (int i = 0; i < count / 2; ++i)
        {
            cpVect v = vects[i];
            vects[i] = vects[count - i - 1];
            vects[count - i - 1] = v;
        }
    }
    
    cpPolyShapeSetVertsRaw(shape, count, vects);
    CC_SAFE_DELETE_ARRAY(vects);
    
    PhysicsShape::updateScale();
}
void
cpPolyShapeSetVerts(cpShape *shape, int count, cpVect *verts, cpTransform transform)
{
	cpVect *hullVerts = (cpVect *)alloca(count*sizeof(cpVect));
	
	// Transform the verts before building the hull in case of a negative scale.
	for(int i=0; i<count; i++) hullVerts[i] = cpTransformPoint(transform, verts[i]);
	
	unsigned int hullCount = cpConvexHull(count, hullVerts, hullVerts, NULL, 0.0);
	cpPolyShapeSetVertsRaw(shape, hullCount, hullVerts);
}