Open SteveSmith16384 opened 1 year ago
This was solved on reddit. A careful look at the coordinates reveals that this is an anticlockwise polygon. It thus considers the point, which is on the exact edge (adding to the confusion), to be outside the inverted polygon.
Thanks. IMHO, the documentation should be updated though; AFAICS it makes no mention of clockwise or anticlockwise or that they are even a thing to know about.
This was solved on reddit. A careful look at the coordinates reveals that this is an anticlockwise polygon. It thus considers the point, which is on the exact edge (adding to the confusion), to be outside the inverted polygon.
For reference: reddit thread.
@TheDuriel It's not solved. Even if it's intended to consider the edges to be a part of / not be a part of the polygon based on the winding order then it still seems to be bugged for the corners/vertices:
Hence it's not just a matter of documenting it.
It's a 3.x
-only issue. In master
(v4.0.beta7.official [0bb1e89fb]) all points on the edges (including corners/vertices) seem to properly be considered as inside the polygon. It was changed as a part of #52110, and intentionally no backported to 3.x
to avoid potential regressions.
Godot version
3.5.1
System information
Linux Mint
Issue description
Geometry.is_point_in_polygon() returns an incorrect result in the example below where the polygon points are clockwise, but works if I invert the points.
Steps to reproduce
I'm running the following code:-
As far as I can see, "result" should be true since (0, 1) is inside this polygon (which is just a rectangle) but it returns false.
If I add:-
It now returns true, which is correct.
Minimal reproduction project
n/a - See example code above