diff -r 9d66d323c354 -r 9af5c039b678 src/octree.cc --- a/src/octree.cc Fri May 02 13:27:47 2008 +0200 +++ b/src/octree.cc Mon May 05 15:31:14 2008 +0200 @@ -37,7 +37,7 @@ delete[] children; } -void OctreeNode::subdivide(BBox bbox, int maxdepth) +void OctreeNode::subdivide(const BBox &bbox, int maxdepth) { ShapeList *l_shapes = getShapes(); @@ -45,9 +45,9 @@ makeChildren(); // evaluate centres for axes - const Float xsplit = (bbox.L.x + bbox.H.x)*0.5; - const Float ysplit = (bbox.L.y + bbox.H.y)*0.5; - const Float zsplit = (bbox.L.z + bbox.H.z)*0.5; + const Float xsplit = (bbox.L.x + bbox.H.x)*0.5f; + const Float ysplit = (bbox.L.y + bbox.H.y)*0.5f; + const Float zsplit = (bbox.L.z + bbox.H.z)*0.5f; // set bounding boxes for children BBox childbb[8] = {bbox, bbox, bbox, bbox, bbox, bbox, bbox, bbox}; @@ -155,7 +155,12 @@ if (!built) return Container::nearest_intersection(origin_shape, ray, nearest_distance); +#ifdef MSVC + // MSVC wants constant expression here... hope it won't overflow :) + OctreeTravState st[20]; +#else OctreeTravState st[max_depth+1]; +#endif register OctreeTravState *st_cur = st; # define node st_cur->node @@ -192,12 +197,12 @@ a |= 1; } - if (rdir.x == 0.0) rdir.x = Eps; - if (rdir.y == 0.0) rdir.y = Eps; - if (rdir.z == 0.0) rdir.z = Eps; - rdir.x = 1.0/rdir.x; - rdir.y = 1.0/rdir.y; - rdir.z = 1.0/rdir.z; + if (rdir.x == 0.0f) rdir.x = Eps; + if (rdir.y == 0.0f) rdir.y = Eps; + if (rdir.z == 0.0f) rdir.z = Eps; + rdir.x = 1.0f/rdir.x; + rdir.y = 1.0f/rdir.y; + rdir.z = 1.0f/rdir.z; tx0 = (bbox.L.x - ro.x) * rdir.x; tx1 = (bbox.H.x - ro.x) * rdir.x; @@ -238,9 +243,9 @@ } else { - txm = 0.5 * (tx0+tx1); - tym = 0.5 * (ty0+ty1); - tzm = 0.5 * (tz0+tz1); + txm = 0.5f * (tx0+tx1); + tym = 0.5f * (ty0+ty1); + tzm = 0.5f * (tz0+tz1); // first node st_cur->next = 0;