summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-04-16 11:39:18 +0200
committerGitHub <noreply@github.com>2020-04-16 11:39:18 +0200
commit4f2c1feab5aa231c2b027ec7e798f2fc69dcc380 (patch)
treea55cd1aeddb3b557e019793f16ba13edbbc47032
parentbf0bfed54ae5cf5d46a922106189cbc8f70b6d79 (diff)
parent88d307df14f1d2784b49e4515fde8ea46171c54a (diff)
Merge pull request #37869 from madmiraal/fix-36533
Assign zero to range when ConvexPolygonShape2D is empty.
-rw-r--r--servers/physics_2d/shape_2d_sw.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index 48f3bea1e1..ca001e6dd9 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++) {