I'm implementing octree data structure. In octants i store triangles. So question: When i need to to stop dividing octants in Octree? I think about max depth or number of max number of triangles in octant, but how i can calculate this values?
CodePudding user response:
A good rule for many circumstances is to subdivide a box if the number of triangles in it is more than twice its depth in the tree. This ensures that:
- The total space consumed by the tree is at most proportional to the number of trianges;
- The total time spent traversing down the tree is at most proportional to the number of triangles you'll have to directly process in the target leaf; and
- You can still go deep when necessary to decompose a tight cluster.