--- a/src/kdtree.cc Fri Nov 30 00:44:51 2007 +0100
+++ b/src/kdtree.cc Mon Dec 03 01:49:23 2007 +0100
@@ -35,10 +35,10 @@
class SplitPos
{
public:
- float pos;
+ Float pos;
int lnum, rnum;
SplitPos(): pos(0.0), lnum(0), rnum(0) {};
- SplitPos(float &aPos): pos(aPos), lnum(0), rnum(0) {};
+ SplitPos(Float &aPos): pos(aPos), lnum(0), rnum(0) {};
friend bool operator<(const SplitPos& a, const SplitPos& b)
{ return a.pos < b.pos; };
friend bool operator==(const SplitPos& a, const SplitPos& b)
@@ -54,9 +54,9 @@
{
public:
KdNode* node; /* pointer to far child */
- float t; /* the entry/exit signed distance */
+ Float t; /* the entry/exit signed distance */
Vector3 pb; /* the coordinates of entry/exit point */
- StackElem(KdNode *anode, const float &at, const Vector3 &apb):
+ StackElem(KdNode *anode, const Float &at, const Vector3 &apb):
node(anode), t(at), pb(apb) {};
};
@@ -81,7 +81,7 @@
};
Shape *Container::nearest_intersection(const Shape *origin_shape, const Ray &ray,
- float &nearest_distance)
+ Float &nearest_distance)
{
Shape *nearest_shape = NULL;
ShapeList::iterator shape;
@@ -183,9 +183,9 @@
}
// choose best split pos
- const float K = 1.4; // constant, K = cost of traversal / cost of ray-triangle intersection
- float SAV = 2*(bbox.w()*bbox.h() + bbox.w()*bbox.d() + bbox.h()*bbox.d()); // surface area of node
- float cost = SAV * (K + shapes->size()); // initial cost = non-split cost
+ const Float K = 1.4; // constant, K = cost of traversal / cost of ray-triangle intersection
+ Float SAV = 2*(bbox.w()*bbox.h() + bbox.w()*bbox.d() + bbox.h()*bbox.d()); // surface area of node
+ Float cost = SAV * (K + shapes->size()); // initial cost = non-split cost
SplitPos *splitpos = NULL;
bool leaf = true;
BBox lbb = bbox;
@@ -195,9 +195,9 @@
// calculate SAH cost of this split
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());
- float splitcost = K + SAL/SAV*(K+spl->lnum) + SAR/SAV*(K+spl->rnum);
+ 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());
+ Float splitcost = K + SAL/SAV*(K+spl->lnum) + SAR/SAV*(K+spl->rnum);
if (splitcost < cost)
{
@@ -237,8 +237,8 @@
#endif
split = splitpos->pos;
- float lnum = splitpos->lnum;
- float rnum = splitpos->rnum;
+ Float lnum = splitpos->lnum;
+ Float rnum = splitpos->rnum;
// split this node
delete shapes;
@@ -315,10 +315,10 @@
/* algorithm by Vlastimil Havran, Heuristic Ray Shooting Algorithms, appendix C */
Shape *KdTree::nearest_intersection(const Shape *origin_shape, const Ray &ray,
- float &nearest_distance)
+ Float &nearest_distance)
{
- float a, b; /* entry/exit signed distance */
- float t; /* signed distance to the splitting plane */
+ Float a, b; /* entry/exit signed distance */
+ Float t; /* signed distance to the splitting plane */
/* if we have no tree, fall back to naive test */
if (!built)
@@ -352,7 +352,7 @@
while (!node->isLeaf())
{
/* retrieve position of splitting plane */
- float splitVal = node->getSplit();
+ Float splitVal = node->getSplit();
short axis = node->getAxis();
if (enPt->pb[axis] <= splitVal)
@@ -401,7 +401,7 @@
/* "intersect ray with each object in the object list, discarding "
"those lying before stack[enPt].t or farther than stack[exPt].t" */
Shape *nearest_shape = NULL;
- float dist = exPt->t;
+ Float dist = exPt->t;
ShapeList::iterator shape;
for (shape = node->shapes->begin(); shape != node->shapes->end(); shape++)
if (*shape != origin_shape && (*shape)->intersect(ray, dist)