ecere/gfx/3D/Object: computeLightVector flag to avoid always recomputing uselessly
[sdk] / ecere / src / gfx / Display.ec
index 7b0e991..217a181 100644 (file)
@@ -717,6 +717,10 @@ public:
    // --- Lights ---
    void SetLight(int id, Light light)
    {
+      if(!display3D)
+      {
+         display3D = Display3D { };
+      }
       displaySystem.driver.SetLight(this, id, light);
    }
 
@@ -943,7 +947,7 @@ public:
                   displaySystem.driver.PushMatrix(this);
 
 #if ENABLE_GL_FFP
-               if(object.mesh.tangents && object.mesh.normals)
+               if(object.mesh.tangents && object.mesh.normals && object.flags.computeLightVectors)
                {
                   Mesh mesh = object.mesh;
                   if(!glCaps_shaders)
@@ -960,7 +964,7 @@ public:
                      Matrix t, inv = camera.viewMatrix;
                      Vector3D ot { };
                      Vector3D cPos = camera.cPosition;
-                     Vector3D pos = camera.position;
+                     Vector3D pos;
                      bool positional = l[3] ? true : false;
 
                      inv.Scale(1.0/nearPlane, -1.0/nearPlane,-1.0/nearPlane);