src/kdtree.cc
branchpyrit
changeset 17 5176ba000a67
parent 16 20bceb605f48
child 20 f22952603f29
--- a/src/kdtree.cc	Sun Nov 25 21:47:10 2007 +0100
+++ b/src/kdtree.cc	Sun Nov 25 22:22:40 2007 +0100
@@ -90,7 +90,7 @@
 KdNode::~KdNode()
 {
 	if (isLeaf())
-		;//delete shapes;  // this sigsegvs for unknown reason
+		delete shapes;
 	else
 		delete[] children;
 }
@@ -237,7 +237,7 @@
 	float rnum = splitpos->rnum;
 
 	// split this node
-	//delete shapes;
+	delete shapes;
 	children = new KdNode[2];
 	int state = 0;
 	for (sh = sslist.begin(); sh != sslist.end(); sh++)
@@ -301,7 +301,9 @@
 void KdTree::build()
 {
 	root = new KdNode();
-	root->shapes = &shapes;
+	ShapeList::iterator shape;
+	for (shape = shapes.begin(); shape != shapes.end(); shape++)
+		root->addShape(*shape);
 	root->subdivide(bbox, 0);
 	built = true;
 }