소스 검색

Check vertices count

Check vertices count for chain shape collision before creating fixture.
cosmy1 10 년 전
부모
커밋
444695f2a6
1개의 변경된 파일14개의 추가작업 그리고 2개의 파일을 삭제
  1. 14 2
      Source/Urho3D/Urho2D/CollisionShape2D.cpp

+ 14 - 2
Source/Urho3D/Urho2D/CollisionShape2D.cpp

@@ -222,8 +222,20 @@ void CollisionShape2D::CreateFixture()
     if (!body)
     if (!body)
         return;
         return;
 
 
-    fixture_ = body->CreateFixture(&fixtureDef_);
-    fixture_->SetUserData(this);
+    // Chain shape must have atleast two vertices before creating fixture
+    if (fixtureDef_.shape->m_type == b2Shape::e_chain)
+    {
+        if (dynamic_cast<const b2ChainShape*>(fixtureDef_.shape)->m_count >= 2)
+        {
+            fixture_ = body->CreateFixture(&fixtureDef_);
+            fixture_->SetUserData(this);
+        }
+    }
+    else
+    {
+        fixture_ = body->CreateFixture(&fixtureDef_);
+        fixture_->SetUserData(this);
+    }
 }
 }
 
 
 void CollisionShape2D::ReleaseFixture()
 void CollisionShape2D::ReleaseFixture()