Example #1
0
        public override BaseBVHController <Value> Build(IList <FastBounds> bounds, IList <Value> dataset)
        {
            Clear();

            sah.Clear();
            for (var i = 0; i < bounds.Count; i++)
            {
                indices.Add(i);
            }

            using (new ScopedPlug <List <AABB3> >(objectBounds, obs => MemoryPoolUtil.Free(obs, boundsPool))) {
                foreach (var b in bounds)
                {
                    var aabb = boundsPool.New().Set(b);
                    objectBounds.Add(aabb);
                }

                if ((_root = Build(objectBounds, indices, 0, indices.Count, sah, _pool)) != null)
                {
                    _root.Build(new IndexedList <FastBounds>(indices, bounds), new IndexedList <Value>(indices, dataset));
                }
            }

            return(this);
        }
Example #2
0
        public void Reset(int nextBinCount)
        {
            if (binCount == nextBinCount)
            {
                return;
            }
            var prevBinCount = binCount;

            binCount = nextBinCount;
            cleared  = false;

            if (bbs != null)
            {
                MemoryPoolUtil.Free(bbs, aabbPool);
            }
            System.Array.Resize(ref bbs, nextBinCount);
            for (var i = 0; i < bbs.Length; i++)
            {
                bbs[i] = aabbPool.New();
            }

            System.Array.Resize(ref bins, nextBinCount);
            for (var i = prevBinCount; i < nextBinCount; i++)
            {
                bins[i] = new List <int>();
            }

            System.Array.Resize(ref lefts, nextBinCount);
            System.Array.Resize(ref rights, nextBinCount);
        }
Example #3
0
 public void Dispose()
 {
     MemoryPoolUtil.Free(bbs, aabbPool);
 }