From de40dfaac0918320bdca2da82b8ca8690c1af1bd Mon Sep 17 00:00:00 2001 From: BimDav Date: Mon, 14 Nov 2022 18:22:13 +0100 Subject: [PATCH] Correctly compute inverse_mass when inertia is defined by user --- servers/physics_2d/body_2d_sw.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 6f3777f3864..9540fac3374 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -44,6 +44,12 @@ void Body2DSW::update_inertias() { switch (mode) { case Physics2DServer::BODY_MODE_RIGID: { + if (mass) { + _inv_mass = 1.0 / mass; + } else { + _inv_mass = 0; + } + if (user_inertia) { _inv_inertia = inertia > 0 ? (1.0 / inertia) : 0; break; @@ -78,13 +84,6 @@ void Body2DSW::update_inertias() { } _inv_inertia = inertia > 0 ? (1.0 / inertia) : 0; - - if (mass) { - _inv_mass = 1.0 / mass; - } else { - _inv_mass = 0; - } - } break; case Physics2DServer::BODY_MODE_KINEMATIC: case Physics2DServer::BODY_MODE_STATIC: {