Open 0XDE57 opened 1 year ago
item drops for asteroids are not centered, they spawn off center.
problem was wrong origin for box2d body vs point (highlighted green is correct center origin, highlighted purple is incorrect off-center origin)
the fix was to shift the points that define the hull by the polygon centroid:
//shift vertices to be centered around 0,0 relatively Vector2 center = new Vector2(); GeometryUtils.polygonCentroid(hull, 0, hull.length, center); for (int j = 0; j < hull.length; j += 2) { hull[j] -= center.x; hull[j + 1] -= center.y; }
this fixes the issue:
but this now causes issue #2 to happen in every case
NOTE: the child polygon origin is still incorrect!
only the drops spawn location is now correct relative to the polygon.
item drops for asteroids are not centered, they spawn off center.
problem was wrong origin for box2d body vs point (highlighted green is correct center origin, highlighted purple is incorrect off-center origin)
the fix was to shift the points that define the hull by the polygon centroid:
this fixes the issue:
but this now causes issue #2 to happen in every case