diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-04-06 22:35:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 22:35:01 +0200 |
commit | 7fa84d8bd36974f622add931cb4c29302e4f6bee (patch) | |
tree | 0bae999636c0b6494803e4aa0dcdadddd321e43f | |
parent | 0d37116aeea6877054492300b82e9fd82aeee547 (diff) | |
parent | 25593a481ac3088616ed12513038fb144124a306 (diff) |
Merge pull request #47675 from madmiraal/fix-47436
Check ConvexPolygonShape2D point count before calcuating moment of inertia
-rw-r--r-- | servers/physics_2d/shape_2d_sw.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index 9b02fb692e..8343899906 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -581,6 +581,7 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vec } real_t ConvexPolygonShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const { + ERR_FAIL_COND_V_MSG(point_count == 0, 0, "Convex polygon shape has no points."); Rect2 aabb; aabb.position = points[0].pos * p_scale; for (int i = 0; i < point_count; i++) { |