Open hatsoptional opened 2 months ago
After a bit of experimentation, it seems that there's no fixed convention, but the results depend on the winding of the input polygon:
So a new proposal would be:
The operation may result in an outer polygon (boundary) and inner polygon (hole) produced which could be distinguished by calling is_polygon_clockwise. Boudaries will have the same winding direction of the input polygon and holes will have the opposite direction.
If someone with more experience on the Geometry2D classs can confirm that this is correct, I will open a PR.
Your Godot version:
4.3
Issue description:
There are some methods in the Geometry2D doc page (see URLs below) that return an
Array[PackedVector2Array]
with this indication:but without telling how to use the result from
is_polygon_clockwise
to distinguish boundaries from holes.It would be less confusing to explicitly state which convention is used by Geometry2D: are clockwise polygons used to represent holes or boundaries?
Looking through the geometry2d.cpp source, it looks like the implementation relies on the Clipper2 Lib that states:
Hoping I got everything right, the indication of the methods listed below could be changed to this:
The proposed description already flips the results of
is_polygon_clockwise
to adapt the Clipper2 Cartesian coordinates in the expected "y+ is down" screen coordinates.URL to the documentation page (if already existing): https://docs.godotengine.org/en/stable/classes/class_geometry2d.html#class-geometry2d-method-clip-polygons https://docs.godotengine.org/en/stable/classes/class_geometry2d.html#class-geometry2d-method-exclude-polygons https://docs.godotengine.org/en/stable/classes/class_geometry2d.html#class-geometry2d-method-intersect-polygons https://docs.godotengine.org/en/stable/classes/class_geometry2d.html#class-geometry2d-method-merge-polygons https://docs.godotengine.org/en/stable/classes/class_geometry2d.html#class-geometry2d-method-offset-polygon https://docs.godotengine.org/en/stable/classes/class_geometry2d.html#class-geometry2d-method-offset-polyline