예제 #1
0
        public unsafe void PrepareVoxelTriangleTests(BoundingBoxD cellBoundingBox, List <MyCubeGrid> gridsToTestOutput)
        {
            m_tmpEntityList.Clear();
            float cubeSize = MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large);

            cellBoundingBox.Inflate((double)cubeSize);
            if (MyPerGameSettings.NavmeshPresumesDownwardGravity)
            {
                Vector3D min     = cellBoundingBox.Min;
                double * numPtr1 = (double *)ref min.Y;
                numPtr1[0]         -= cubeSize;
                cellBoundingBox.Min = min;
            }
            MyGamePruningStructure.GetAllEntitiesInBox(ref cellBoundingBox, m_tmpEntityList, MyEntityQueryType.Both);
            foreach (MyCubeGrid grid in m_tmpEntityList)
            {
                if (grid == null)
                {
                    continue;
                }
                if (MyGridPathfinding.GridCanHaveNavmesh(grid))
                {
                    gridsToTestOutput.Add(grid);
                }
            }
            m_tmpEntityList.Clear();
        }
예제 #2
0
        public MyPathfinding()
        {
            NextTimestampFunction = GenerateNextTimestamp;

            m_navmeshCoordinator = new MyNavmeshCoordinator();
            m_gridPathfinding    = new MyGridPathfinding(m_navmeshCoordinator);
            m_voxelPathfinding   = new MyVoxelPathfinding(m_navmeshCoordinator);
        }
예제 #3
0
        public void UnloadData()
        {
            m_gridPathfinding.UnloadData();
            m_voxelPathfinding.UnloadData();

            m_gridPathfinding    = null;
            m_voxelPathfinding   = null;
            m_navmeshCoordinator = null;
        }
예제 #4
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);
 }
예제 #5
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;
 }
예제 #6
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;
        }
예제 #7
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;
        }
예제 #8
0
        public void PrepareVoxelTriangleTests(BoundingBoxD cellBoundingBox, List <MyCubeGrid> gridsToTestOutput)
        {
            ProfilerShort.Begin("PrepareVoxelTriangleTests");

            m_tmpEntityList.Clear();

            // Each triangle will be tested with grids up to one largest cube further away from them, so we have to reflect this in the bounding box.
            float largeCubeSize = MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large);

            cellBoundingBox.Inflate(largeCubeSize);

            // Furthermore, a triangle cannot lie in a cube under existing block, so we have to extend the bbox even further
            if (MyPerGameSettings.NavmeshPresumesDownwardGravity)
            {
                var min = cellBoundingBox.Min;
                min.Y -= largeCubeSize;
                cellBoundingBox.Min = min;
            }

            MyGamePruningStructure.GetAllEntitiesInBox(ref cellBoundingBox, m_tmpEntityList);
            foreach (var entity in m_tmpEntityList)
            {
                var grid = entity as MyCubeGrid;
                if (grid == null)
                {
                    continue;
                }

                if (!MyGridPathfinding.GridCanHaveNavmesh(grid))
                {
                    continue;
                }

                gridsToTestOutput.Add(grid);
            }

            m_tmpEntityList.Clear();

            ProfilerShort.End();
        }
 public void SetGridPathfinding(MyGridPathfinding gridPathfinding)
 {
     m_gridPathfinding = gridPathfinding;
 }
        private void DecreaseGridLinkCounter(MyGridPathfinding.CubeId candidate)
        {
            int counter = 0;
            if (!m_gridLinkCounter.TryGetValue(candidate, out counter))
            {
                Debug.Assert(false, "Grid link counter is inconsistent!");
                return;
            }
            else
            {
                counter--;
            }

            if (counter == 0)
            {
                m_gridLinkCounter.Remove(candidate);
            }
            else
            {
                m_gridLinkCounter[candidate] = counter;
            }
        }
 private void IncreaseGridLinkCounter(MyGridPathfinding.CubeId candidate)
 {
     int counter = 0;
     if (!m_gridLinkCounter.TryGetValue(candidate, out counter))
     {
         counter = 1;
     }
     else
     {
         counter++;
     }
     m_gridLinkCounter[candidate] = counter;
 }
예제 #12
0
 public void SetGridPathfinding(MyGridPathfinding gridPathfinding)
 {
     this.m_gridPathfinding = gridPathfinding;
 }