Skip to content

Commit

Permalink
Merge pull request #93467 from anniryynanen/progress-circle-atlas
Browse files Browse the repository at this point in the history
Fix atlas texture positioning in circular TextureProgressBar
  • Loading branch information
akien-mga committed Jun 22, 2024
2 parents ded2a4a + 2c5befd commit 04bf7d4
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions scene/gui/texture_progress_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "texture_progress_bar.h"

#include "core/config/engine.h"
#include "scene/resources/atlas_texture.h"

void TextureProgressBar::set_under_texture(const Ref<Texture2D> &p_texture) {
_set_texture(&under, p_texture);
Expand Down Expand Up @@ -513,15 +512,6 @@ void TextureProgressBar::_notification(int p_what) {
}
pts.push_back(to);

Ref<AtlasTexture> atlas_progress = progress;
bool valid_atlas_progress = atlas_progress.is_valid() && atlas_progress->get_atlas().is_valid();
Rect2 region_rect;
Size2 atlas_size;
if (valid_atlas_progress) {
region_rect = atlas_progress->get_region();
atlas_size = atlas_progress->get_atlas()->get_size();
}

Vector<Point2> uvs;
Vector<Point2> points;
for (const float &f : pts) {
Expand All @@ -530,21 +520,13 @@ void TextureProgressBar::_notification(int p_what) {
continue;
}
points.push_back(progress_offset + Point2(uv.x * s.x, uv.y * s.y));
if (valid_atlas_progress) {
uv.x = Math::remap(uv.x, 0, 1, region_rect.position.x / atlas_size.x, (region_rect.position.x + region_rect.size.x) / atlas_size.x);
uv.y = Math::remap(uv.y, 0, 1, region_rect.position.y / atlas_size.y, (region_rect.position.y + region_rect.size.y) / atlas_size.y);
}
uvs.push_back(uv);
}

// 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;
Expand Down

0 comments on commit 04bf7d4

Please sign in to comment.