public void Apply(DMesh3 mesh) { int NV = AddedV.size; if (NV > 0) { NewVertexInfo vinfo = new NewVertexInfo(Positions[0]); mesh.BeginUnsafeVerticesInsert(); for (int i = 0; i < NV; ++i) { int vid = AddedV[i]; vinfo.v = Positions[i]; if (Normals != null) { vinfo.bHaveN = true; vinfo.n = Normals[i]; } if (Colors != null) { vinfo.bHaveC = true; vinfo.c = Colors[i]; } if (UVs != null) { vinfo.bHaveUV = true; vinfo.uv = UVs[i]; } MeshResult result = mesh.InsertVertex(vid, ref vinfo, true); if (result != MeshResult.Ok) { throw new Exception("AddTrianglesMeshChange.Revert: error in InsertVertex(" + vid.ToString() + "): " + result.ToString()); } } mesh.EndUnsafeVerticesInsert(); } int NT = AddedT.size; if (NT > 0) { mesh.BeginUnsafeTrianglesInsert(); for (int i = 0; i < NT; ++i) { int tid = AddedT[i]; Index4i tdata = Triangles[i]; Index3i tri = new Index3i(tdata.a, tdata.b, tdata.c); MeshResult result = mesh.InsertTriangle(tid, tri, tdata.d, true); if (result != MeshResult.Ok) { throw new Exception("AddTrianglesMeshChange.Revert: error in InsertTriangle(" + tid.ToString() + "): " + result.ToString()); } } mesh.EndUnsafeTrianglesInsert(); } if (OnApplyF != null) { OnApplyF(AddedV, AddedT); } }