From a3f4bd96c5bb389fcde886b036aceefbc132ed98 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Tue, 6 Apr 2021 16:18:16 +0100 Subject: [PATCH] Ensure ConvexPolygonShape support count variable is initialised (cherry picked from commit 0d4d8925b7ebaf608e0b3c2abf0d8213d9ce95f7) --- servers/physics_2d/shape_2d_sw.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index 8217da048dc..4dee5a7b8c1 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -543,6 +543,7 @@ void ConvexPolygonShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_su int support_idx = -1; real_t d = -1e10; + r_amount = 0; for (int i = 0; i < point_count; i++) { @@ -563,7 +564,7 @@ void ConvexPolygonShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_su } } - ERR_FAIL_COND(support_idx == -1); + ERR_FAIL_COND_MSG(support_idx == -1, "Convex polygon shape support not found."); r_amount = 1; r_supports[0] = points[support_idx].pos;