Understand the BVH CSG implementation architecture
mainThe three-bvh-csg library is designed for high-performance Constructive Solid Geometry (CSG) operations using Bounding Volume Hierarchies (BVH) and half-edge data structures.
Core Design Priorities
- Compact Memory: Uses typed arrays to keep memory utilization low.
- Low Garbage Collection (GC) Impact: Employs data pooling (e.g., triangle instances) and modifies existing geometry buffers in place to minimize temporary data creation. Brushes cache data to speed up subsequent operations.
- High Performance: Uses half-edge structures and BVH to quickly discover and cull triangle intersections.
- Low Mesh Complexity: The BVH approach minimizes the number of triangles that need to be split, reducing the complexity of the resulting mesh.
Key Data Structures
- Half-Edge Structure: Pre-generated per
Brushto allow fast traversal of connected triangles. - BVH: Pre-generated per
Brushto accelerate intersection detection between geometries. - Group Indices: A map of group indices to triangles, allowing resulting triangles to be mapped to their appropriate material indices.