Merge pull request #68659 from BimDav/user_inertia

Correctly compute inverse_mass when inertia is defined by the user
This commit is contained in:
Rémi Verschelde 2022-11-14 23:51:45 +01:00
commit 032190fb92
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -44,6 +44,12 @@ void Body2DSW::update_inertias() {
switch (mode) { switch (mode) {
case Physics2DServer::BODY_MODE_RIGID: { case Physics2DServer::BODY_MODE_RIGID: {
if (mass) {
_inv_mass = 1.0 / mass;
} else {
_inv_mass = 0;
}
if (user_inertia) { if (user_inertia) {
_inv_inertia = inertia > 0 ? (1.0 / inertia) : 0; _inv_inertia = inertia > 0 ? (1.0 / inertia) : 0;
break; break;
@ -78,13 +84,6 @@ void Body2DSW::update_inertias() {
} }
_inv_inertia = inertia > 0 ? (1.0 / inertia) : 0; _inv_inertia = inertia > 0 ? (1.0 / inertia) : 0;
if (mass) {
_inv_mass = 1.0 / mass;
} else {
_inv_mass = 0;
}
} break; } break;
case Physics2DServer::BODY_MODE_KINEMATIC: case Physics2DServer::BODY_MODE_KINEMATIC:
case Physics2DServer::BODY_MODE_STATIC: { case Physics2DServer::BODY_MODE_STATIC: {