浏览代码

For optimization, assume that the scene root node does not have a moving rigid body.

Lasse Öörni 14 年之前
父节点
当前提交
57bcdb2479
共有 1 个文件被更改,包括 4 次插入6 次删除
  1. 4 6
      Engine/Physics/RigidBody.cpp

+ 4 - 6
Engine/Physics/RigidBody.cpp

@@ -424,15 +424,13 @@ void RigidBody::PostStep(float t, HashSet<RigidBody*>& processedBodies)
     inPostStep_ = true;
     inPostStep_ = true;
     
     
     // If the parent node has a rigid body, process it first
     // If the parent node has a rigid body, process it first
+    // Note: for optimization, we intentionally assume that the scene root node can not have a rigid body
     Node* parent = node_->GetParent();
     Node* parent = node_->GetParent();
-    if (parent)
+    if (parent && parent != node_->GetScene())
     {
     {
         RigidBody* parentBody = parent->GetComponent<RigidBody>();
         RigidBody* parentBody = parent->GetComponent<RigidBody>();
-        if (parentBody)
-        {
-            if (!processedBodies.Contains(parentBody))
-                parentBody->PostStep(t, processedBodies);
-        }
+        if (parentBody && !processedBodies.Contains(parentBody))
+            parentBody->PostStep(t, processedBodies);
     }
     }
     
     
     // Apply the physics transform to rendering transform now
     // Apply the physics transform to rendering transform now