public static IEnumerable <Value> Intersect(BVH <Value> t, FastBounds bb) { if (t == null || !t.bb.Intersects(bb)) { yield break; } if (!t.IsLeaf()) { foreach (var s in t.ch) { if (s != null) { foreach (var r in Intersect(s, bb)) { yield return(r); } } } } foreach (var v in t.Values) { if (v != null) { yield return(v); } } }
public static int Count(BVH <Value> t) { if (t == null) { return(0); } return(1 + Count(t.ch [0]) + Count(t.ch [1])); }
public static IMemoryPool <BVH <Value> > Clear(BVH <Value> t, IMemoryPool <BVH <Value> > alloc) { if (t == null) { return(alloc); } for (var i = 0; i < 2; i++) { Clear(t.ch [i], alloc); } return(alloc.Free(t.Clear())); }
public static void DrawBounds(BVH <Value> t, int depth, int length) { if (t == null || depth >= length) { return; } Gizmos.DrawWireCube(t.bb.Center, t.bb.Size); foreach (var s in t.ch.Where(s => s != null)) { DrawBounds(s, depth + 1, length); } }
public static IList <Value> Intersect(BVH <Value> t, FastBounds bb, IList <Value> result) { if (t != null && t.bb.Intersects(bb)) { Intersect(t.ch[0], bb, result); Intersect(t.ch[1], bb, result); foreach (var v in t.Values) { if (v != null) { result.Add(v); } } } return(result); }
public virtual void DrawBounds(int depthFrom, int length) { BVH <Value> .DrawBounds(_root, -depthFrom, length); }
public static int CountValues(BVH <Value> t) { return(t == null ? 0 : (t.Values.Count + CountValues(t.ch [0]) + CountValues(t.ch [1]))); }
public virtual BaseBVHController <Value> Clear() { BVH <Value> .Clear(_root, _pool); return(this); }
public BVH <Value> SetChildren(BVH <Value> l, BVH <Value> r) { ch [0] = l; ch [1] = r; return(this); }