emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.53k stars 1.61k forks source link

Fix vector normalization in epaint/tessellator/add_line_loop. #5364

Closed PangolinGiLA closed 1 week ago

PangolinGiLA commented 2 weeks ago

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: before

After: after

github-actions[bot] commented 2 weeks ago

Preview available at https://egui-pr-preview.github.io/pr/5364-normalization-fix Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

lucasmerlin commented 2 weeks ago

Seems like this causes a couple small differences in the snapshot tests, the biggest one is visible in the rendering test: (the thinner one is the new, updated snapshot)

https://github.com/user-attachments/assets/c1a91aee-62ba-43bd-ac2e-6c37cd8b3332

And some minor differences in the bezier test: (the one where the top green line is more faint is the new one) Also, notice how the triangle to close the window seems slightly worse antialiased.

https://github.com/user-attachments/assets/dbdd314a-3029-40e8-bb5b-0a6638b7dd88

Not 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 UPDATE_SNAPSHOTS=true to update the snapshots before we can merge this

emilk commented 1 week ago

I would love to have a proper solution to this problem, but this PR isn't it