Home

Awesome

Unity Bounding Volume Heirachy

BVH GIF

Dynamic Unity 3d BVH - 3d Bounding Volume Hierarchy.

Modified from David Jeske's SimpleScene

About

This is a 3d Bounding Volume Hiearchy implementation for Unity in C#. It is used for sorting objects that occupy volume and answering geometric queries about them; such as ray, box, and sphere intersection.

It includes an efficient algorithm for incrementally re-optimizing the BVH when contained objects move. This variation works in Unity and supports GameObjects.

For more information about what a BVH is, and about how to use this code, see David's CodeProject article:

<table> <tr> <td>BVH.cs</td> <td> The root interface to the BVH. Call RenderDebug() to render the debug bounds using DrawMeshInstanced.</td></tr> <tr> <td>BVHNode.cs</td> <td> The code for managing, traversing, and optimizing the BVH </td></tr> <tr> <td>BVHGameObjectAdaptor.cs</td> <td> A IBVHNodeAdaptor with GameObject integration.</td></tr> <tr> <td>BVHSphereAdaptor.cs</td> <td> An example IBVHNodeAdaptor for spheres in the BVH.</td></tr> <tr> <td>IBVHNodeAdaptor.cs</td> <td> Base interface for any BVHNodeAdaptor. Implement this to create a new adaptor.</td></tr> </table>

Notable Modifications

References