include/kdtree.h
branchpyrit
changeset 46 6493fb65f0b1
parent 44 3763b26244f0
child 74 09aedbf5f95f
equal deleted inserted replaced
45:76b254ce92cf 46:6493fb65f0b1
    34 #include "vector.h"
    34 #include "vector.h"
    35 #include "scene.h"
    35 #include "scene.h"
    36 
    36 
    37 using namespace std;
    37 using namespace std;
    38 
    38 
       
    39 /**
       
    40  * a node of kd-tree
       
    41  */
    39 class KdNode
    42 class KdNode
    40 {
    43 {
    41 	Float split;
    44 	Float split;
    42 	short axis; /* 0,1,2 => x,y,z; 3 => leaf */
    45 	short axis; /* 0,1,2 => x,y,z; 3 => leaf */
    43 public:
    46 public:
    64 	void addShape(Shape* aShape) { shapes->push_back(aShape); };
    67 	void addShape(Shape* aShape) { shapes->push_back(aShape); };
    65 
    68 
    66 	void subdivide(BBox bbox, int maxdepth);
    69 	void subdivide(BBox bbox, int maxdepth);
    67 };
    70 };
    68 
    71 
       
    72 /**
       
    73  * kd-tree
       
    74  */
    69 class KdTree: public Container
    75 class KdTree: public Container
    70 {
    76 {
    71 	KdNode *root;
    77 	KdNode *root;
    72 	bool built;
    78 	bool built;
    73 	int max_depth;
    79 	int max_depth;