Unity physics BVH tree skill level.

I am looking through the BVH tree source code, and it just seems out of my scope of knowledge to fully comprehend. I am a little intimidated. I find myself reading through it and getting lost as to how certain parts communicate with others, especially with the pointers and data types like NativeStream.

This post is more of a general programming question. What kind of skill level/knowledge did it take to build this tree? Is this something an “average” programmer can do? Or is it something that takes someone or multiple people with alot of experience to create?

it’d be great if you linked to what you were talking about.

1 Like

He’s talking about BVH tree (Bounding Volume Hierarchy), on which Unity dots physics relies for efficient queries, and about sources in physics package.

...\Library\PackageCache\com.unity.physics\Unity.Physics\Collision\Geometry\BoundingVolumeHierarchyBuilder.cs
...\Library\PackageCache\com.unity.physics\Unity.Physics\Collision\Geometry\BoundingVolumeHierarchy.cs

Well, “average” can be a very wide definition. But in common it’s not so hard, you need just get the idea of how it works “on paper” before code, and if you have knowledge in any other tree-like structure types (Octree, K-d tree) you will find that they share many ideas. About the code side, well, if you experienced enough in unsafe code then it will be as easy for you as implement it in a straightforward way in managed land, in Unity case unmanaged implementation was chosen because of performance and (mostly I think) because of Burst capability which will give huge performance bust for that implementation (and to be honest there are not so many unusual unsafe things, mostly for nodes, for emulate references in structs for staying in Burst compatible area, and arrays-like behaviour)

2 Likes

Yeah I kind of know what he’s talking about… but putting it on the reader to go do the basic research as to find it, let alone read the code just to give an opinion… basically I’m being snarky because if he wants meaningful responses he should make it easier on the person helping him.

That said, thanks for linking it for him. I took a look and the code isn’t bad. If you are not familiar with unsafe c#, that will be the biggest coding hurdle for you to do external research on.

My big problem with that code is lack of documentation compounding my non-understanding of the BVH algorithm. So things like ProcessAxis() would make a lot more sense if I knew why that’s significant.

Thanks. I know its kind of a bad question but I really just wanted to have an idea of where I stand with my programming abilities. It looks like I still have alot to learn.