BGE patch #18051: add localInertia attribute to GameObject.
[blender.git] / source / gameengine / Ketsji / KX_BulletPhysicsController.cpp
index 062e9f7df503ac14a7e8da81dd9db1d3262f9469..c621f11994abd5fadb77878e1a1585dbbe0108e0 100644 (file)
@@ -162,6 +162,20 @@ MT_Scalar  KX_BulletPhysicsController::GetMass()
 
 }
 
+MT_Vector3 KX_BulletPhysicsController::GetLocalInertia()
+{
+    MT_Vector3 inertia(0.f, 0.f, 0.f);
+    btVector3 inv_inertia;
+    if (GetRigidBody()) {
+        inv_inertia = GetRigidBody()->getInvInertiaDiagLocal();
+               if (!btFuzzyZero(inv_inertia.getX()) && 
+                       !btFuzzyZero(inv_inertia.getY()) && 
+                       !btFuzzyZero(inv_inertia.getZ()))
+                       inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ());
+    }
+    return inertia;
+}
+
 MT_Scalar KX_BulletPhysicsController::GetRadius()
 {
        return MT_Scalar(CcdPhysicsController::GetRadius());
@@ -417,13 +431,14 @@ void      KX_BulletPhysicsController::SetSumoTransform(bool nondynaonly)
        {
                if (!nondynaonly)
                {
+                       /*
                        btTransform worldTrans;
                        if (GetRigidBody())
                        {
                                GetRigidBody()->getMotionState()->getWorldTransform(worldTrans);
                                GetRigidBody()->setCenterOfMassTransform(worldTrans);
                        }
-                       
+                       */
                        /*
                        scaling?
                        if (m_bDyna)