Quellcode durchsuchen

Do not attempt to draw empty geometries.

Lasse Öörni vor 13 Jahren
Ursprung
Commit
8c58f43ee8
2 geänderte Dateien mit 3 neuen und 3 gelöschten Zeilen
  1. 1 1
      Engine/Graphics/Batch.cpp
  2. 2 2
      Engine/Graphics/Geometry.cpp

+ 1 - 1
Engine/Graphics/Batch.cpp

@@ -647,7 +647,7 @@ void BatchGroup::SetTransforms(Renderer* renderer, void* lockedData, unsigned& f
 
 
 void BatchGroup::Draw(Graphics* graphics, Renderer* renderer) const
 void BatchGroup::Draw(Graphics* graphics, Renderer* renderer) const
 {
 {
-    if (!instances_.Size())
+    if (!instances_.Size() || (!geometry_->GetIndexCount() && !geometry_->GetVertexCount()))
         return;
         return;
     
     
     // Draw as individual objects if instancing not supported
     // Draw as individual objects if instancing not supported

+ 2 - 2
Engine/Graphics/Geometry.cpp

@@ -158,13 +158,13 @@ void Geometry::SetLodDistance(float distance)
 
 
 void Geometry::Draw(Graphics* graphics)
 void Geometry::Draw(Graphics* graphics)
 {
 {
-    if (indexBuffer_)
+    if (indexBuffer_ && indexCount_ > 0)
     {
     {
         graphics->SetIndexBuffer(indexBuffer_);
         graphics->SetIndexBuffer(indexBuffer_);
         graphics->SetVertexBuffers(vertexBuffers_, elementMasks_);
         graphics->SetVertexBuffers(vertexBuffers_, elementMasks_);
         graphics->Draw(primitiveType_, indexStart_, indexCount_, vertexStart_, vertexCount_);
         graphics->Draw(primitiveType_, indexStart_, indexCount_, vertexStart_, vertexCount_);
     }
     }
-    else
+    else if (vertexCount_ > 0)
     {
     {
         graphics->SetVertexBuffers(vertexBuffers_, elementMasks_);
         graphics->SetVertexBuffers(vertexBuffers_, elementMasks_);
         graphics->Draw(primitiveType_, vertexStart_, vertexCount_);
         graphics->Draw(primitiveType_, vertexStart_, vertexCount_);