Skip to content

Commit

Permalink
Merge pull request #55094 from Giwayume/bugfix/atlas_cutoff_3.x
Browse files Browse the repository at this point in the history
[3.x] Fix texture atlas generation when source sprite is larger than generated atlas
  • Loading branch information
akien-mga authored Nov 18, 2021
2 parents b0f7212 + 0093bda commit a1ebcbc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions editor/import/resource_importer_texture_atlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
int max_y = MIN(y[2], height - p_offset.y - 1);
for (int yi = y[0]; yi < max_y; yi++) {
if (yi >= 0) {
for (int xi = (xf > 0 ? int(xf) : 0); xi < (xt < width ? xt : width - 1); xi++) {
for (int xi = (xf > 0 ? int(xf) : 0); xi < (xt < src_width ? xt : src_width - 1); xi++) {
int px = xi, py = yi;
int sx = px, sy = py;
sx = CLAMP(sx, 0, src_width - 1);
Expand All @@ -153,7 +153,7 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
p_image->set_pixel(px, py, color);
}

for (int xi = (xf < width ? int(xf) : width - 1); xi >= (xt > 0 ? xt : 0); xi--) {
for (int xi = (xf < src_width ? int(xf) : src_width - 1); xi >= (xt > 0 ? xt : 0); xi--) {
int px = xi, py = yi;
int sx = px, sy = py;
sx = CLAMP(sx, 0, src_width - 1);
Expand Down

0 comments on commit a1ebcbc

Please sign in to comment.