Fix inconsistent Bodies.fromVertices behavior
When calling Bodies.fromVertices with an array of vertexSets in which some vertexSets are convex and some are concave, the convex vertices end up in wildly different places from the concave vertices.
See the following example, where in vectorized text, the three convex parts (making up the “i” and the “o”) are out of place with the rest of the (concave) parts, even though they were correctly positioned in the input data:
This occurs because the Bodies.fromVertices implementation sets the x, y of convex parts to the input x, y (which is the same for every part) but it sets the x, y of concave parts to the center of mass of the part.
This pull request makes the behavior consistent by ensuring every part has its position set to its center of mass, so that multiple vertexSets passed to Matter.fromVertices have their relative positions preserved.
Thanks a lot, this Pull request finally solved my problem I was having for over a week. I needed Polygons with holes and did not like the results of poly-decomp so I used another algorithm @mapbox/earcut, but the resulting vertices always were on top of each other. With this small change it works!