Browse Source

Merge pull request #39271 from RandomShaper/fix_atlas_crop

Fix excessive bottom cropping in atlas generation
Rémi Verschelde 5 years ago
parent
commit
d642cc1d70
1 changed files with 2 additions and 1 deletions
  1. 2 1
      editor/import/resource_importer_texture_atlas.cpp

+ 2 - 1
editor/import/resource_importer_texture_atlas.cpp

@@ -130,7 +130,8 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr
 	double dx_low = double(x[2] - x[1]) / (y[2] - y[1] + 1);
 	double xf = x[0];
 	double xt = x[0] + dx_upper; // if y[0] == y[1], special case
-	for (int yi = y[0]; yi <= (y[2] > height - 1 ? height - 1 : y[2]); yi++) {
+	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++) {
 				int px = xi, py = yi;