src/kdtree.cc
branchpyrit
changeset 42 fbdeb3e04543
parent 35 fb170fccb19f
child 44 3763b26244f0
--- a/src/kdtree.cc	Tue Dec 18 12:36:01 2007 +0100
+++ b/src/kdtree.cc	Sat Dec 29 13:53:33 2007 +0100
@@ -162,7 +162,7 @@
 
 	// choose best split pos
 	const Float K = 1.4; // constant, K = cost of traversal / cost of ray-triangle intersection
-	Float SAV = 2*(bbox.w()*bbox.h() + bbox.w()*bbox.d() + bbox.h()*bbox.d()); // surface area of node
+	Float SAV = (bbox.w()*bbox.h() + bbox.w()*bbox.d() + bbox.h()*bbox.d()); // surface area of node
 	Float cost = SAV * (K + shapes->size()); // initial cost = non-split cost
 	bool leaf = true;
 	BBox lbb = bbox;
@@ -172,9 +172,9 @@
 		// calculate SAH cost of this split
 		lbb.H.cell[axis] = spl->pos;
 		rbb.L.cell[axis] = spl->pos;
-		Float SAL = 2*(lbb.w()*lbb.h() + lbb.w()*lbb.d() + lbb.h()*lbb.d());
-		Float SAR = 2*(rbb.w()*rbb.h() + rbb.w()*rbb.d() + rbb.h()*rbb.d());
-		Float splitcost = K + SAL/SAV*(K+spl->lnum) + SAR/SAV*(K+spl->rnum);
+		Float SAL = (lbb.w()*lbb.h() + lbb.w()*lbb.d() + lbb.h()*lbb.d());
+		Float SAR = (rbb.w()*rbb.h() + rbb.w()*rbb.d() + rbb.h()*rbb.d());
+		Float splitcost = K*SAV + SAL*(K+spl->lnum) + SAR*(K+spl->rnum);
 
 		if (splitcost < cost)
 		{