include/octree.h
branchpyrit
changeset 103 3b3257a410fe
parent 98 64638385798a
equal deleted inserted replaced
102:de3e9ea18f56 103:3b3257a410fe
    71 /**
    71 /**
    72  * optimized octree
    72  * optimized octree
    73  */
    73  */
    74 class Octree: public Container
    74 class Octree: public Container
    75 {
    75 {
       
    76 	static const int MAX_DEPTH;
    76 	OctreeNode *root;
    77 	OctreeNode *root;
    77 	const int max_depth;
       
    78 	bool built;
    78 	bool built;
    79 public:
    79 public:
    80 	/** default constructor,
    80 	Octree() : Container(), root(NULL), built(false) {};
    81 	 * maximum depth of tree is set to 10 */
    81 	~Octree() { if (root) delete root; };
    82 	Octree() : Container(), root(NULL), max_depth(10), built(false) {};
       
    83 
    82 
    84 	/** constructor
       
    85 	 * @param[in] maxdepth	maximum depth of the tree */
       
    86 	Octree(int maxdepth) : Container(), root(NULL), max_depth(maxdepth), built(false) {};
       
    87 	~Octree() { if (root) delete root; };
       
    88 	void addShape(const Shape* aShape) { Container::addShape(aShape); built = false; };
    83 	void addShape(const Shape* aShape) { Container::addShape(aShape); built = false; };
    89 	const Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
    84 	const Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray,
    90 		Float &nearest_distance);
    85 		Float &nearest_distance);
    91 	void optimize() { build(); };
    86 	void optimize() { build(); };
    92 
    87