From 158c7c72c741ad58f22dfdcade74d4e893cd33c5 Mon Sep 17 00:00:00 2001 From: Crazy-P Date: Thu, 12 Apr 2018 18:15:34 +0800 Subject: [PATCH] Resolves crash on shape2D culling for empty Concave shapes Fixes https://github.com/godotengine/godot/issues/17789 --- servers/physics_2d/shape_2d_sw.cpp | 4 ++++ servers/physics_2d/space_2d_sw.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index 433942708e5..2b0eab59997 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -1011,6 +1011,10 @@ void ConcavePolygonShape2DSW::cull(const Rect2 &p_local_aabb, Callback p_callbac stack[i]=0; */ + if (segments.size() == 0 || points.size() == 0 || bvh.size() == 0) { + return; + } + int level = 0; const Segment *segmentptr = &segments[0]; diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index c29093d1af8..503ca0af4a8 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -33,6 +33,7 @@ #include "collision_solver_2d_sw.h" #include "pair.h" #include "physics_2d_server_sw.h" + _FORCE_INLINE_ static bool _can_collide_with(CollisionObject2DSW *p_object, uint32_t p_collision_mask) { return p_object->get_collision_layer() & p_collision_mask;