diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index d165d477f84..f27d729e21d 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -299,6 +299,9 @@ void Line2D::_draw() { } lb.build(); + if (lb.indices.is_empty()) { + return; + } RS::get_singleton()->canvas_item_add_triangle_array( get_canvas_item(), diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp index ea949712ee2..4a092675c98 100644 --- a/scene/2d/line_builder.cpp +++ b/scene/2d/line_builder.cpp @@ -112,6 +112,11 @@ void LineBuilder::build() { } } + if (Math::is_zero_approx(total_distance)) { + // Zero-length line, nothing to build. + return; + } + if (_interpolate_color) { color0 = gradient->get_color(0); } else {