Browse Source

add egg-recursion-limit

David Rose 14 years ago
parent
commit
05be3e1b5e
3 changed files with 10 additions and 1 deletions
  1. 8 0
      panda/src/egg/config_egg.cxx
  2. 1 0
      panda/src/egg/config_egg.h
  3. 1 1
      panda/src/egg/eggPrimitive.cxx

+ 8 - 0
panda/src/egg/config_egg.cxx

@@ -151,6 +151,14 @@ ConfigVariableInt egg_test_vref_integrity
           "its vertices will no longer be checked for internal integrity.  "
           "This is meaningful in non-production builds only."));
 
+ConfigVariableInt egg_recursion_limit
+("egg-recursion-limit", 5000,
+ PRC_DESC("The maximum number of levels that recursive algorithms within "
+          "the egg library are allowed to traverse.  This is a simple hack "
+          "to prevent deeply-recursive algorithms from triggering a stack "
+          "overflow.  Set it larger to run more efficiently if your stack "
+          "allows it; set it lower if you experience stack overflows."));
+
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libegg
 //  Description: Initializes the library.  This must be called at

+ 1 - 0
panda/src/egg/config_egg.h

@@ -40,6 +40,7 @@ extern EXPCL_PANDAEGG ConfigVariableDouble egg_max_tfan_angle;
 extern EXPCL_PANDAEGG ConfigVariableInt egg_min_tfan_tris;
 extern EXPCL_PANDAEGG ConfigVariableDouble egg_coplanar_threshold;
 extern EXPCL_PANDAEGG ConfigVariableInt egg_test_vref_integrity;
+extern EXPCL_PANDAEGG ConfigVariableInt egg_recursion_limit;
 
 extern EXPCL_PANDAEGG void init_libegg();
 

+ 1 - 1
panda/src/egg/eggPrimitive.cxx

@@ -1223,7 +1223,7 @@ void EggPrimitive::
 r_set_connected_shading(int stack_depth, EggPrimitive::Shading shading, 
                         const EggAttributes *neighbor, 
                         ConnectedShadingNodes &next_nodes) {
-  if (stack_depth > 10000) {
+  if (stack_depth > egg_recursion_limit) {
     // Too deep.  Limit recursion.
     ConnectedShadingNode next;
     next._shading = shading;