equal
deleted
inserted
replaced
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 |