src/kdtree.cc
author Radek Brich <radek.brich@devl.cz>
Sat, 17 Nov 2007 17:47:06 +0100
branchpyrit
changeset 5 2d97ea5e711a
parent 0 3547b885df7e
child 7 bf17f9f84c91
permissions -rw-r--r--
resolve warnings from current g++

#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);
}