include/kdtree.h
branchpyrit
changeset 76 3b60fd0bea64
parent 74 09aedbf5f95f
child 78 9569e9f35374
--- a/include/kdtree.h	Mon Apr 21 09:05:09 2008 +0200
+++ b/include/kdtree.h	Mon Apr 21 19:35:27 2008 +0200
@@ -59,16 +59,14 @@
 	short getAxis() { return flags & 3; };
 
 	void setSplit(Float aSplit) { split = aSplit; };
-	Float getSplit() { return split; };
+	Float& getSplit() { return split; };
 
 	void setChildren(KdNode *node) { children = node; assert((flags & 3) == 0); };
-	KdNode *getLeftChild() { return (KdNode*)((off_t)children & ~3); };
-	KdNode *getRightChild() { return (KdNode*)((off_t)children & ~3) + 1; };
+	KdNode* getLeftChild() { return (KdNode*)((off_t)children & ~3); };
+	KdNode* getRightChild() { return (KdNode*)((off_t)children & ~3) + 1; };
 
-	ShapeList *getShapes() { return (ShapeList*)((off_t)shapes & ~3); };
+	ShapeList* getShapes() { return (ShapeList*)((off_t)shapes & ~3); };
 	void addShape(Shape* aShape) { getShapes()->push_back(aShape); };
-
-	void subdivide(BBox bbox, int maxdepth);
 };
 
 /**
@@ -79,6 +77,8 @@
 	KdNode *root;
 	bool built;
 	int max_depth;
+
+	void recursive_build(KdNode *node, BBox bbox, int maxdepth);
 public:
 	KdTree() : Container(), root(NULL), built(false), max_depth(32) {};
 	~KdTree() { if (root) delete root; };