bsp-tree
A Binary Space Partitioning (BSP) tree implementation in Rust for 3D polygon management. The BSP tree works with flat polygons (triangles, quads, etc.).
BSP trees recursively subdivide space using planes, enabling efficient spatial queries and correct back-to-front rendering of overlapping geometry without a depth buffer.
Features
- Geometric primitives:
Polygon,Triangle,Rectangle - Plane operations: Classification of points and polygons relative to planes
- Polygon splitting:
Cuttabletrait for splitting geometry by planes - BSP tree construction: Automatic partitioning with configurable plane selection
- Ordered traversal: Front-to-back or back-to-front traversal via
BspVisitor
Usage
use ;
use Point3;
// Create polygons
let poly = new;
// Build the tree
let tree = from_polygons;
assert_eq!;
Traversal
use ;
use Point3;
;
let tree = from_polygons;
let eye = new;
// Back-to-front for correct transparency rendering
tree.traverse_back_to_front;
Documentation
See the GitHub repository for full documentation, screenshots, and visualization examples.
License
Apache-2.0 - See LICENSE for details.