Ejemplo n.º 1
0
        private void DoExtend(int shiftX, int shiftY, int shiftZ, SetItemResult <T> result)
        {
            var prevSize     = Size;
            var prevChildren = Children;

            var offsetShift = new IntVector(shiftX, shiftY, shiftZ) * prevSize;

            result.OffsetShift = result.OffsetShift + offsetShift;
            Offset            += offsetShift;

            SetSize(prevSize * 2);

            var child      = new BinaryGridBranch <T>(prevSize, prevChildren);
            var childIndex = -shiftX + 2 * -shiftY + 4 * -shiftZ;

            Children             = new IBinarySubGrid <T> [8];
            Children[childIndex] = child;
        }
        private IBinarySubGrid <T> GetOrCreateChild(int index)
        {
            var halfSize = HalfSize;
            var child    = Children[index];

            if (child == null)
            {
                if (halfSize == BinaryGridLeaf <T> .Size)
                {
                    child = new BinaryGridLeaf <T>();
                }
                else
                {
                    child = new BinaryGridBranch <T>(halfSize);
                }
                Children[index] = child;
            }
            return(child);
        }