--- a/src/kdtree.h Sun Nov 25 15:50:01 2007 +0100
+++ b/src/kdtree.h Sun Nov 25 17:58:29 2007 +0100
@@ -31,13 +31,14 @@
class KdNode
{
float split;
- bool leaf; /* is this node a leaf? */
- short axis; /* 0,1,2 => x,y,z */
- KdNode *children;
+ short axis; /* 0,1,2 => x,y,z; 3 => leaf */
public:
- ShapeList shapes;
+ union {
+ KdNode *children;
+ ShapeList *shapes;
+ };
- KdNode() : leaf(true), axis(0), shapes() {};
+ KdNode() : axis(3) { shapes = new ShapeList(); };
void setAxis(short aAxis) { axis = aAxis; };
short getAxis() { return axis; };
@@ -45,13 +46,13 @@
void setSplit(float aSplit) { split = aSplit; };
float getSplit() { return split; };
- void setLeaf(bool aLeaf) { leaf = aLeaf; };
- bool isLeaf() { return leaf; };
+ void setLeaf() { axis = 3; };
+ bool isLeaf() { return axis == 3; };
KdNode *getLeftChild() { return children; };
KdNode *getRightChild() { return children+1; };
- void addShape(Shape* aShape) { shapes.push_back(aShape); };
+ void addShape(Shape* aShape) { shapes->push_back(aShape); };
void subdivide(BBox bbox, int depth);
};