Browse Source

added some debug variable and print statements to investigate polylight behavior

Asad M. Zaman 21 years ago
parent
commit
10cc2dd9a9

+ 4 - 0
panda/src/pgraph/config_pgraph.cxx

@@ -127,6 +127,10 @@ const bool paranoid_compose = config_pgraph.GetBool("paranoid-compose", false);
 // by matrix.
 // by matrix.
 const bool compose_componentwise = config_pgraph.GetBool("compose-componentwise", true);
 const bool compose_componentwise = config_pgraph.GetBool("compose-componentwise", true);
 
 
+// Set this true to view some info statements regarding the polylight
+// It is helpful for debugging
+const bool polylight_info = config_pgraph.GetBool("polylight-info", false);
+
 // Set this false to disable TransparencyAttrib::M_dual altogether
 // Set this false to disable TransparencyAttrib::M_dual altogether
 // (and use M_alpha in its place).
 // (and use M_alpha in its place).
 const bool m_dual = config_pgraph.GetBool("m-dual", true);
 const bool m_dual = config_pgraph.GetBool("m-dual", true);

+ 2 - 0
panda/src/pgraph/config_pgraph.h

@@ -36,6 +36,8 @@ extern const bool allow_unrelated_wrt;
 extern const bool paranoid_compose;
 extern const bool paranoid_compose;
 extern const bool compose_componentwise;
 extern const bool compose_componentwise;
 
 
+extern const bool polylight_info;
+
 extern const bool m_dual;
 extern const bool m_dual;
 extern const bool m_dual_opaque;
 extern const bool m_dual_opaque;
 extern const bool m_dual_transparent;
 extern const bool m_dual_transparent;

+ 13 - 9
panda/src/pgraph/polylightEffect.cxx

@@ -156,10 +156,13 @@ do_poly_light(const CullTraverserData *data, const TransformState *node_transfor
       }
       }
 
 
       if (dist <= light_radius) { // If node is in range of this light
       if (dist <= light_radius) { // If node is in range of this light
-        pgraph_cat.debug() << "light's position = " << light->get_pos() << endl;
-        pgraph_cat.debug() << "relative position = " << point << endl;
-        pgraph_cat.debug() << "effect center = " << _effect_center << endl;
-        pgraph_cat.debug() << "close to this light = " << light->get_name() << endl;
+        if (polylight_info) {
+          pgraph_cat.info() << "light's position = " << light->get_pos() << endl;
+          pgraph_cat.info() << "relative position = " << point << endl;
+          pgraph_cat.info() << "effect center = " << _effect_center << endl;
+          //pgraph_cat.info() << "close to this light = " << light->get_name() << endl;
+          pgraph_cat.info() << "dist = " << dist << ";radius = " << light_radius << endl;
+        }
 
 
         PolylightNode::Attenuation_Type light_attenuation = light->get_attenuation();
         PolylightNode::Attenuation_Type light_attenuation = light->get_attenuation();
         Colorf light_color;
         Colorf light_color;
@@ -189,16 +192,16 @@ do_poly_light(const CullTraverserData *data, const TransformState *node_transfor
           light_scale = 1.0;
           light_scale = 1.0;
         }
         }
 
 
-        pgraph_cat.debug() << "dist = " << dist << ";radius = " << light_radius << endl;
-             
         // Keep accumulating each lights contribution... 
         // Keep accumulating each lights contribution... 
         // we have to prevent color snap, so factor in the weight.
         // we have to prevent color snap, so factor in the weight.
         // weight becomes negligent as you are closer to the light
         // weight becomes negligent as you are closer to the light
         // and opposite otherwise
         // and opposite otherwise
         weight_scale = _weight * (1.0 - light_scale);
         weight_scale = _weight * (1.0 - light_scale);
 
 
-        pgraph_cat.debug() << "weight_scale = " << weight_scale
-             << "; light_scale " << light_scale << endl;
+        if (polylight_info) {
+          pgraph_cat.debug() << "weight_scale = " << weight_scale
+                             << "; light_scale " << light_scale << endl;
+        }
 
 
         Rcollect += light_color[0] * light_scale + weight_scale;
         Rcollect += light_color[0] * light_scale + weight_scale;
         Gcollect += light_color[1] * light_scale + weight_scale;
         Gcollect += light_color[1] * light_scale + weight_scale;
@@ -222,7 +225,8 @@ do_poly_light(const CullTraverserData *data, const TransformState *node_transfor
     r = Rcollect / num_lights;
     r = Rcollect / num_lights;
     g = Gcollect / num_lights;
     g = Gcollect / num_lights;
     b = Bcollect / num_lights;
     b = Bcollect / num_lights;
-    pgraph_cat.debug() << "r=" << r << "; g=" << g << "; b=" << b << endl;
+    if (polylight_info)
+      pgraph_cat.info() << "r=" << r << "; g=" << g << "; b=" << b << endl;
   }
   }
 
 
   return ColorScaleAttrib::make(LVecBase4f(r, g, b, 1.0));
   return ColorScaleAttrib::make(LVecBase4f(r, g, b, 1.0));

+ 4 - 2
panda/src/pgraph/polylightNode.cxx

@@ -93,11 +93,13 @@ Colorf PolylightNode::flicker() const {
     //srand((int)ClockObject::get_global_clock()->get_frame_time());
     //srand((int)ClockObject::get_global_clock()->get_frame_time());
     variation = (rand()%100);  // a value between 0-99
     variation = (rand()%100);  // a value between 0-99
     variation /= 100.0;
     variation /= 100.0;
-    pgraph_cat.debug() << "Random Variation: " << variation << endl;
+    if (polylight_info)
+      pgraph_cat.info() << "Random Variation: " << variation << endl;
   } else if (_flicker_type == FSIN) {
   } else if (_flicker_type == FSIN) {
     double now = ClockObject::get_global_clock()->get_frame_time();
     double now = ClockObject::get_global_clock()->get_frame_time();
     variation = sinf(now*_sin_freq);
     variation = sinf(now*_sin_freq);
-    pgraph_cat.debug() << "Variation: " << variation << endl;
+    if (polylight_info)
+      pgraph_cat.info() << "Variation: " << variation << endl;
     // can't use negative variation, so make it positive
     // can't use negative variation, so make it positive
     if (variation < 0.0)
     if (variation < 0.0)
       variation *= -1.0;
       variation *= -1.0;