public BinnedSAHBVHController() { this.boundsPool = AABB3.CreateAABBPool(); this.indices = new List <int>(); this.sah = new BinnedSAH(boundsPool); this.objectBounds = new List <AABB3>(); }
public static BVH <Value> Build(IList <AABB3> bounds, IList <int> indices, int offset, int length, BinnedSAH sah, IMemoryPool <BVH <Value> > alloc) { if (length <= 0) { return(null); } int countFromLeft; if (length <= 2 || !sah.Build(bounds, indices, offset, length, out countFromLeft)) { return(alloc.New().Reset(offset, length)); } var l = Build(bounds, indices, offset, countFromLeft, sah, alloc); var r = Build(bounds, indices, offset + countFromLeft, length - countFromLeft, sah, alloc); if (l != null ^ r != null) { return((l != null) ? l : r); } return(alloc.New().Reset(offset, length).SetChildren(l, r)); }