src/kdtree.h
branchpyrit
changeset 21 79b516a3803d
parent 16 20bceb605f48
equal deleted inserted replaced
20:f22952603f29 21:79b516a3803d
    60 
    60 
    61 class KdTree: public Container
    61 class KdTree: public Container
    62 {
    62 {
    63 	KdNode *root;
    63 	KdNode *root;
    64 	bool built;
    64 	bool built;
       
    65 	int max_depth;
    65 public:
    66 public:
    66 	KdTree() : Container(), root(NULL), built(false) {};
    67 	KdTree() : Container(), root(NULL), built(false), max_depth(32) {};
    67 	~KdTree() { if (root) delete root; };
    68 	~KdTree() { if (root) delete root; };
    68 	void addShape(Shape* aShape) { Container::addShape(aShape); built = false; };
    69 	void addShape(Shape* aShape) { Container::addShape(aShape); built = false; };
    69 	Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
    70 	Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
    70 		float &nearest_distance);
    71 		float &nearest_distance);
    71 	void optimize() { build(); };
    72 	void optimize() { build(); };
    72 	void build();
    73 	void build();
    73 	void save(ostream &str, KdNode *node = NULL);
    74 	void save(ostream &str, KdNode *node = NULL);
    74 	void load(istream &str, KdNode *node = NULL);
    75 	void load(istream &str, KdNode *node = NULL);
       
    76 	void setMaxDepth(int md) { max_depth = md; };
    75 };
    77 };
    76 
    78 
    77 #endif
    79 #endif