public void CheckMeshBeforeSaving() { m_dmesh.RemoveUnusedVerts(); m_dmesh.DeconvertPolysToTris(); string issues; if (m_dmesh.CheckAndCleanMeshIssues(false, out issues)) { AddOutputText(issues); Utility.DebugPopup("Mesh has issues. See output window for details."); } }
/// <summary> /// Return true if the mesh has degenerate triangles or other issues /// </summary> /// <returns></returns> public bool CheckAndCleanMeshIssues(bool removeSmallInvalidTriangles, out string issues) { return(DMesh.CheckAndCleanMeshIssues(ref m_triangle, m_vertex, removeSmallInvalidTriangles, out issues)); }
public void MaybeUpdateGMesh(bool report_mesh_issues, out string decal_issues) { if (string.IsNullOrEmpty(mesh_name) || hidden) { decal_issues = string.Empty; gmesh = null; //Clear out rendered mesh return; } dmesh = side.level.GetDMeshByName(mesh_name); System.Text.StringBuilder issues_text = new System.Text.StringBuilder(); const bool cleanup_bad_triangles = true; if (report_mesh_issues || cleanup_bad_triangles) { string issues; if (dmesh != null && dmesh.CheckAndCleanMeshIssues(cleanup_bad_triangles, out issues)) { if (report_mesh_issues) { issues_text.AppendFormat("Decal \"{0}\" has issues in its source geometry:\n{1}", mesh_name, issues); } } } if (dmesh == null) { decal_issues = string.Empty; gmesh = null; //Clear out rendered mesh return; } mesh_name = dmesh.name; gmesh = new GMesh(); gmesh.SetColors(dmesh.color); UpdateClipNormals(); // This must be done before GenerateNonClippedGeometry because gmesh.GenerateNonClippedGeometry(this, dmesh); #if OVERLOAD_LEVEL_EDITOR { // Note: We may not be in the UNITY_EDITOR here, but not // have valid TextureManager for decal and level textures. // This is the case when we are doing an export for user // levels. We don't need GL texture data anyway. var texman_decal = side.level.editor.tm_decal; var texman_level = side.level.editor.tm_level; if (texman_decal != null && texman_level != null) { gmesh.UpdateGLTextures(texman_decal, texman_level); } } #endif gmesh.ClipGeometry(); if (report_mesh_issues || cleanup_bad_triangles) { string issues; if (gmesh.CheckAndCleanMeshIssues(cleanup_bad_triangles, out issues)) { if (report_mesh_issues) { issues_text.AppendFormat("Decal \"{0}\" has issues after generation and clipping:\n{1}", mesh_name, issues); } } } gmesh.OptimizeMesh(); if (report_mesh_issues || cleanup_bad_triangles) { string issues; if (gmesh.CheckAndCleanMeshIssues(cleanup_bad_triangles, out issues)) { if (report_mesh_issues) { issues_text.AppendFormat("Decal \"{0}\" has issues after optimization:\n{1}", mesh_name, issues); } } } decal_issues = issues_text.ToString(); }