Ejemplo n.º 1
0
        private unsafe void GenerateTile(MyNavmeshOBBs.OBBCoords obbCoord)
        {
            MyOrientedBoundingBoxD oBB        = obbCoord.OBB;
            Vector3             pos           = (Vector3)this.WorldPositionToLocalNavmeshPosition(oBB.Center, 0f);
            List <BoundingBoxD> boundingBoxes = new List <BoundingBoxD>();

            MyNavigationInputMesh.WorldVerticesInfo info = this.m_navInputMesh.GetWorldVertices(this.m_border, this.Center, oBB, boundingBoxes, this.m_tmpTrackedVoxelMaps);
            this.m_groundCaptureAABBs = boundingBoxes;
            foreach (MyVoxelMap map in this.m_tmpTrackedVoxelMaps)
            {
                if (!this.m_trackedVoxelMaps.ContainsKey(map.EntityId))
                {
                    map.RangeChanged += new MyVoxelBase.StorageChanged(this.VoxelMapRangeChanged);
                    this.m_trackedVoxelMaps.Add(map.EntityId, map);
                }
            }
            this.m_tmpTrackedVoxelMaps.Clear();
            if (info.Triangles.Count <= 0)
            {
                this.m_newObbCoordsPolygons[obbCoord.Coords] = null;
            }
            else
            {
                Vector3 *vectorPtr;
                Vector3[] pinned vectorArray;
                int *numPtr2;
                int[] pinned numArray;
                if (((vectorArray = info.Vertices.GetInternalArray <Vector3>()) == null) || (vectorArray.Length == 0))
                {
                    vectorPtr = null;
                }
                else
                {
                    vectorPtr = vectorArray;
                }
                float *vertices = (float *)vectorPtr;
                if (((numArray = info.Triangles.GetInternalArray <int>()) == null) || (numArray.Length == 0))
                {
                    numPtr2 = null;
                }
                else
                {
                    numPtr2 = numArray;
                }
                this.m_rdWrapper.CreateNavmeshTile(pos, ref this.m_recastOptions, ref this.m_polygons, obbCoord.Coords.X, obbCoord.Coords.Y, 0, vertices, info.Vertices.Count, numPtr2, info.Triangles.Count / 3);
                numArray    = null;
                vectorArray = null;
                this.GenerateDebugDrawPolygonNavmesh(this.Planet, this.m_polygons, this.m_navmeshOBBs.CenterOBB, obbCoord.Coords);
                this.GenerateDebugTileDataSize(pos, obbCoord.Coords.X, obbCoord.Coords.Y);
                if (this.m_polygons != null)
                {
                    this.m_polygons.Clear();
                    this.m_updateDrawMesh = true;
                }
            }
            this.m_navmeshTileGenerationRunning = false;
        }
Ejemplo n.º 2
0
 public void AddTrianglesToWorldVertices(Vector3 center, float radius)
 {
     foreach (int num in this.triangleIndices)
     {
         MyNavigationInputMesh.m_worldVertices.Triangles.Add(MyNavigationInputMesh.m_worldVertices.VerticesMaxValue + num);
     }
     foreach (Vector3 vector in this.positions)
     {
         MyNavigationInputMesh.m_worldVertices.Vertices.Add(center + (vector * radius));
     }
     MyNavigationInputMesh.WorldVerticesInfo worldVertices = MyNavigationInputMesh.m_worldVertices;
     worldVertices.VerticesMaxValue += this.positions.Count;
 }
Ejemplo n.º 3
0
            public void AddTrianglesToWorldVertices(Matrix transformMatrix, float radius, Line axisLine)
            {
                Matrix  matrix      = Matrix.CreateFromDir(axisLine.Direction);
                Vector3 translation = transformMatrix.Translation;

                transformMatrix.Translation = Vector3.Zero;
                int     num     = this.m_verticeList.Count / 2;
                Vector3 vector2 = new Vector3(0f, 0f, axisLine.Length * 0.5f);

                for (int i = 0; i < num; i++)
                {
                    MyNavigationInputMesh.m_worldVertices.Vertices.Add(Vector3.Transform((translation + (this.m_verticeList[i] * radius)) - vector2, matrix));
                }
                for (int j = num; j < this.m_verticeList.Count; j++)
                {
                    MyNavigationInputMesh.m_worldVertices.Vertices.Add(Vector3.Transform((translation + (this.m_verticeList[j] * radius)) + vector2, matrix));
                }
                foreach (int num4 in this.m_triangleList)
                {
                    MyNavigationInputMesh.m_worldVertices.Triangles.Add(MyNavigationInputMesh.m_worldVertices.VerticesMaxValue + num4);
                }
                MyNavigationInputMesh.WorldVerticesInfo worldVertices = MyNavigationInputMesh.m_worldVertices;
                worldVertices.VerticesMaxValue += this.m_verticeList.Count;
            }