Ejemplo n.º 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();
        }
Ejemplo n.º 2
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();
        }