add egg-recursion-limit

This commit is contained in:
David Rose 2011-12-19 14:44:38 +00:00
parent f9240e0258
commit 05be3e1b5e
3 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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();

View File

@ -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;