浏览代码

Merge pull request #9947 from RandomShaper/fix-polygon2d-single-color-2.1

Add special handling for single-color Polygon2D (2.1)
George Marques 8 年之前
父节点
当前提交
ac9c4f44a9
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      scene/2d/polygon_2d.cpp

+ 7 - 2
scene/2d/polygon_2d.cpp

@@ -165,8 +165,13 @@ void Polygon2D::_notification(int p_what) {
 
 			Vector<Color> colors;
 			int color_len = vertex_colors.size();
-			colors.resize(len);
-			{
+			if (color_len == 0) {
+				// No vertex colors => Pass only the main color
+				// The rasterizer handles this case especially, taking alpha into account
+				colors.push_back(color);
+			} else {
+				// Vertex colors present => Fill color array and pad with main color as necessary
+				colors.resize(len);
 				DVector<Color>::Read color_r = vertex_colors.read();
 				for (int i = 0; i < color_len && i < len; i++) {
 					colors[i] = color_r[i];