Ejemplo n.º 1
0
        private void RemoveMinMarkedForAddition()
        {
            CellToAddHeapItem item = this.m_toAdd.RemoveMin();

            m_heapItemAllocator.Deallocate(item);
            this.m_markedForAddition.Remove(item.Position);
        }
Ejemplo n.º 2
0
        private void MarkCellForAdditionInternal(ref Vector3I cellPos, float weight)
        {
            CellToAddHeapItem item = m_heapItemAllocator.Allocate();

            item.Position = cellPos;
            this.m_toAdd.Insert(item, weight);
            this.m_markedForAddition.Add((Vector3I)cellPos);
        }
Ejemplo n.º 3
0
 public override unsafe void DebugDraw(ref Matrix drawMatrix)
 {
     if (MyFakes.DEBUG_DRAW_NAVMESH_PROCESSED_VOXEL_CELLS)
     {
         Vector3 vector  = Vector3.TransformNormal(this.m_cellSize, (Matrix)drawMatrix);
         Vector3 vector2 = Vector3.Transform((Vector3)(this.m_voxelMap.PositionLeftBottomCorner - this.m_voxelMap.PositionComp.GetPosition()), (Matrix)drawMatrix);
         foreach (Vector3I vectori in this.m_processedCells)
         {
             BoundingBoxD xd;
             xd.Min = vector2 + (vector * (new Vector3(0.0625f) + vectori));
             BoundingBoxD *xdPtr1 = (BoundingBoxD *)ref xd;
             xdPtr1->Max = xd.Min + vector;
             xd.Inflate((double)-0.20000000298023224);
             MyRenderProxy.DebugDrawAABB(xd, Color.Orange, 1f, 1f, false, false, false);
             MyRenderProxy.DebugDrawText3D(xd.Center, vectori.ToString(), Color.Orange, 0.5f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false);
         }
     }
     if (MyFakes.DEBUG_DRAW_NAVMESH_CELLS_ON_PATHS)
     {
         Vector3     vector3 = Vector3.TransformNormal(this.m_cellSize, (Matrix)drawMatrix);
         Vector3     vector4 = Vector3.Transform((Vector3)(this.m_voxelMap.PositionLeftBottomCorner - this.m_voxelMap.PositionComp.GetPosition()), (Matrix)drawMatrix);
         MyCellCoord coord   = new MyCellCoord();
         foreach (ulong num in this.m_cellsOnWayCoords)
         {
             BoundingBoxD xd2;
             coord.SetUnpack(num);
             Vector3I coordInLod = coord.CoordInLod;
             xd2.Min = vector4 + (vector3 * (new Vector3(0.0625f) + coordInLod));
             BoundingBoxD *xdPtr2 = (BoundingBoxD *)ref xd2;
             xdPtr2->Max = xd2.Min + vector3;
             xd2.Inflate((double)-0.30000001192092896);
             MyRenderProxy.DebugDrawAABB(xd2, Color.Green, 1f, 1f, false, false, false);
         }
     }
     if (MyFakes.DEBUG_DRAW_NAVMESH_PREPARED_VOXEL_CELLS)
     {
         Vector3  vector5          = Vector3.TransformNormal(this.m_cellSize, (Matrix)drawMatrix);
         Vector3  vector6          = Vector3.Transform((Vector3)(this.m_voxelMap.PositionLeftBottomCorner - this.m_voxelMap.PositionComp.GetPosition()), (Matrix)drawMatrix);
         float    negativeInfinity = float.NegativeInfinity;
         Vector3I zero             = Vector3I.Zero;
         int      index            = 0;
         while (true)
         {
             if (index >= this.m_toAdd.Count)
             {
                 for (int i = 0; i < this.m_toAdd.Count; i++)
                 {
                     BoundingBoxD      xd3;
                     CellToAddHeapItem local1   = this.m_toAdd.GetItem(i);
                     float             num6     = local1.HeapKey;
                     Vector3I          position = local1.Position;
                     xd3.Min = vector6 + (vector5 * (new Vector3(0.0625f) + position));
                     BoundingBoxD *xdPtr3 = (BoundingBoxD *)ref xd3;
                     xdPtr3->Max = xd3.Min + vector5;
                     xd3.Inflate((double)-0.10000000149011612);
                     Color aqua = Color.Aqua;
                     if (position.Equals(zero))
                     {
                         aqua = Color.Red;
                     }
                     MyRenderProxy.DebugDrawAABB(xd3, aqua, 1f, 1f, false, false, false);
                     string text = $"{num6.ToString("n2")}";
                     MyRenderProxy.DebugDrawText3D(xd3.Center, text, aqua, 0.7f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false);
                 }
                 break;
             }
             CellToAddHeapItem item    = this.m_toAdd.GetItem(index);
             float             heapKey = item.HeapKey;
             if (heapKey > negativeInfinity)
             {
                 negativeInfinity = heapKey;
                 zero             = item.Position;
             }
             index++;
         }
     }
     MyRenderProxy.DebugDrawSphere(this.m_debugPos1, 0.2f, Color.Red, 1f, false, false, true, false);
     MyRenderProxy.DebugDrawSphere(this.m_debugPos2, 0.2f, Color.Green, 1f, false, false, true, false);
     MyRenderProxy.DebugDrawSphere(this.m_debugPos3, 0.1f, Color.Red, 1f, false, false, true, false);
     MyRenderProxy.DebugDrawSphere(this.m_debugPos4, 0.1f, Color.Green, 1f, false, false, true, false);
     if (MyFakes.DEBUG_DRAW_VOXEL_CONNECTION_HELPER)
     {
         this.m_connectionHelper.DebugDraw(ref drawMatrix, base.Mesh);
     }
     if (MyFakes.DEBUG_DRAW_NAVMESH_CELL_BORDERS)
     {
         foreach (KeyValuePair <ulong, List <DebugDrawEdge> > pair in this.m_debugCellEdges)
         {
             foreach (DebugDrawEdge edge in pair.Value)
             {
                 MyRenderProxy.DebugDrawLine3D(edge.V1, edge.V2, Color.Orange, Color.Orange, false, false);
             }
         }
     }
     else
     {
         this.m_debugCellEdges.Clear();
     }
     if (MyFakes.DEBUG_DRAW_NAVMESH_HIERARCHY)
     {
         if (MyFakes.DEBUG_DRAW_NAVMESH_HIERARCHY_LITE)
         {
             this.m_higherLevel.DebugDraw(true);
         }
         else
         {
             this.m_higherLevel.DebugDraw(false);
             this.m_higherLevelHelper.DebugDraw();
         }
     }
     if ((MyDebugDrawSettings.DEBUG_DRAW_NAVMESHES == MyWEMDebugDrawMode.LINES) && !(this.m_voxelMap is MyVoxelPhysics))
     {
         int num7 = 0;
         MyWingedEdgeMesh.EdgeEnumerator edges = base.Mesh.GetEdges(null);
         Vector3D position = this.m_voxelMap.PositionComp.GetPosition();
         while (edges.MoveNext())
         {
             MyWingedEdgeMesh.Edge current = edges.Current;
             Vector3D vectord2             = base.Mesh.GetVertexPosition(current.Vertex2) + position;
             Vector3D point = ((base.Mesh.GetVertexPosition(edges.Current.Vertex1) + position) + vectord2) * 0.5;
             if (MyCestmirPathfindingShorts.Pathfinding.Obstacles.IsInObstacle(point))
             {
                 MyRenderProxy.DebugDrawSphere(point, 0.05f, Color.Red, 1f, false, false, true, false);
             }
             num7++;
         }
     }
 }
Ejemplo n.º 4
0
        public bool AddOneMarkedCell(List <Vector3D> importantPositions)
        {
            bool flag = false;

            List <Vector3I> .Enumerator enumerator = this.m_cellsOnWay.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    Vector3I current = enumerator.Current;
                    if (!this.m_processedCells.Contains(ref current) && !this.m_markedForAddition.Contains(ref current))
                    {
                        this.MarkCellForAddition(current, this.CalculateCellWeight(importantPositions, current));
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
                goto TR_001A;
            }
TR_000A:
            if (flag)
            {
                return(flag);
            }
TR_001A:
            while (true)
            {
                if (this.m_toAdd.Count == 0)
                {
                    return(flag);
                }
                this.m_toAdd.QueryAll(this.m_heapItemList);
                float             negativeInfinity = float.NegativeInfinity;
                CellToAddHeapItem item             = null;
                foreach (CellToAddHeapItem item2 in this.m_heapItemList)
                {
                    float newKey = this.CalculateCellWeight(importantPositions, item2.Position);
                    if (newKey > negativeInfinity)
                    {
                        negativeInfinity = newKey;
                        item             = item2;
                    }
                    this.m_toAdd.Modify(item2, newKey);
                }
                this.m_heapItemList.Clear();
                if (item == null)
                {
                    return(flag);
                }
                else if (negativeInfinity >= this.LimitAddingWeight)
                {
                    this.m_toAdd.Remove(item);
                    Vector3I position = item.Position;
                    m_heapItemAllocator.Deallocate(item);
                    this.m_markedForAddition.Remove(position);
                    m_adjacentCells.Clear();
                    if (this.AddCell(position, ref m_adjacentCells))
                    {
                        foreach (Vector3I vectori3 in m_adjacentCells)
                        {
                            float weight = this.CalculateCellWeight(importantPositions, vectori3);
                            this.MarkCellForAddition(vectori3, weight);
                        }
                        return(true);
                    }
                }
                else
                {
                    return(flag);
                }
                break;
            }
            goto TR_000A;
        }