Browse Source

If drawable does not limit number of per-pixel lights, no need to store them per drawable (skips allocation of dynamic memory for the light list.)

Lasse Öörni 11 years ago
parent
commit
406b71d4c9
1 changed files with 7 additions and 3 deletions
  1. 7 3
      Source/Urho3D/Graphics/Drawable.h

+ 7 - 3
Source/Urho3D/Graphics/Drawable.h

@@ -248,9 +248,13 @@ public:
     // Add a per-pixel light affecting the object this frame.
     void AddLight(Light* light)
     {
-        if (lights_.Empty())
+        if (!firstLight_)
             firstLight_ = light;
-        lights_.Push(light);
+
+        // Need to store into the light list only if the per-pixel lights are being limited.
+        // Otherwise recording the first light is enough
+        if (maxLights_)
+            lights_.Push(light);
     }
 
     // Add a per-vertex light affecting the object this frame.
@@ -321,7 +325,7 @@ protected:
     float lodBias_;
     /// Base pass flags.
     unsigned basePassFlags_;
-    /// Maximum lights.
+    /// Maximum per-pixel lights.
     unsigned maxLights_;
     /// Octree octant.
     Octant* octant_;