include/octree.h
branchpyrit
changeset 46 6493fb65f0b1
parent 44 3763b26244f0
child 92 9af5c039b678
equal deleted inserted replaced
45:76b254ce92cf 46:6493fb65f0b1
    33 
    33 
    34 #include <assert.h>
    34 #include <assert.h>
    35 
    35 
    36 using namespace std;
    36 using namespace std;
    37 
    37 
       
    38 /**
       
    39  * a node of octree
       
    40  */
    38 class OctreeNode
    41 class OctreeNode
    39 {
    42 {
    40     union {
    43     union {
    41 		OctreeNode *children; // pointer to first of eight children
    44 		OctreeNode *children; // pointer to first of eight children
    42 		ShapeList *shapes;    // pointer to shape array, if this is leaf
    45 		ShapeList *shapes;    // pointer to shape array, if this is leaf
    62 	void setShapes(ShapeList *const ashapes) { shapes = ashapes; assert(!isLeaf()); setLeaf(); };
    65 	void setShapes(ShapeList *const ashapes) { shapes = ashapes; assert(!isLeaf()); setLeaf(); };
    63 
    66 
    64 	void subdivide(BBox bbox, int maxdepth);
    67 	void subdivide(BBox bbox, int maxdepth);
    65 };
    68 };
    66 
    69 
       
    70 /**
       
    71  * optimized octree
       
    72  */
    67 class Octree: public Container
    73 class Octree: public Container
    68 {
    74 {
    69 	OctreeNode *root;
    75 	OctreeNode *root;
    70 	bool built;
    76 	bool built;
    71 	int max_depth;
    77 	int max_depth;