Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
 public static int Count(BVH <Value> t)
 {
     if (t == null)
     {
         return(0);
     }
     return(1 + Count(t.ch [0]) + Count(t.ch [1]));
 }
Esempio n. 3
0
        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()));
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 public virtual void DrawBounds(int depthFrom, int length)
 {
     BVH <Value> .DrawBounds(_root, -depthFrom, length);
 }
Esempio n. 7
0
 public static int CountValues(BVH <Value> t)
 {
     return(t == null ? 0 : (t.Values.Count + CountValues(t.ch [0]) + CountValues(t.ch [1])));
 }
Esempio n. 8
0
        public virtual BaseBVHController <Value> Clear()
        {
            BVH <Value> .Clear(_root, _pool);

            return(this);
        }
Esempio n. 9
0
 public BVH <Value> SetChildren(BVH <Value> l, BVH <Value> r)
 {
     ch [0] = l;
     ch [1] = r;
     return(this);
 }