equal
deleted
inserted
replaced
15 delete[] children; |
15 delete[] children; |
16 } |
16 } |
17 |
17 |
18 void OctreeNode::subdivide(BBox bbox, int maxdepth) |
18 void OctreeNode::subdivide(BBox bbox, int maxdepth) |
19 { |
19 { |
20 if (maxdepth <= 0 || shapes->size() <= 4) |
|
21 return; |
|
22 |
|
23 // make children |
20 // make children |
24 children = new OctreeNode[8]; |
21 children = new OctreeNode[8]; |
25 |
22 |
26 // evaluate centres for axes |
23 // evaluate centres for axes |
27 const Float xsplit = (bbox.L.x + bbox.H.x)*0.5; |
24 const Float xsplit = (bbox.L.x + bbox.H.x)*0.5; |
67 delete shapes; |
64 delete shapes; |
68 shapes = NULL; |
65 shapes = NULL; |
69 |
66 |
70 // recursive subdivision |
67 // recursive subdivision |
71 for (int i = 0; i < 8; i++) |
68 for (int i = 0; i < 8; i++) |
72 children[i].subdivide(childbb[i], maxdepth-1); |
69 if (maxdepth > 1 && getChild(i)->shapes->size() > 4) |
|
70 children[i].subdivide(childbb[i], maxdepth-1); |
73 } |
71 } |
74 |
72 |
75 void Octree::build() |
73 void Octree::build() |
76 { |
74 { |
77 dbgmsg(1, "* building octree\n"); |
75 dbgmsg(1, "* building octree\n"); |