src/kdtree.cc
branchpyrit
changeset 35 fb170fccb19f
parent 34 28f6e8b9d5d1
child 42 fbdeb3e04543
--- a/src/kdtree.cc	Sun Dec 09 23:10:58 2007 +0100
+++ b/src/kdtree.cc	Wed Dec 12 19:59:19 2007 +0100
@@ -379,7 +379,10 @@
 		for (shape = node->shapes->begin(); shape != node->shapes->end(); shape++)
 			if (*shape != origin_shape && (*shape)->intersect(ray, dist)
 			&& dist >= enPt->t)
+			{
 				nearest_shape = *shape;
+				nearest_distance = dist;
+			}
 
 		delete enPt;
 
@@ -390,7 +393,6 @@
 				delete st.back();
 				st.pop_back();
 			}
-			nearest_distance = dist;
 			return nearest_shape;
 		}