From 2abfc0518f6a2d7587d54d82b7edf26976585409 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Tue, 6 Apr 2021 19:43:51 +0100 Subject: Check for empty ConcavePolygonShape2D before checking for intersection --- servers/physics_2d/shape_2d_sw.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'servers/physics_2d/shape_2d_sw.cpp') diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index 6e7e802a8b..a74f6e2f87 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -691,6 +691,10 @@ bool ConcavePolygonShape2DSW::contains_point(const Vector2 &p_point) const { } bool ConcavePolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const { + if (segments.size() == 0 || points.size() == 0) { + return false; + } + uint32_t *stack = (uint32_t *)alloca(sizeof(int) * bvh_depth); enum { -- cgit v1.2.3