--- a/src/kdtree.cc Sun Apr 27 14:19:37 2008 +0200
+++ b/src/kdtree.cc Sun Apr 27 19:56:23 2008 +0200
@@ -342,27 +342,16 @@
{
__m128 a, b; /* entry/exit signed distance */
__m128 t; /* signed distance to the splitting plane */
- __m128 mask = zeros;
+ __m128 mask = mZero;
/* if we have no tree, fall back to naive test */
if (!built)
Container::packet_intersection(origin_shapes, rays, nearest_distances, nearest_shapes);
- nearest_shapes[0] = NULL;
- nearest_shapes[1] = NULL;
- nearest_shapes[2] = NULL;
- nearest_shapes[3] = NULL;
+ // nearest_shapes[0..4] = NULL
+ memset(nearest_shapes, 0, 4*sizeof(Shape*));
- //bbox.intersect_packet(rays, a, b)
- if (bbox.intersect(rays[0], ((float*)&a)[0], ((float*)&b)[0]))
- ((int*)&mask)[0] = -1;
- if (bbox.intersect(rays[1], ((float*)&a)[1], ((float*)&b)[1]))
- ((int*)&mask)[1] = -1;
- if (bbox.intersect(rays[2], ((float*)&a)[2], ((float*)&b)[2]))
- ((int*)&mask)[2] = -1;
- if (bbox.intersect(rays[3], ((float*)&a)[3], ((float*)&b)[3]))
- ((int*)&mask)[3] = -1;
-
+ mask = bbox.intersect_packet(rays, a, b);
if (!_mm_movemask_ps(mask))
return;
@@ -396,7 +385,7 @@
__m128 splitVal;
int axis;
static const int mod3[] = {0,1,2,0,1};
- const VectorPacket invdirs = ones / rays.dir;
+ const VectorPacket invdirs = mOne / rays.dir;
while (node)
{
/* loop until a leaf is found */
@@ -494,6 +483,7 @@
__m128 dists = stack[exit].t;
ShapeList::iterator shape;
__m128 results;
+ __m128 newmask = mask;
for (shape = node->getShapes()->begin(); shape != node->getShapes()->end(); shape++)
{
results = (*shape)->intersect_packet(rays, dists);
@@ -505,14 +495,12 @@
{
nearest_shapes[i] = *shape;
nearest_distances[i] = ((float*)&dists)[i];
+ ((int*)&newmask)[i] = 0;
}
}
}
- for (int i = 0; i < 4; i++)
- if (nearest_shapes[i])
- ((int*)&mask)[i] = 0;
-
+ mask = newmask;
if (!_mm_movemask_ps(mask))
return;