src/kdtree.cc
branchpyrit
changeset 0 3547b885df7e
child 7 bf17f9f84c91
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/kdtree.cc	Thu Oct 25 16:40:22 2007 +0200
@@ -0,0 +1,36 @@
+#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);
+}
\ No newline at end of file