Browse Source

Delay call Drawable2D::GetVertices.

aster2013 11 years ago
parent
commit
c52d2e35d5
1 changed files with 11 additions and 8 deletions
  1. 11 8
      Source/Engine/Urho2D/DrawableProxy2D.cpp

+ 11 - 8
Source/Engine/Urho2D/DrawableProxy2D.cpp

@@ -216,21 +216,24 @@ void DrawableProxy2D::HandleBeginViewUpdate(StringHash eventType, VariantMap& ev
     if (camera->IsOrthographic() && camera->GetNode()->GetWorldDirection() == Vector3::FORWARD)
     if (camera->IsOrthographic() && camera->GetNode()->GetWorldDirection() == Vector3::FORWARD)
     {
     {
         // Define bounding box with min and max points
         // Define bounding box with min and max points
-        frustumBoundingBox_.Define(frustum_->vertices_[2], frustum_->vertices_[4]); 
+        frustumBoundingBox_.Define(frustum_->vertices_[2], frustum_->vertices_[4]);
         frustum_ = 0;
         frustum_ = 0;
     }
     }
 
 
     for (unsigned i = 0; i < drawables_.Size(); ++i)
     for (unsigned i = 0; i < drawables_.Size(); ++i)
     {
     {
-        Material* usedMaterial = drawables_[i]->GetUsedMaterial();
-        const Vector<Vertex2D>& vertices = drawables_[i]->GetVertices();
-        if (drawables_[i]->GetUsedMaterial() && vertices.Size() && CheckVisibility(drawables_[i]))
+        drawablesVisible_[i] = false;
+
+        if (CheckVisibility(drawables_[i]) && drawables_[i]->GetUsedMaterial())
         {
         {
-            drawablesVisible_[i] = true;
-            vertexCount_ += vertices.Size();
+            // Delay call Drawable2D::GetVertices
+            const Vector<Vertex2D>& vertices = drawables_[i]->GetVertices();
+            if (!vertices.Empty())
+            {
+                drawablesVisible_[i] = true;
+                vertexCount_ += vertices.Size();
+            }
         }
         }
-        else
-            drawablesVisible_[i] = false;
     }
     }
 
 
     indexCount_ = vertexCount_ / 4 * 6;
     indexCount_ = vertexCount_ / 4 * 6;