src/kdtree.h
branchpyrit
changeset 12 f4fcabf05785
parent 11 4d192e13ee84
child 15 a0a3e334744f
--- a/src/kdtree.h	Fri Nov 23 16:14:38 2007 +0100
+++ b/src/kdtree.h	Sat Nov 24 21:55:41 2007 +0100
@@ -13,51 +13,6 @@
 {
 };
 
-class SortableShape
-{
-public:
-	Shape *shape;
-	BBox bbox;
-	short axis;
-	short mark;
-
-	SortableShape(Shape *aShape, short &aAxis): shape(aShape), axis(aAxis), mark(0)
-		{ bbox = shape->get_bbox(); };
-	friend bool operator<(const SortableShape& a, const SortableShape& b)
-		{ return a.bbox.L.cell[a.axis] < b.bbox.L.cell[b.axis]; };
-	void setAxis(short aAxis) { axis = aAxis; };
-	void setMark() { mark = 1; };
-	short hasMark() { return mark; };
-};
-
-class SortableShapeList: public vector<SortableShape>
-{
-public:
-	SortableShapeList(ShapeList &shapes, short axis)
-	{
-		ShapeList::iterator shape;
-		for (shape = shapes.begin(); shape != shapes.end(); shape++)
-			push_back(SortableShape(*shape, axis));
-	};
-};
-
-class SplitPos
-{
-public:
-	float pos;
-	int lnum, rnum;
-	SplitPos(): pos(0.0), lnum(0), rnum(0) {};
-	SplitPos(float &aPos): pos(aPos), lnum(0), rnum(0) {};
-	friend bool operator<(const SplitPos& a, const SplitPos& b)
-		{ return a.pos < b.pos; };
-	friend bool operator==(const SplitPos& a, const SplitPos& b)
-		{ return a.pos == b.pos; };
-};
-
-class SplitList: public vector<SplitPos>
-{
-};
-
 class Container
 {
 protected:
@@ -68,7 +23,7 @@
 	virtual ~Container() {};
 	virtual void addShape(Shape* aShape);
 	//void addShapeNoExtend(Shape* aShape) { shapes.push_back(aShape); };
-        virtual Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
+	virtual Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
 		float &nearest_distance);
 	virtual void optimize() {};
 };
@@ -108,8 +63,10 @@
 public:
 	KdTree() : Container(), built(false) {};
 	void addShape(Shape* aShape) { Container::addShape(aShape); built = false; };
+	Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
+		float &nearest_distance);
+	void optimize() { build(); };
 	void build();
-	void optimize() { build(); };
 	void save(ostream &str, KdNode *node = NULL);
 	void load(istream &str, KdNode *node = NULL);
 };