Getting Started
...
Glossary
#-G Terms

Binary Space Partitioning

3min

A BSP tree is a binary tree data structure used in 3D computer graphics for efficient collision detection and visibility culling. BSP stands for "binary space partitioning," and the tree is used to partition a 3D space into smaller sub-spaces.

BSP trees are more efficient than traditional bounding volume hierarchies (BVHs) for collision detection and visibility culling because they can be traversed in a depth-first manner, which means that only the sub-spaces that are relevant to the query need to be traversed. BVHs, on the other hand, need to be traversed in a breadth-first manner, which can be slow for large scenes.

BSP trees are typically constructed by first creating a root node that contains the entire 3D space. The root node is then split into two child nodes, each of which contains a half-space of the 3D space. This process is repeated recursively until each leaf node contains a single primitive (e.g., a triangle).

When a collision detection or visibility culling query is performed, the BSP tree is traversed from the root node to a leaf node. At each node, the plane of the node is checked to see if it intersects the query object. If it does intersect, then the query is further processed by traversing the child node on the side of the plane that contains the query object. If it does not intersect, then the query is discarded.

Here are some of the advantages of using BSP trees for collision detection and visibility culling:

  • Efficient: BSP trees are more efficient than traditional BVHs for collision detection and visibility culling because they can be traversed in a depth-first manner.
  • Scalable: BSP trees can be scaled to large scenes without sacrificing performance.
  • Robust: BSP trees are robust to changes in the scene, such as the addition or removal of objects.

Here are some of the disadvantages of using BSP trees:

  • More complex: BSP trees are more complex to construct and maintain than traditional BVHs.
  • Not as widely supported: BSP trees are not as widely supported as traditional BVHs by graphics libraries and engines.

Overall, BSP trees are a powerful and efficient data structure for collision detection and visibility culling in 3D graphics.

Here are some additional tips for using BSP trees:

  • Use the appropriate number of splitting planes: The number of splitting planes used to construct the BSP tree will affect the performance of the tree for collision detection and visibility culling. Too few splitting planes will result in a tree that is too unbalanced, while too many splitting planes will result in a tree that is too shallow.
  • Use the appropriate splitting criteria: The splitting criteria used to select the splitting plane for each node will also affect the performance of the tree for collision detection and visibility culling. A good splitting criteria will result in a tree that is well-balanced and efficient.
  • Update the BSP tree when the scene changes: The BSP tree should be updated whenever the scene changes, such as the addition or removal of objects. This will ensure that the tree is always accurate and efficient.

Feedback

Please be sure to submit issues or feature requests through the embedded feedback form. In the event it is a major issue please contact us directly through Discord.

Updated 03 Apr 2024
Doc contributor
Did this page help you?