Exemplo n.º 1
0
        public void AppendVoxBox(VoxBox voxBox)
        {
            int key = GetKey(voxBox.floorCellIdxX, voxBox.floorCellIdxZ);
            LinkedList <SolidSpan> cellSpanList;

            if (soildSpanDict.TryGetValue(key, out cellSpanList) == false)
            {
                cellSpanList       = new LinkedList <SolidSpan>();
                soildSpanDict[key] = cellSpanList;
            }

            AppendVoxBoxToSpanHeightList(cellSpanList, voxBox);
        }
Exemplo n.º 2
0
        void AppendVoxBoxToSpanHeightList(LinkedList <SolidSpan> cellSpanList, VoxBox voxBox)
        {
            int    voxStartIdx = voxBox.heightCellStartIdx;
            int    voxEndIdx   = voxBox.heightCellStartIdx;
            double yPosStart   = voxBox.yPosRange[0];
            double yPosEnd     = voxBox.yPosRange[1];

            LinkedListNode <SolidSpan> startNode = null;
            LinkedListNode <SolidSpan> endNode   = null;

            var node = cellSpanList.First;

            for (; node != null; node = node.Next)
            {
                if (node.Value.startCellIdx > voxStartIdx && startNode == null)
                {
                    startNode = node;
                }
                else if (voxStartIdx >= node.Value.startCellIdx &&
                         voxStartIdx <= node.Value.endCellIdx)
                {
                    yPosStart   = node.Value.startPos;
                    voxStartIdx = node.Value.startCellIdx;
                    startNode   = node;
                }

                if (node.Value.startCellIdx > voxEndIdx && endNode == null)
                {
                    endNode = node.Previous;
                    break;
                }
                else if (voxEndIdx >= node.Value.startCellIdx &&
                         voxEndIdx <= node.Value.endCellIdx)
                {
                    yPosEnd   = node.Value.endPos;
                    voxEndIdx = node.Value.endCellIdx;
                    endNode   = node;
                    break;
                }
            }

            if (startNode != null && endNode == null)
            {
                endNode = cellSpanList.Last;
            }

            SolidSpan voxSpan = new SolidSpan()
            {
                startPos     = yPosStart,
                endPos       = yPosEnd,
                startCellIdx = voxStartIdx,
                endCellIdx   = voxEndIdx
            };

            if (startNode == null && endNode == null)
            {
                if (node == cellSpanList.First)
                {
                    cellSpanList.AddFirst(voxSpan);
                }
                else
                {
                    cellSpanList.AddLast(voxSpan);
                }
            }
            else
            {
                var prevNode = startNode.Previous;
                var mnode    = startNode;
                LinkedListNode <SolidSpan> tmpNode;
                bool flag = true;

                while (flag)
                {
                    if (mnode == endNode)
                    {
                        flag = false;
                    }

                    tmpNode = mnode.Next;
                    cellSpanList.Remove(mnode);
                    mnode = tmpNode;
                }

                if (prevNode == null)
                {
                    cellSpanList.AddFirst(voxSpan);
                }
                else
                {
                    cellSpanList.AddAfter(prevNode, voxSpan);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据投影Rect生成体素box
        /// </summary>
        /// <param name="cellProjectionRect"></param>
        /// <param name="floorGridCenter">在地板单元格的中心位置坐标</param>
        void CreateVoxBoxToList(int[] gridYIdxs, int cellx, int cellz)
        {
            VoxBox voxBox = new VoxBox(voxBoxList.Count.ToString(), voxSpace, cellx, cellz, gridYIdxs[0], gridYIdxs[1]);

            voxBoxList.Add(voxBox);
        }