summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Admiraal <madmiraal@users.noreply.github.com>2021-04-06 19:11:40 +0100
committerMarcel Admiraal <madmiraal@users.noreply.github.com>2021-04-06 19:15:09 +0100
commit25593a481ac3088616ed12513038fb144124a306 (patch)
tree28e22c9a547687bf21aee7b174d4474652049a43
parent55faf1c874fae5b67928395d3a35889bbb4e458b (diff)
Check ConvexPolygonShape2D point count before calcuating moment of inertia
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp1
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 6e7e802a8b..4923b61e68 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -580,6 +580,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++) {