Skip to content

Commit d408264

Browse files
committed
Merge pull request #102778 from KoBeWi/line_zero
Prevent errors when Line2D has 0 length
2 parents be7b640 + 842421e commit d408264

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

scene/2d/line_2d.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ void Line2D::_draw() {
299299
}
300300

301301
lb.build();
302+
if (lb.indices.is_empty()) {
303+
return;
304+
}
302305

303306
RS::get_singleton()->canvas_item_add_triangle_array(
304307
get_canvas_item(),

scene/2d/line_builder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ void LineBuilder::build() {
112112
}
113113
}
114114

115+
if (Math::is_zero_approx(total_distance)) {
116+
// Zero-length line, nothing to build.
117+
return;
118+
}
119+
115120
if (_interpolate_color) {
116121
color0 = gradient->get_color(0);
117122
} else {

0 commit comments

Comments
 (0)