summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2021-03-04 09:46:32 -0700
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2021-03-04 09:46:32 -0700
commit6fb609074895b8681cc42af866782e4963567a23 (patch)
treebe51d4be75d24677be3a605677466a1f588d1d6f
parentf01e95eb55b9798becc47a697f83515c737b5bf3 (diff)
Fix errors and crash with empty ConvexPolygonShape2D
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index d331f83daf..6e56f6e7fc 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/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);