initial commit, raytracer source as written year ago and unchanged since 2007-03-25
#include "kdtree.cc"
void KdTree::KdTree(ShapeList &shapelist):
{
root = new KdNode();
shapes = new vector<Shape*>();
ShapeList::iterator shape;
for (shape = shapelist.begin(); shape != shapes.end(); shape++)
addShape(*shape);
rebuild();
}
void KdTree::Subdivide(KdNode* node, AABB& bbox, int depth, int count)
{
/*if (stopcriterionmet()) return
splitpos = findoptimalsplitposition()
leftnode = new Node()
rightnode = new Node()
for (all primitives in node)
{
if (node->intersectleftnode()) leftnode->addprimitive( primitive )
if (node->intersectrightnode()) rightnode->addprimitive( primitive )
}
buildkdtree( leftnode )
buildkdtree( rightnode )*/
}
void KdTree::rebuild()
{
int count = shapes->size();
AABB bbox = shapes->extends();
Subdivide(root, bbox, 0, count);
}