Browse Source

Update rigid body's inertia tensor whenever its transform is forcibly changed, or when it is re-added to the world.

Lasse Öörni 13 years ago
parent
commit
f6ca98e0c9
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Engine/Physics/RigidBody.cpp

+ 4 - 0
Engine/Physics/RigidBody.cpp

@@ -208,6 +208,7 @@ void RigidBody::SetPosition(Vector3 position)
         btTransform interpTrans = body_->getInterpolationWorldTransform();
         interpTrans.setOrigin(worldTrans.getOrigin());
         body_->setInterpolationWorldTransform(interpTrans);
+        body_->updateInertiaTensor();
         
         Activate();
         MarkNetworkUpdate();
@@ -225,6 +226,7 @@ void RigidBody::SetRotation(Quaternion rotation)
         btTransform interpTrans = body_->getInterpolationWorldTransform();
         interpTrans.setRotation(worldTrans.getRotation());
         body_->setInterpolationWorldTransform(interpTrans);
+        body_->updateInertiaTensor();
         
         Activate();
         MarkNetworkUpdate();
@@ -244,6 +246,7 @@ void RigidBody::SetTransform(const Vector3& position, const Quaternion& rotation
         interpTrans.setOrigin(worldTrans.getOrigin());
         interpTrans.setRotation(worldTrans.getRotation());
         body_->setInterpolationWorldTransform(interpTrans);
+        body_->updateInertiaTensor();
         
         Activate();
         MarkNetworkUpdate();
@@ -672,6 +675,7 @@ void RigidBody::UpdateMass()
         if (mass_ > 0.0f)
             compoundShape_->calculateLocalInertia(mass_, localInertia);
         body_->setMassProps(mass_, localInertia);
+        body_->updateInertiaTensor();
     }
 }