Skip to content

rossborchers/UnityBoundingVolumeHeirachy

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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:

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

Notable Modifications

  • Supports GameObjects through a custom implementation of IBVHNodeAdapter (BVHGameObjectAdapter). Uses child renderers bounds to calculate bounds. Could be easily swapped out for any other bounds calculation. See BVHGameObjectAdaptor.GetBounds.
  • BVHHelper provides a radial node traversal test to be used with Traverse().
  • Code has been refactored to be closer to the .NET naming conventions.
  • Includes some tests that can be used as a starting reference.

References

About

Unity Bounding Volume Heirachy (BVH)

Topics

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages