Skip to content
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 TextureProgressBar radial mode invalid polygon edge case #92901

Conversation

kleonc
Copy link
Member

@kleonc kleonc commented Jun 8, 2024

TextureProgressBar::unit_val_to_uv(float val) can produce exactly the same UV for almost equal values. Currently subsequent points on the TextureProgressBar's edge mapped to the same UV would be skipped, which can lead to trying to create a 2-point polygon created from from and center (in case to would be skipped because it is close enough to from so unit_val_to_uv(from) == unit_val_to_uv(to)).

for (const float &f : pts) {
Point2 uv = unit_val_to_uv(f);
if (uvs.has(uv)) {
continue;
}

This PR leaves skipping same-UV points as is, and just ensure points.size() >= 3 before rendering a polygon.

Alternative would be to try improve precision/robustness of TextureProgressBar::unit_val_to_uv(float val) but it's probably not needed as the issue happens in an edge case (a super thin triangle which would likely not be rendered anyway).

Fixes #92790.

@kleonc kleonc added bug topic:gui cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Jun 8, 2024
@kleonc kleonc added this to the 4.3 milestone Jun 8, 2024
@kleonc kleonc requested a review from a team as a code owner June 8, 2024 12:01
@akien-mga akien-mga merged commit 034e579 into godotengine:master Jun 11, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@kleonc kleonc deleted the texture-progress-bar-fix-radial-mode-2-point-polygon-edge-case branch June 11, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release topic:gui
Projects
None yet
3 participants