Browse Source

robustify lighting a bit

David Rose 24 years ago
parent
commit
3db77d13a5
1 changed files with 7 additions and 1 deletions
  1. 7 1
      panda/src/display/graphicsStateGuardian.cxx

+ 7 - 1
panda/src/display/graphicsStateGuardian.cxx

@@ -867,7 +867,10 @@ begin_frame() {
   // changed between frames.
   // changed between frames.
   if (_lighting_enabled_this_frame) {
   if (_lighting_enabled_this_frame) {
     for (int i = 0; i < _max_lights; i++) {
     for (int i = 0; i < _max_lights; i++) {
-      enable_light(i, false);
+      if (_light_info[i]._enabled) {
+        enable_light(i, false);
+        _light_info[i]._enabled = false;
+      }
       _light_info[i]._light = (Light *)NULL;
       _light_info[i]._light = (Light *)NULL;
     }
     }
 
 
@@ -1238,6 +1241,7 @@ issue_light(const LightAttrib *attrib) {
           // enable the light, not reapply it.
           // enable the light, not reapply it.
           cur_light_id = -2;
           cur_light_id = -2;
           enable_light(i, true);
           enable_light(i, true);
+          _light_info[i]._enabled = true;
           _light_info[i]._next_enabled = true;
           _light_info[i]._next_enabled = true;
           break;
           break;
         }
         }
@@ -1268,6 +1272,7 @@ issue_light(const LightAttrib *attrib) {
         
         
       if (cur_light_id >= 0) {
       if (cur_light_id >= 0) {
         enable_light(cur_light_id, true);
         enable_light(cur_light_id, true);
+        _light_info[cur_light_id]._enabled = true;
         _light_info[cur_light_id]._next_enabled = true;
         _light_info[cur_light_id]._next_enabled = true;
         
         
         if (!any_bound) {
         if (!any_bound) {
@@ -1290,6 +1295,7 @@ issue_light(const LightAttrib *attrib) {
   for (i = 0; i < _max_lights; i++) {
   for (i = 0; i < _max_lights; i++) {
     if (!_light_info[i]._next_enabled) {
     if (!_light_info[i]._next_enabled) {
       enable_light(i, false);
       enable_light(i, false);
+      _light_info[i]._enabled = false;
     }
     }
   }
   }