diff -r 6f7fe14782c2 -r 907a634e5c02 src/kdtree.cc --- a/src/kdtree.cc Sun Apr 27 09:44:49 2008 +0200 +++ b/src/kdtree.cc Sun Apr 27 14:19:37 2008 +0200 @@ -450,7 +450,7 @@ // fall back to single rays // FIXME: split rays and continue for (int i = 0; i < 4; i++) - if(!nearest_shapes[i]) + if (!nearest_shapes[i]) nearest_shapes[i] = nearest_intersection(origin_shapes[i], rays[i], nearest_distances[i]); return; @@ -493,34 +493,20 @@ /* current node is the leaf . . . empty or full */ __m128 dists = stack[exit].t; ShapeList::iterator shape; + __m128 results; for (shape = node->getShapes()->begin(); shape != node->getShapes()->end(); shape++) { - for (int i = 0; i < 4; i++) - if ( ((_mm_movemask_ps(mask)>>(i))&1) && - ((float*)&stack[entry].t)[i] < ((float*)&stack[exit].t)[i] && - *shape != origin_shapes[i] && - (*shape)->intersect(rays[i], ((float*)&dists)[i]) - && ((float*)&dists)[i] >= ((float*)&stack[entry].t)[i] - Eps) - { - nearest_shapes[i] = *shape; - nearest_distances[i] = ((float*)&dists)[i]; - } - - /* - bool results[4]; - (*shape)->intersect_packet(rays, dists, results); - int greater_than_entry = _mm_movemask_ps( - _mm_and_ps(_mm_cmpge_ps(dists, _mm_sub_ps(stack[entry].t, mEps)), mask)); + results = (*shape)->intersect_packet(rays, dists); + int valid = _mm_movemask_ps( + _mm_and_ps(mask, _mm_and_ps(results, _mm_cmpge_ps(dists, _mm_sub_ps(stack[entry].t, mEps))))); for (int i = 0; i < 4; i++) { - if (results[i] //&& *shape != origin_shapes[i] - && ((greater_than_entry>>(3-i))&1)) + if (*shape != origin_shapes[i] && ((valid>>i)&1)) { nearest_shapes[i] = *shape; nearest_distances[i] = ((float*)&dists)[i]; } } - */ } for (int i = 0; i < 4; i++)