src/kdtree.cc
branchpyrit
changeset 103 3b3257a410fe
parent 95 ca7d4c665531
child 104 2274a07510c1
--- a/src/kdtree.cc	Mon Sep 08 20:14:24 2014 +0200
+++ b/src/kdtree.cc	Tue Jul 26 17:41:36 2016 +0200
@@ -66,6 +66,8 @@
 		delete getShapes();
 }
 
+const int KdTree::MAX_DEPTH = 32;
+
 // kd-tree recursive build algorithm, inspired by PBRT (www.pbrt.org)
 void KdTree::recursive_build(KdNode *node, const BBox &bounds, int maxdepth)
 {
@@ -199,7 +201,7 @@
 	ShapeList::iterator shape;
 	for (shape = shapes.begin(); shape != shapes.end(); shape++)
 		root->addShape(*shape);
-	recursive_build(root, bbox, max_depth);
+	recursive_build(root, bbox, MAX_DEPTH);
 	built = true;
 }
 
@@ -221,12 +223,7 @@
 	KdNode *farchild, *node;
 	node = root;
 
-#ifdef MSVC
-	// MSVC wants constant expression here... hope it won't overflow :)
-	StackElem stack[64];
-#else
-	StackElem stack[max_depth];
-#endif
+	StackElem stack[MAX_DEPTH];
 
 	int entry = 0, exit = 1;
 	stack[entry].t = a;
@@ -296,7 +293,7 @@
 			exit++;
 			if (exit == entry)
 				exit++;
-			assert(exit < max_depth);
+			assert(exit < MAX_DEPTH);
 
 			stack[exit].prev = tmp;
 			stack[exit].t = t;
@@ -367,12 +364,7 @@
 	KdNode *farchild, *node;
 	node = root;
 
-#ifdef MSVC
-	// MSVC wants constant expression here... hope it won't overflow :)
-	StackElem4 stack[64];
-#else
-	StackElem4 stack[max_depth];
-#endif
+	StackElem4 stack[MAX_DEPTH];
 
 	int entry = 0, exit = 1;
 	stack[entry].t = a;
@@ -476,7 +468,7 @@
 			exit++;
 			if (exit == entry)
 				exit++;
-			assert(exit < max_depth);
+			assert(exit < MAX_DEPTH);
 
 			stack[exit].prev = tmp;
 			stack[exit].t = t;