public MyGridNavigationMesh(MyCubeGrid grid, MyNavmeshCoordinator coordinator, int triPrealloc = 32, Func <long> timestampFunction = null)
            : base(coordinator != null ? coordinator.Links : null, triPrealloc, timestampFunction)
        {
            m_connectionHelper      = new Dictionary <EdgeIndex, int>();
            m_smallTriangleRegistry = new Dictionary <Vector3I, List <int> >();
            m_cubeSet = new MyVector3ISet();

            m_coordinator = coordinator;

            m_static = false;
            if (grid != null)
            {
                m_higherLevel       = new MyHighLevelGroup(this, coordinator.HighLevelLinks, timestampFunction);
                m_higherLevelHelper = new MyGridHighLevelHelper(this, m_smallTriangleRegistry, new Vector3I(8, 8, 8));

                m_grid               = grid;
                grid.OnBlockAdded   += grid_OnBlockAdded;
                grid.OnBlockRemoved += grid_OnBlockRemoved;

                float   divisor = 1.0f / grid.CubeBlocks.Count;
                Vector3 center  = Vector3.Zero;

                foreach (var block in grid.CubeBlocks)
                {
                    OnBlockAddedInternal(block);
                    center += block.Position * grid.GridSize * divisor;
                }
            }
        }
예제 #2
0
 public MyHighLevelPrimitive(MyHighLevelGroup parent, int index, Vector3 position)
 {
     m_parent    = parent;
     m_neighbors = new List <int>(4);
     m_index     = index;
     m_position  = position;
     IsExpanded  = false;
 }
예제 #3
0
        public MyVoxelNavigationMesh(MyVoxelMap voxelMap, MyNavmeshCoordinator coordinator, Func <long> timestampFunction)
            : base(coordinator.Links, 16, timestampFunction)
        {
            m_voxelMap = voxelMap;
            m_cellSize = m_voxelMap.SizeInMetres / m_voxelMap.Storage.Geometry.CellsCount * (1 << NAVMESH_LOD);

            m_processedCells    = new MyVector3ISet();
            m_markedForAddition = new MyVector3ISet();
            m_toAdd             = new MyBinaryStructHeap <float, Vector3I>(128);

            m_connectionHelper   = new MyVoxelConnectionHelper();
            m_navmeshCoordinator = coordinator;
            m_higherLevel        = new MyHighLevelGroup(this, coordinator.HighLevelLinks, timestampFunction);
            m_higherLevelHelper  = new MyVoxelHighLevelHelper(this);

            m_debugCellEdges = new Dictionary <ulong, List <DebugDrawEdge> >();

            voxelMap.Storage.RangeChanged += OnStorageChanged;
        }
예제 #4
0
 public MyVoxelNavigationMesh(MyVoxelBase voxelMap, MyNavmeshCoordinator coordinator, Func <long> timestampFunction) : base(coordinator.Links, 0x10, timestampFunction)
 {
     this.LimitAddingWeight         = GetWeight(25f);
     this.m_voxelMap                = voxelMap;
     m_staticVoxelMap               = this.m_voxelMap;
     this.m_processedCells          = new MyVector3ISet();
     this.m_cellsOnWayCoords        = new HashSet <ulong>();
     this.m_cellsOnWay              = new List <Vector3I>();
     this.m_primitivesOnPath        = new List <MyHighLevelPrimitive>(0x80);
     this.m_toAdd                   = new MyBinaryHeap <float, CellToAddHeapItem>(0x80);
     this.m_heapItemList            = new List <CellToAddHeapItem>();
     this.m_markedForAddition       = new MyVector3ISet();
     this.m_cellsToChange           = new LinkedList <Vector3I>();
     this.m_cellsToChangeSet        = new MyVector3ISet();
     this.m_connectionHelper        = new MyVoxelConnectionHelper();
     this.m_navmeshCoordinator      = coordinator;
     this.m_higherLevel             = new MyHighLevelGroup(this, coordinator.HighLevelLinks, timestampFunction);
     this.m_higherLevelHelper       = new MyVoxelHighLevelHelper(this);
     this.m_debugCellEdges          = new Dictionary <ulong, List <DebugDrawEdge> >();
     voxelMap.Storage.RangeChanged += new Action <Vector3I, Vector3I, MyStorageDataTypeFlags>(this.OnStorageChanged);
     this.m_maxCellCoord            = ((Vector3I)(this.m_voxelMap.Size / 8)) - Vector3I.One;
 }
예제 #5
0
 public MyGridNavigationMesh(MyCubeGrid grid, MyNavmeshCoordinator coordinator, int triPrealloc = 0x20, Func <long> timestampFunction = null) : this(coordinator?.Links, triPrealloc, timestampFunction)
 {
     this.m_connectionHelper      = new Dictionary <EdgeIndex, int>();
     this.m_smallTriangleRegistry = new Dictionary <Vector3I, List <int> >();
     this.m_cubeSet     = new MyVector3ISet();
     this.m_coordinator = coordinator;
     this.m_static      = false;
     if (grid != null)
     {
         this.m_higherLevel       = new MyHighLevelGroup(this, coordinator.HighLevelLinks, timestampFunction);
         this.m_higherLevelHelper = new MyGridHighLevelHelper(this, this.m_smallTriangleRegistry, new Vector3I(8, 8, 8));
         this.m_grid          = grid;
         grid.OnBlockAdded   += new Action <MySlimBlock>(this.grid_OnBlockAdded);
         grid.OnBlockRemoved += new Action <MySlimBlock>(this.grid_OnBlockRemoved);
         float   num  = 1f / ((float)grid.CubeBlocks.Count);
         Vector3 zero = Vector3.Zero;
         foreach (MySlimBlock block in grid.CubeBlocks)
         {
             this.OnBlockAddedInternal(block);
             zero += (block.Position * grid.GridSize) * num;
         }
     }
 }