summaryrefslogtreecommitdiff
path: root/servers/physics_2d
diff options
context:
space:
mode:
authorJosh Grams <josh@qualdan.com>2016-04-20 20:49:37 -0400
committerJosh Grams <josh@qualdan.com>2016-04-20 20:49:37 -0400
commitf7d31cec38c795909c4d1e0917f54aa118d380d7 (patch)
tree842bb5cd786dbce408bb7f5c563a9502542c05eb /servers/physics_2d
parentdbabe4c07cd9c0d825c14b961bd472f77e525162 (diff)
RigidBody2D: add and bind get_inertia() method.
You can't set this value very well, since it's automatically computed from the mass and the collision shapes. But since the values are higher than many people might suspect, so being able to read it helps estimate the amount of torque you might need to apply.
Diffstat (limited to 'servers/physics_2d')
-rw-r--r--servers/physics_2d/body_2d_sw.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index ab1c7ef66f..97f08a6aa3 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -186,6 +186,10 @@ float Body2DSW::get_param(Physics2DServer::BodyParameter p_param) const {
case Physics2DServer::BODY_PARAM_MASS: {
return mass;
} break;
+ case Physics2DServer::BODY_PARAM_INERTIA: {
+ if(_inv_inertia == 0) return INFINITY;
+ else return 1.0 / _inv_inertia;
+ } break;
case Physics2DServer::BODY_PARAM_GRAVITY_SCALE: {
return gravity_scale;
} break;