summaryrefslogtreecommitdiffstats
path: root/scene/gui/texture_progress_bar.cpp
diff options
context:
space:
mode:
authorkleonc <9283098+kleonc@users.noreply.github.com>2024-06-08 13:51:32 +0200
committerkleonc <9283098+kleonc@users.noreply.github.com>2024-06-08 13:51:32 +0200
commit7f6951b1f637e509d7849421f1402d94975b753e (patch)
tree55df6603312a5d412af7907b568a15a938bdced1 /scene/gui/texture_progress_bar.cpp
parent1ce6df7087113a61491567f3ac55561d5688e2a8 (diff)
downloadredot-engine-7f6951b1f637e509d7849421f1402d94975b753e.tar.gz
Fix TextureProgressBar radial mode invalid polygon edge case
Diffstat (limited to 'scene/gui/texture_progress_bar.cpp')
-rw-r--r--scene/gui/texture_progress_bar.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp
index dc48945d9b..3c3e6cd30c 100644
--- a/scene/gui/texture_progress_bar.cpp
+++ b/scene/gui/texture_progress_bar.cpp
@@ -537,17 +537,20 @@ void TextureProgressBar::_notification(int p_what) {
uvs.push_back(uv);
}
- Point2 center_point = get_relative_center();
- points.push_back(progress_offset + s * center_point);
- if (valid_atlas_progress) {
- center_point.x = Math::remap(center_point.x, 0, 1, region_rect.position.x / atlas_size.x, (region_rect.position.x + region_rect.size.x) / atlas_size.x);
- center_point.y = Math::remap(center_point.y, 0, 1, region_rect.position.y / atlas_size.y, (region_rect.position.y + region_rect.size.y) / atlas_size.y);
- }
- uvs.push_back(center_point);
+ // Filter out an edge case where almost equal `from`, `to` were mapped to the same UV.
+ if (points.size() >= 2) {
+ Point2 center_point = get_relative_center();
+ points.push_back(progress_offset + s * center_point);
+ if (valid_atlas_progress) {
+ center_point.x = Math::remap(center_point.x, 0, 1, region_rect.position.x / atlas_size.x, (region_rect.position.x + region_rect.size.x) / atlas_size.x);
+ center_point.y = Math::remap(center_point.y, 0, 1, region_rect.position.y / atlas_size.y, (region_rect.position.y + region_rect.size.y) / atlas_size.y);
+ }
+ uvs.push_back(center_point);
- Vector<Color> colors;
- colors.push_back(tint_progress);
- draw_polygon(points, colors, uvs, progress);
+ Vector<Color> colors;
+ colors.push_back(tint_progress);
+ draw_polygon(points, colors, uvs, progress);
+ }
}
// Draw a reference cross.