-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix vector normalization in epaint/tessellator/add_line_loop. #5364
Conversation
Preview available at https://egui-pr-preview.github.io/pr/5364-normalization-fix |
Seems like this causes a couple small differences in the snapshot tests, the biggest one is visible in the rendering test: Bildschirmaufnahme.2024-11-11.um.14.28.34.movAnd some minor differences in the bezier test: Bildschirmaufnahme.2024-11-11.um.14.29.26.movNot sure which versions are more correct though, just wanted to share the differences I noted. Here is a link to the snapshot test results: https://github.com/emilk/egui/actions/runs/11778645510/artifacts/2171312779 @PangolinGiLA You'll need to run the tests with |
@@ -470,7 +470,7 @@ impl Path { | |||
self.add_point(points[i], n1c / n1c.length_sq()); | |||
} else { | |||
// miter join | |||
self.add_point(points[i], normal / length_sq); | |||
self.add_point(points[i], normal.normalized()); |
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.
Dividing with length-squared is what gets the correct widths for a miter-joins. If this fails for some angles, let's figure out why. The CUT_OFF_SHARP_CORNERS
is meant to catch this problem.
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.
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.
Oh I just read the issue linked in the code. I guess i should have done a little bit more research before opening the PR.
I would love to have a proper solution to this problem, but this PR isn't it |
In epaint/tessellator/add_line_loop normal vectors of added points were not normalized correctly, they were divided by length squared, what caused their length to explode for some points close together.
Before:
After: