-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Added Geometry2D unit tests #44274
Added Geometry2D unit tests #44274
Conversation
df69193
to
318e02d
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!
Boolean methods cover the documented functionality, as I recall (so is the rest I presume). 🙂
318e02d
to
6bb15e2
Compare
So turns out I also converted the plain asserts in the polygon tests to subcases. |
There's a better and more efficient implementation in Goost (ported from Clipper's code currently used by boolean methods in Godot): https://github.com/goostengine/goost/blob/gd3/core/math/2d/geometry/goost_geometry_2d.cpp#L165-L212, the implementation treats those cases separately by returning 0 if outside, 1 if inside, and -1 if a point is exactly on the edge. So yeah that's something which can be done, I recall @reduz wasn't against the general idea but he still had doubts whether it's worth to replace the implementation last time we talked about this... Some IRC logs months ago:
|
Recent report for this #44717. 🙂 |
6bb15e2
to
060b70e
Compare
@akien-mga Rebased and updated. As discussed on IRC i did 2 more changes:
|
Needs another rebase now that the |
060b70e
to
1bfb5fb
Compare
Done, but now
Bug report with an official response from the MSVC developers: https://developercommunity.visualstudio.com/content/problem/961455/spurious-c4723-warning.html |
7a15321
to
c1cf88c
Compare
I wasn't able to fix the |
I think you can disable the warning around the problematic code with: #ifdef _MSC_VER
// False positive, we correctly check for zero earlier.
#pragma warning ( push )
#pragma warning ( disable C4723 )
#endif
// Problematic code
#ifdef _MSC_VER
#pragma warning ( pop )
#endif See https://docs.microsoft.com/en-us/cpp/preprocessor/warning?view=msvc-160 |
c1cf88c
to
e455ca2
Compare
That's better and works, but i had to disable the warning before the function definition and re-enable it afterwards. |
Thanks! |
Some functions are not completely unit-testable, because the results are not always either right or wrong (e.g.
make_atlas
or thetriangulate_*
functions can have many correct results). Some are also not tested yet, but this should be good for now (feel free to add more tests in seperate PRs). I included the complete list of tested functions below.Part of #43440
Tests included in this PR
Not tested:
cc @Calinou @Xrayez for review if you have time 🙂