Browse Source

Remove unnecessary check for physics world (2D).

aster 11 years ago
parent
commit
5ce6276b97

+ 1 - 4
Source/Engine/Physics/CollisionShape.cpp

@@ -817,10 +817,7 @@ void CollisionShape::OnNodeSet(Node* node)
                 LOGWARNING(GetTypeName() + " should not be created to the root scene node");
 
             physicsWorld_ = scene->GetOrCreateComponent<PhysicsWorld>();
-            if (physicsWorld_)
-                physicsWorld_->AddCollisionShape(this);
-            else
-                LOGERROR("No physics world component in scene, can not create collision shape");
+            physicsWorld_->AddCollisionShape(this);
         }
         else
             LOGERROR("Node is detached from scene, can not create collision shape");

+ 1 - 4
Source/Engine/Physics/Constraint.cpp

@@ -449,10 +449,7 @@ void Constraint::OnNodeSet(Node* node)
                 LOGWARNING(GetTypeName() + " should not be created to the root scene node");
 
             physicsWorld_ = scene->GetOrCreateComponent<PhysicsWorld>();
-            if (physicsWorld_)
-                physicsWorld_->AddConstraint(this);
-            else
-                LOGERROR("No physics world component in scene, can not create constraint");
+            physicsWorld_->AddConstraint(this);
         }
         else
             LOGERROR("Node is detached from scene, can not create constraint");

+ 1 - 4
Source/Engine/Physics/RigidBody.cpp

@@ -898,10 +898,7 @@ void RigidBody::OnNodeSet(Node* node)
                 LOGWARNING(GetTypeName() + " should not be created to the root scene node");
 
             physicsWorld_ = scene->GetOrCreateComponent<PhysicsWorld>();
-            if (physicsWorld_)
-                physicsWorld_->AddRigidBody(this);
-            else
-                LOGERROR("No physics world component in scene, can not create rigid body");
+            physicsWorld_->AddRigidBody(this);
 
             AddBodyToWorld();
         }

+ 0 - 5
Source/Engine/Urho2D/Constraint2D.cpp

@@ -129,11 +129,6 @@ void Constraint2D::OnNodeSet(Node* node)
     {
         Scene* scene = GetScene();
         physicsWorld_ = scene->GetOrCreateComponent<PhysicsWorld2D>();
-        if (!physicsWorld_)
-        {
-            LOGERROR("No 2D physics world component in scene, can not create constraint");
-            return;
-        }
 
         ownerBody_ = node->GetComponent<RigidBody2D>();
         if (!ownerBody_)

+ 3 - 7
Source/Engine/Urho2D/RigidBody2D.cpp

@@ -484,13 +484,9 @@ void RigidBody2D::OnNodeSet(Node* node)
         node->AddListener(this);
         Scene* scene = GetScene();
         physicsWorld_ = scene->GetOrCreateComponent<PhysicsWorld2D>();
-        if (physicsWorld_)
-        {
-            CreateBody();
-            physicsWorld_->AddRigidBody(this);
-        }
-        else
-            LOGERROR("No 2D physics world component in scene, can not create rigid body");
+        
+        CreateBody();
+        physicsWorld_->AddRigidBody(this);
     }
 }