-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Remove polyline offset duplicates #91627
Remove polyline offset duplicates #91627
Conversation
Clipper2 has the |
The TrimCollinear function is around 50 lines that allows a decimal precision to be used to determine a more approximate equality of position. This inexact equality test is not needed to solve this bug which only manifests if the vertices are exactly the same. I had a look at the PreserveCollinear property of the ClipperOffset class and it looks like to get access to it we'd have to basically copy-paste the whole InflatePaths interface function to add that setting. Both of these solutions seem like overkill in the context of this bug and its solution. TrimCollinear in particular is just doing what I'm doing with extra (unnecessary) steps. Replicating InflatePaths also seems to me like adding a bunch of extra code for little benefit. I'll make a version that copy-pastes InflatePaths and we'll see which is preferred. The existing code already passes across the entire array to copy and cast the vertices back into godot types. |
Makes sense, thanks for looking into it. Should imo pick whatever solution works better for performance at scale. Performance regression was one of the concerns with the update #90153 from Clipper1 to Clipper2 and why certain Clipper2 features were toggled. I don't expect you to do all the performance testing yourself as a first-time contributor but someone should imo do it so an informed decision can be made what to pick. Not relevant for this PR but the convex decompose function has general issues with dirty input that includes duplicates that might be worth fixing in a central place on the decompose input, else we end up with x-amount of mostly duplicated fix-me functions across the engine. |
Unrelated but I'm seeing a very large performance degradation when decomposing polygons generated by inflating with END_ROUND set vs v4.2. That's a different issue though. |
Here's the conclusion of my investigation: Reducing the precision parameter from Godot's default of 5 to clipper2's default of 2 eliminates duplicate points even when PreserveCollinear is true. It also gives a (subjectively) noticeable performance boost even when using END_ROUND which will freeze my PC at precision 5. I've created a new, even smaller pull request that implements this. |
Fixes #91607 by removing duplicates generated by InflatePaths so that it doesn't cause decompose_polygon_in_convex to fail.