src/kdtree.cc
branchpyrit
changeset 35 fb170fccb19f
parent 34 28f6e8b9d5d1
child 42 fbdeb3e04543
equal deleted inserted replaced
34:28f6e8b9d5d1 35:fb170fccb19f
   377 		Float dist = exPt->t;
   377 		Float dist = exPt->t;
   378 		ShapeList::iterator shape;
   378 		ShapeList::iterator shape;
   379 		for (shape = node->shapes->begin(); shape != node->shapes->end(); shape++)
   379 		for (shape = node->shapes->begin(); shape != node->shapes->end(); shape++)
   380 			if (*shape != origin_shape && (*shape)->intersect(ray, dist)
   380 			if (*shape != origin_shape && (*shape)->intersect(ray, dist)
   381 			&& dist >= enPt->t)
   381 			&& dist >= enPt->t)
       
   382 			{
   382 				nearest_shape = *shape;
   383 				nearest_shape = *shape;
       
   384 				nearest_distance = dist;
       
   385 			}
   383 
   386 
   384 		delete enPt;
   387 		delete enPt;
   385 
   388 
   386 		if (nearest_shape)
   389 		if (nearest_shape)
   387 		{
   390 		{
   388 			while (!st.empty())
   391 			while (!st.empty())
   389 			{
   392 			{
   390 				delete st.back();
   393 				delete st.back();
   391 				st.pop_back();
   394 				st.pop_back();
   392 			}
   395 			}
   393 			nearest_distance = dist;
       
   394 			return nearest_shape;
   396 			return nearest_shape;
   395 		}
   397 		}
   396 
   398 
   397 		enPt = exPt;
   399 		enPt = exPt;
   398 
   400