Пример #1
0
        private void DrawPersistentDebugNavmesh()
        {
            foreach (var coordPoly in m_newObbCoordsPolygons)
            {
                if (m_newObbCoordsPolygons[coordPoly.Key] == null)
                {
                    m_obbCoordsPolygons.Remove(coordPoly.Key);
                }
                else
                {
                    m_obbCoordsPolygons[coordPoly.Key] = coordPoly.Value;
                }
            }

            m_newObbCoordsPolygons.Clear();

            if (m_obbCoordsPolygons.Count > 0)
            {
                MyRenderMessageDebugDrawMesh mesh = VRageRender.MyRenderProxy.PrepareDebugDrawMesh();
                Vertex vec0 = new Vertex(), vec1 = new Vertex(), vec2 = new Vertex();

                foreach (var vertexList in m_obbCoordsPolygons.Values)
                {
                    for (int i = 0; i < vertexList.Count;)
                    {
                        vec0 = vertexList[i++];
                        vec1 = vertexList[i++];
                        vec2 = vertexList[i++];
                        mesh.AddTriangle(ref vec0.pos, vec0.color, ref vec1.pos, vec1.color, ref vec2.pos, vec2.color);
                    }
                }

                if (m_drawNavmeshID == VRageRender.MyRenderProxy.RENDER_ID_UNASSIGNED)
                {
                    m_drawNavmeshID = VRageRender.MyRenderProxy.DebugDrawMesh(mesh, MatrixD.Identity, Color.Green, true, true);
                }
                else
                {
                    VRageRender.MyRenderProxy.DebugDrawUpdateMesh(m_drawNavmeshID, mesh, MatrixD.Identity, Color.Green, true, true);
                }
            }
        }