Browse Source

Fix errors and crash with empty ConvexPolygonShape2D

PouleyKetchoupp 4 năm trước cách đây
mục cha
commit
6fb6090748
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      scene/resources/convex_polygon_shape_2d.cpp

+ 4 - 0
scene/resources/convex_polygon_shape_2d.cpp

@@ -72,6 +72,10 @@ void ConvexPolygonShape2D::_bind_methods() {
 }
 
 void ConvexPolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) {
+	if (points.size() < 3) {
+		return;
+	}
+
 	Vector<Color> col;
 	col.push_back(p_color);
 	RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);