diff -r fbd1d2f7d94e -r fc18ac4833f2 src/kdtree.cc --- a/src/kdtree.cc Sat Nov 24 23:55:54 2007 +0100 +++ b/src/kdtree.cc Sun Nov 25 15:50:01 2007 +0100 @@ -70,9 +70,9 @@ if (shapebb.L.x < bbox.L.x) bbox.L.x = shapebb.L.x; if (shapebb.L.y < bbox.L.y) bbox.L.y = shapebb.L.y; if (shapebb.L.z < bbox.L.z) bbox.L.z = shapebb.L.z; - if (shapebb.R.x > bbox.R.x) bbox.R.x = shapebb.R.x; - if (shapebb.R.y > bbox.R.y) bbox.R.y = shapebb.R.y; - if (shapebb.R.z > bbox.R.z) bbox.R.z = shapebb.R.z; + if (shapebb.H.x > bbox.H.x) bbox.H.x = shapebb.H.x; + if (shapebb.H.y > bbox.H.y) bbox.H.y = shapebb.H.y; + if (shapebb.H.z > bbox.H.z) bbox.H.z = shapebb.H.z; } }; @@ -112,7 +112,7 @@ for (sh = sslist.begin(); sh != sslist.end(); sh++) { splitlist.push_back(SplitPos(sh->bbox.L.cell[axis])); - splitlist.push_back(SplitPos(sh->bbox.R.cell[axis])); + splitlist.push_back(SplitPos(sh->bbox.H.cell[axis])); } sort(splitlist.begin(), splitlist.end()); // remove duplicate splits @@ -131,9 +131,9 @@ continue; } // if shape is completely contained in split plane - if (spl->pos == sh->bbox.L.cell[axis] == sh->bbox.R.cell[axis]) + if (spl->pos == sh->bbox.L.cell[axis] == sh->bbox.H.cell[axis]) { - if (spl->pos - bbox.L.cell[axis] < bbox.R.cell[axis] - spl->pos) + if (spl->pos - bbox.L.cell[axis] < bbox.H.cell[axis] - spl->pos) { // left subcell is smaller -> if not empty, put shape here if (spl->lnum) @@ -150,13 +150,13 @@ sh->setMark(); } else // if shape is on left side of split plane - if (sh->bbox.R.cell[axis] <= spl->pos) + if (sh->bbox.H.cell[axis] <= spl->pos) { spl->lnum++; sh->setMark(); } else // if shape occupies both sides of split plane - if (sh->bbox.L.cell[axis] < spl->pos && sh->bbox.R.cell[axis] > spl->pos) + if (sh->bbox.L.cell[axis] < spl->pos && sh->bbox.H.cell[axis] > spl->pos) { spl->lnum++; spl->rnum++; @@ -181,7 +181,7 @@ for (spl = splitlist.begin(); spl != splitlist.end(); spl++) { // calculate SAH cost of this split - lbb.R.cell[axis] = spl->pos; + lbb.H.cell[axis] = spl->pos; rbb.L.cell[axis] = spl->pos; float SAL = 2*(lbb.w()*lbb.h() + lbb.w()*lbb.d() + lbb.h()*lbb.d()); float SAR = 2*(rbb.w()*rbb.h() + rbb.w()*rbb.d() + rbb.h()*rbb.d()); @@ -209,12 +209,12 @@ v.cell[(axis+2)%3] = bbox.L.cell[(axis+2)%3]; F << "v " << v.x << " " << v.y << " " << v.z << endl; v.cell[(axis+1)%3] = bbox.L.cell[(axis+1)%3]; - v.cell[(axis+2)%3] = bbox.R.cell[(axis+2)%3]; + v.cell[(axis+2)%3] = bbox.H.cell[(axis+2)%3]; F << "v " << v.x << " " << v.y << " " << v.z << endl; - v.cell[(axis+1)%3] = bbox.R.cell[(axis+1)%3]; - v.cell[(axis+2)%3] = bbox.R.cell[(axis+2)%3]; + v.cell[(axis+1)%3] = bbox.H.cell[(axis+1)%3]; + v.cell[(axis+2)%3] = bbox.H.cell[(axis+2)%3]; F << "v " << v.x << " " << v.y << " " << v.z << endl; - v.cell[(axis+1)%3] = bbox.R.cell[(axis+1)%3]; + v.cell[(axis+1)%3] = bbox.H.cell[(axis+1)%3]; v.cell[(axis+2)%3] = bbox.L.cell[(axis+2)%3]; F << "v " << v.x << " " << v.y << " " << v.z << endl; F << "f " << f+1 << " " << f+2 << " " << f+3 << " " << f+4 << endl; @@ -238,11 +238,11 @@ } if (state == 0) { - if (sh->bbox.R.cell[axis] < split) + if (sh->bbox.H.cell[axis] < split) { // left children[0].addShape(sh->shape); } else - if (sh->bbox.R.cell[axis] > split) + if (sh->bbox.H.cell[axis] > split) { if (sh->bbox.L.cell[axis] < split) { // both @@ -254,13 +254,13 @@ state = 1; } } else - { // R == split + { // H == split if (sh->bbox.L.cell[axis] < split) { // left children[0].addShape(sh->shape); } else { // contained - if (split - bbox.L.cell[axis] < bbox.R.cell[axis] - split) + if (split - bbox.L.cell[axis] < bbox.H.cell[axis] - split) { // left subcell is smaller -> if not empty, put shape here if (lnum) @@ -279,7 +279,7 @@ } } - lbb.R.cell[axis] = split; + lbb.H.cell[axis] = split; rbb.L.cell[axis] = split; children[0].subdivide(lbb, depth+1); @@ -406,6 +406,7 @@ } /* pop from the stack */ + delete enPt; enPt = exPt; /* the signed distance intervals are adjacent */ /* retrieve the pointer to the next node, it is possible that ray traversal terminates */ @@ -416,6 +417,8 @@ st.pop(); } /* while */ + delete enPt; + /* ray leaves the scene */ return NULL; }