Browse Source

Add special handling for single-color Polygon2D

Fixes #6060.
Pedro J. Estébanez 8 years ago
parent
commit
db3c1e83e7
1 changed files with 7 additions and 2 deletions
  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];