I have an application in which I am using an octree to store a volume mesh of axis-aligned bounding boxes (AABBs).
Given a water-tight triangle mesh, I need to:
find if an AABB is intersected by or completely inside/outside of the surface mesh,
clip the surface mesh with the intersected AABBs to generate triangles that completely lie within each AABB.
The triangulation and the octree containing the AABBs are both dynamic. The number of leaf nodes in the octree is huge. The number of triangles in the surface mesh is much smaller (O(10^9 - 10^13) octree nodes, vs O(10^6) triangles).
Which data-structures and algorithm are suitable for my problem?
Right now I:
- store the triangles in the same octree as the volume mesh,
- store each triangle in the smallest octree node that contains it,
- clip the triangle mesh with a single AABB by traversing from that AABB to both the root node and its leafs clipping each triangle contained in the nodes with the AABB.
The triangles in the nodes until the leafs are fully contained within the AABB and don't need any clipping, while the ones contained in the nodes from the AABB to the root need clipping. However:
due to the way I am storing the triangles I don't have an upper bound in the maximum number of triangles that can be store within each single octree node, so I don't have an upper bound in the number of triangles that have to be clip when clipping the surface mesh with a single AABB.
testing if an AABB is intersected by the triangle mesh might require clipping if triangles are stored in the root node.
have no fast way of determining if a node is inside/outside/intersected by the mesh.