Browse Source

Only apply world transform for active and awake rigid body.

aster2013 10 years ago
parent
commit
1ab328db34
2 changed files with 13 additions and 2 deletions
  1. 2 0
      Source/Urho3D/Urho2D/PhysicsWorld2D.cpp
  2. 11 2
      Source/Urho3D/Urho2D/RigidBody2D.cpp

+ 2 - 0
Source/Urho3D/Urho2D/PhysicsWorld2D.cpp

@@ -226,6 +226,8 @@ void PhysicsWorld2D::DrawTransform(const b2Transform& xf)
 
 void PhysicsWorld2D::Update(float timeStep)
 {
+	PROFILE(UpdatePhysics2D);
+
     using namespace PhysicsPreStep2D;
 
     VariantMap& eventData = GetEventDataMap();

+ 11 - 2
Source/Urho3D/Urho2D/RigidBody2D.cpp

@@ -393,8 +393,17 @@ void RigidBody2D::ReleaseBody()
 
 void RigidBody2D::ApplyWorldTransform()
 {
-    if (!body_)
-        return;
+	if (!body_)
+		return;
+
+	if (!body_->IsActive())
+		return; 
+	
+	if (body_->GetType() == b2_staticBody)
+		return;
+
+	if (!body_->IsAwake())
+		return;
 
     physicsWorld_->SetApplyingTransforms(true);