From 3e71992eda72ac4bbd683a822a017dd5d45287a6 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Tue, 14 Apr 2020 12:40:24 +0100 Subject: [PATCH] Assign zero to range when ConvexPolygonShape2D is empty. (cherry picked from commit 88d307df14f1d2784b49e4515fde8ea46171c54a) --- servers/physics_2d/shape_2d_sw.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h index a336dcecf51..f1e8b0541bd 100644 --- a/servers/physics_2d/shape_2d_sw.h +++ b/servers/physics_2d/shape_2d_sw.h @@ -465,7 +465,11 @@ public: virtual Variant get_data() const; _FORCE_INLINE_ void project_range(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { - // no matter the angle, the box is mirrored anyway + + if (!points || point_count <= 0) { + r_min = r_max = 0; + return; + } r_min = r_max = p_normal.dot(p_transform.xform(points[0].pos)); for (int i = 1; i < point_count; i++) {