Răsfoiți Sursa

Slight optimizations in light-related operations.

Lasse Öörni 14 ani în urmă
părinte
comite
04a7049bdf
2 a modificat fișierele cu 6 adăugiri și 4 ștergeri
  1. 4 2
      Engine/Graphics/Drawable.cpp
  2. 2 2
      Engine/Graphics/View.cpp

+ 4 - 2
Engine/Graphics/Drawable.cpp

@@ -240,8 +240,9 @@ void Drawable::LimitLights()
     if (!maxLights_)
         return;
     
+    const BoundingBox& box = GetWorldBoundingBox();
     for (unsigned i = 0; i < lights_.Size(); ++i)
-        lights_[i]->SetIntensitySortValue(GetWorldBoundingBox());
+        lights_[i]->SetIntensitySortValue(box);
     
     Sort(lights_.Begin(), lights_.End(), CompareDrawables);
     
@@ -255,8 +256,9 @@ void Drawable::LimitLights()
 
 void Drawable::LimitVertexLights()
 {
+    const BoundingBox& box = GetWorldBoundingBox();
     for (unsigned i = 0; i < vertexLights_.Size(); ++i)
-        vertexLights_[i]->SetIntensitySortValue(GetWorldBoundingBox());
+        vertexLights_[i]->SetIntensitySortValue(box);
     
     Sort(vertexLights_.Begin(), vertexLights_.End(), CompareDrawables);
     

+ 2 - 2
Engine/Graphics/View.cpp

@@ -812,9 +812,9 @@ void View::GetLitBatches(Drawable* drawable, LightBatchQueue& lightQueue)
 {
     Light* light = lightQueue.light_;
     Light* firstLight = drawable->GetFirstLight();
-    
     // Shadows on transparencies can only be rendered if shadow maps are not reused
     bool allowTransparentShadows = !renderer_->GetReuseShadowMaps();
+    bool hasVertexLights = drawable->GetVertexLights().Size() > 0;
     unsigned numBatches = drawable->GetNumBatches();
     
     for (unsigned i = 0; i < numBatches; ++i)
@@ -830,7 +830,7 @@ void View::GetLitBatches(Drawable* drawable, LightBatchQueue& lightQueue)
         
         // Check for lit base pass. Because it uses the replace blend mode, it must be ensured to be the first light
         // Also vertex lighting requires the non-lit base pass, so skip if any vertex lights
-        if (light == firstLight && drawable->GetVertexLights().Empty() && !drawable->HasBasePass(i))
+        if (light == firstLight && !hasVertexLights && !drawable->HasBasePass(i))
         {
             pass = tech->GetPass(PASS_LITBASE);
             if (pass)