Jelajahi Sumber

Merge pull request #36564 from dankan1890/quick_fix

Fixed TextureAtlas import size.
Rémi Verschelde 5 tahun lalu
induk
melakukan
afa773f388
1 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 4 4
      editor/import/resource_importer_texture_atlas.cpp

+ 4 - 4
editor/import/resource_importer_texture_atlas.cpp

@@ -143,8 +143,8 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
 
 				int px = xi, py = yi;
 				int sx = px, sy = py;
-				sx = CLAMP(sx, 0, src_width);
-				sy = CLAMP(sy, 0, src_height);
+				sx = CLAMP(sx, 0, src_width - 1);
+				sy = CLAMP(sy, 0, src_height - 1);
 				Color color = p_src_image->get_pixel(sx, sy);
 				if (p_transposed) {
 					SWAP(px, py);
@@ -165,8 +165,8 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
 			for (int xi = (xf < width ? int(xf) : width - 1); xi >= (xt > 0 ? xt : 0); xi--) {
 				int px = xi, py = yi;
 				int sx = px, sy = py;
-				sx = CLAMP(sx, 0, src_width);
-				sy = CLAMP(sy, 0, src_height);
+				sx = CLAMP(sx, 0, src_width - 1);
+				sy = CLAMP(sy, 0, src_height - 1);
 				Color color = p_src_image->get_pixel(sx, sy);
 				if (p_transposed) {
 					SWAP(px, py);