Browse Source

Merge pull request #55095 from Giwayume/bugfix/atlas_cutoff_master

Fix texture atlas generation when source sprite is larger than generated atlas
Rémi Verschelde 3 years ago
parent
commit
84f59c60b0
1 changed files with 2 additions and 2 deletions
  1. 2 2
      editor/import/resource_importer_texture_atlas.cpp

+ 2 - 2
editor/import/resource_importer_texture_atlas.cpp

@@ -134,7 +134,7 @@ static void _plot_triangle(Vector2i *vertices, const Vector2i &p_offset, bool p_
 	int max_y = MIN(y[2], height - p_offset.y - 1);
 	int max_y = MIN(y[2], height - p_offset.y - 1);
 	for (int yi = y[0]; yi < max_y; yi++) {
 	for (int yi = y[0]; yi < max_y; yi++) {
 		if (yi >= 0) {
 		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 px = xi, py = yi;
 				int sx = px, sy = py;
 				int sx = px, sy = py;
 				sx = CLAMP(sx, 0, src_width - 1);
 				sx = CLAMP(sx, 0, src_width - 1);
@@ -156,7 +156,7 @@ static void _plot_triangle(Vector2i *vertices, const Vector2i &p_offset, bool p_
 				p_image->set_pixel(px, py, color);
 				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 px = xi, py = yi;
 				int sx = px, sy = py;
 				int sx = px, sy = py;
 				sx = CLAMP(sx, 0, src_width - 1);
 				sx = CLAMP(sx, 0, src_width - 1);