diff -r fb170fccb19f -r b490093b0ac3 src/octree.cc --- a/src/octree.cc Wed Dec 12 19:59:19 2007 +0100 +++ b/src/octree.cc Thu Dec 13 00:08:11 2007 +0100 @@ -44,71 +44,15 @@ // distribute shapes to children ShapeList::iterator sh; - BBox shbb; - int child, both; unsigned int shapenum = 0; for (sh = shapes->begin(); sh != shapes->end(); sh++) { - child = 0; - both = 0; - shbb = (*sh)->get_bbox(); - - if (shbb.L.x >= xsplit) - child |= 4; //right - else if (shbb.H.x > xsplit) - both |= 4; // both - // for left, do nothing - - if (shbb.L.y >= ysplit) - child |= 2; - else if (shbb.H.y > ysplit) - both |= 2; - - if (shbb.L.z >= zsplit) - child |= 1; - else if (shbb.H.z > zsplit) - both |= 1; - - if (!both) - { - getChild(child)->addShape(*sh); - shapenum++; - } - else - { - // shape goes to more than one child - if (both == 7) + for (int i = 0; i < 8; i++) + if ((*sh)->intersect_bbox(childbb[i])) { - for (int i = 0; i < 8; i++) - getChild(i)->addShape(*sh); - shapenum += 8; + getChild(i)->addShape(*sh); + shapenum++; } - else if (both == 3 || both >= 5) - { - if (both == 3) - { - for (int i = 0; i < 4; i++) - getChild(child + i)->addShape(*sh); - } - else if (both == 5) - { - for (int i = 0; i < 4; i++) - getChild(child + i+(i>>1<<1))->addShape(*sh); - } - else if (both == 6) - { - for (int i = 0; i < 4; i++) - getChild(child + (i<<1))->addShape(*sh); - } - shapenum += 4; - } - else - { - getChild(child)->addShape(*sh); - getChild(child+both)->addShape(*sh); - shapenum += 2; - } - } } if (shapes->size() <= 8 && shapenum > 2*shapes->size()) @@ -316,7 +260,6 @@ Float tz0 = (bbox.L.z - ro.z) / rdir.z; Float tz1 = (bbox.H.z - ro.z) / rdir.z; - //Octree *node = root; if (max(max(tx0,ty0),tz0) < min (min(tx1,ty1),tz1)) return proc_subtree(a,tx0,ty0,tz0,tx1,ty1,tz1,root, origin_shape, ray, nearest_distance);