-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Replace Clipper1 library by Clipper2 library #90153
Replace Clipper1 library by Clipper2 library #90153
Conversation
You can replace the Clipper XYZ_64 classes with the Clipper D class equivalents. Those do the same except that they allow for direct float input that gets up- and downscaled to the integer grid internally. So the old Clipper1 manual scaling with SCALE_FACTOR can be removed. I did a similar upgrade for the 2D navigation mesh baking as an example with PR #89929 here. The manual Rect clipping in the sprite editor can also be replaced by the "real" RectD Clip of Clipper2 which is far more performant see https://angusj.com/clipper2/Docs/Units/Clipper/Functions/RectClip.htm |
What's about #29886? |
This PR should imo stay focus on only the upgrade so it can be added without much issues and bike-shed. Adding new parameters is feature territory as it creates compatibility issues. It is likely that there is need for a more general rework of the Geometry2D boolean ops later which would be a good place for this and other features. E.g. the single polygon per function limit comes to mind. It is kinda arbitrary as Clipper2 can do way more. |
777cd31
to
faa9614
Compare
@smix8 Thanks for the tips! I used the D variants of Clipper functions/types now, and used
Should we actually be using Edit: I see I should be using the |
e7b0d83
to
d0e7907
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for the Clipper2 replacements.
Not really a 2D and sprite editor user so can't say if there are some subtle differences in the results that could cause some compatibility problems for older projects.
I'm using Geometry2D for merging polygons and this change makes my tool a few times slower. Here's a test scene: This was already discussed in the chat, I thought I'd mention it here for the record. |
d0e7907
to
8a28f81
Compare
Here is an image that explains why it was slower: I have now added clp.PreserveCollinear(false); // Remove redundant vertices. to make the resulting polygon the same as it was with Clipper1 (i.e. having just the corner vertices).
Edit: In a release build (or a non-dev editor build) there is now no measurable performance difference when running @KoBeWi's project. |
In dev build my code runs 10ms slower on average, but it's acceptable in this case. |
Thanks! |
Reduces release template binary size (by 54.1 kB on Linux).
To-do:
Fixes #90103