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;
                }
            }
        }
        public MyGridPathfinding(MyNavmeshCoordinator coordinator)
        {
            m_navigationMeshes = new Dictionary<MyCubeGrid, MyGridNavigationMesh>();
            m_coordinator = coordinator;
            m_coordinator.SetGridPathfinding(this);

            m_highLevelNavigationDirty = false;
        }
Exemple #3
0
        public MyPathfinding()
        {
            NextTimestampFunction = GenerateNextTimestamp;

            m_navmeshCoordinator = new MyNavmeshCoordinator();
            m_gridPathfinding    = new MyGridPathfinding(m_navmeshCoordinator);
            m_voxelPathfinding   = new MyVoxelPathfinding(m_navmeshCoordinator);
        }
Exemple #4
0
        public MyGridPathfinding(MyNavmeshCoordinator coordinator)
        {
            m_navigationMeshes = new Dictionary <MyCubeGrid, MyGridNavigationMesh>();
            m_coordinator      = coordinator;
            m_coordinator.SetGridPathfinding(this);

            m_highLevelNavigationDirty = false;
        }
Exemple #5
0
 public MyPathfinding() : base(0x80, null)
 {
     this.NextTimestampFunction = new Func <long>(this.GenerateNextTimestamp);
     this.m_obstacles           = new MyDynamicObstacles();
     this.m_navmeshCoordinator  = new MyNavmeshCoordinator(this.m_obstacles);
     this.m_gridPathfinding     = new MyGridPathfinding(this.m_navmeshCoordinator);
     this.m_voxelPathfinding    = new MyVoxelPathfinding(this.m_navmeshCoordinator);
     MyEntities.OnEntityAdd    += new Action <MyEntity>(this.MyEntities_OnEntityAdd);
 }
Exemple #6
0
        public void UnloadData()
        {
            m_gridPathfinding.UnloadData();
            m_voxelPathfinding.UnloadData();

            m_gridPathfinding    = null;
            m_voxelPathfinding   = null;
            m_navmeshCoordinator = null;
        }
Exemple #7
0
 public void UnloadData()
 {
     MyEntities.OnEntityAdd -= new Action <MyEntity>(this.MyEntities_OnEntityAdd);
     this.m_voxelPathfinding.UnloadData();
     this.m_gridPathfinding    = null;
     this.m_voxelPathfinding   = null;
     this.m_navmeshCoordinator = null;
     this.m_obstacles.Clear();
     this.m_obstacles = null;
 }
        public MyVoxelPathfinding(MyNavmeshCoordinator coordinator)
        {
            MyEntities.OnEntityAdd += MyEntities_OnEntityAdd;

            m_navigationMeshes = new Dictionary<MyVoxelBase, MyVoxelNavigationMesh>();
            m_tmpUpdatePositions = new List<Vector3D>(8);
            m_tmpVoxelMaps = new List<MyVoxelBase>();
            m_tmpNavmeshes = new List<MyVoxelNavigationMesh>();
            m_coordinator = coordinator;
            coordinator.SetVoxelPathfinding(this);
        }
        public MyVoxelPathfinding(MyNavmeshCoordinator coordinator)
        {
            MyEntities.OnEntityAdd += MyEntities_OnEntityAdd;

            m_navigationMeshes   = new Dictionary <MyVoxelMap, MyVoxelNavigationMesh>();
            m_tmpUpdatePositions = new List <Vector3D>(8);
            m_tmpVoxelMaps       = new List <MyVoxelMap>();
            m_tmpNavmeshes       = new List <MyVoxelNavigationMesh>();
            m_coordinator        = coordinator;
            coordinator.SetVoxelPathfinding(this);
        }
Exemple #10
0
        public MyPathfinding()
        {
            NextTimestampFunction = GenerateNextTimestamp;

            m_obstacles          = new MyDynamicObstacles();
            m_navmeshCoordinator = new MyNavmeshCoordinator(m_obstacles);
            m_gridPathfinding    = new MyGridPathfinding(m_navmeshCoordinator);
            m_voxelPathfinding   = new MyVoxelPathfinding(m_navmeshCoordinator);

            MyEntities.OnEntityAdd += MyEntities_OnEntityAdd;
        }
Exemple #11
0
        public void UnloadData()
        {
            MyEntities.OnEntityAdd -= MyEntities_OnEntityAdd;

            m_voxelPathfinding.UnloadData();

            m_gridPathfinding    = null;
            m_voxelPathfinding   = null;
            m_navmeshCoordinator = null;
            m_obstacles.Clear();
            m_obstacles = null;
        }
Exemple #12
0
 public MyVoxelPathfinding(MyNavmeshCoordinator coordinator)
 {
     MyEntities.OnEntityAdd   += new Action <MyEntity>(this.MyEntities_OnEntityAdd);
     this.m_navigationMeshes   = new Dictionary <MyVoxelBase, MyVoxelNavigationMesh>();
     this.m_tmpUpdatePositions = new List <Vector3D>(8);
     this.m_tmpVoxelMaps       = new List <MyVoxelBase>();
     this.m_tmpNavmeshes       = new List <MyVoxelNavigationMesh>();
     this.m_coordinator        = coordinator;
     coordinator.SetVoxelPathfinding(this);
     if (MyFakes.REPLAY_NAVMESH_GENERATION || MyFakes.LOG_NAVMESH_GENERATION)
     {
         this.DebugLog = new MyVoxelPathfindingLog("PathfindingLog.log");
     }
 }
        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;
        }
        public MyVoxelNavigationMesh(MyVoxelBase 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;
        }
Exemple #15
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;
 }
Exemple #16
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;
         }
     }
 }
        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;
                }
            }
        }
Exemple #18
0
 public MyGridPathfinding(MyNavmeshCoordinator coordinator)
 {
     this.m_coordinator = coordinator;
     this.m_coordinator.SetGridPathfinding(this);
     this.m_highLevelNavigationDirty = false;
 }