-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geometry.is_polygon_clockwise
seems to return the opposite of expected results
#49716
Geometry.is_polygon_clockwise
seems to return the opposite of expected results
#49716
Comments
cc @Xrayez |
It looks like a bug to me. I have previously exposed this method to scripting in #28987, but I never really paid attention to result because nowadays I'm calculating polygon's signed area to determine the orientation in my code. See also #30251 which can be added as an alternative to var clockwise = Geometry.polygon_area(polygon) < 0 # aka Hole
var counter_clockwise = Geometry.polygon_area(polygon) > 0 # aka Boundary See also #53574 (comment). |
Just ran into this issue using godot 4.0.1. If |
When this was originally implemented in 16022da, the implementation treated the vertices as being in a space where the y-axis is positive in the up direction. This caused it to return the incorrect value, since Godot treats the y-axis as being positive in the down direction. All existing uses of `is_polygon_clockwise` have been updated in a way which preserves the existing behavior with the comments being updated to refer to the correct winding order. Fixes godotengine#49716.
When this was originally implemented in 16022da, the implementation treated the vertices as being in a space where the y-axis is positive in the up direction. This causes it to return the incorrect value for 2D games, since Godot treats the y-axis as being positive in the down direction. This change maintains compatibility with existing uses of `is_polygon_clockwise` by adding an optional parameter which allows the user to select which handedness their coordinate system uses. The documentation for `is_polygon_clockwise` has also been updated to describe the difference. Fixes godotengine#49716.
Godot version
v3.3.2.stable.official
System information
Windows 10, GLES3, GeForce GTX 1070/PCIe/SSE2
Issue description
The results of
Geometry.is_polygon_clockwise
seem consistent with a cartesian coordinate system where the Y axis grows upwards. However, I was under the impression that 2D graphics in Godot used a coordinate system where the Y axis grows downward, and sinceGeometry.is_polygon_clockwise
is an inherently 2D function, the results given seem to be the opposite of what I would have expected.Steps to reproduce
True
, which is not consistent with the 2D coordinate system that Godot uses with the Y axis growing downward.Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: