Skip to content

Commit

Permalink
Fixed flipped polygons not being clockwise.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Dec 23, 2023
1 parent a51ee7c commit 5126172
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -858,14 +858,23 @@ private static void ApplyFlip(uint idWithFlip, Polygon cloned)
cloned.SetPoint(i, point);
}
}
// If we flip, it needs to be made clockwise, but if we flip 2x, it automatically reverts
// back to being clockwise
var shouldMakeClockwise = false;
if (flipHorizontally)
{
shouldMakeClockwise = !shouldMakeClockwise;
cloned.FlipRelativePointsHorizontally();
}
if (flipVertically)
{
shouldMakeClockwise = !shouldMakeClockwise;
cloned.FlipRelativePointsVertically();
}
if (shouldMakeClockwise)
{
cloned.InvertPointOrder();
}
}

private static Polygon AddPolygonCloneAtXY(MapLayer layer, float tileDimension, Polygon polygon, uint[] tiles, long tilesetTileGid, int index,
Expand Down

0 comments on commit 5126172

Please sign in to comment.