From 46f225246714e0ea38fd04070e47d6b60ba6f643 Mon Sep 17 00:00:00 2001 From: Klara Date: Mon, 9 Dec 2024 13:27:12 +0000 Subject: [PATCH 1/2] Fix bug in MeshCycler --- Assets/Scripts/tools/utils/HighlightStyles/MeshCycler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/tools/utils/HighlightStyles/MeshCycler.cs b/Assets/Scripts/tools/utils/HighlightStyles/MeshCycler.cs index fe79016b..b9a11379 100644 --- a/Assets/Scripts/tools/utils/HighlightStyles/MeshCycler.cs +++ b/Assets/Scripts/tools/utils/HighlightStyles/MeshCycler.cs @@ -70,7 +70,7 @@ public static Mesh GetTempMeshForMeshMatId(int meshId, int materialId, out bool mesh = new Mesh(); } - matDict[meshId] = mesh; + matDict[materialId] = mesh; return mesh; } From c70231c126f962ed32ed77fa4c5e4e8560758e1d Mon Sep 17 00:00:00 2001 From: Klara Date: Mon, 9 Dec 2024 13:29:14 +0000 Subject: [PATCH 2/2] Use MeshCycler in MeshDeleteSyle --- .../tools/utils/HighlightStyles/MeshDeleteStyle.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/tools/utils/HighlightStyles/MeshDeleteStyle.cs b/Assets/Scripts/tools/utils/HighlightStyles/MeshDeleteStyle.cs index 8456e5d4..a697f3a2 100644 --- a/Assets/Scripts/tools/utils/HighlightStyles/MeshDeleteStyle.cs +++ b/Assets/Scripts/tools/utils/HighlightStyles/MeshDeleteStyle.cs @@ -72,16 +72,19 @@ public static void RenderMeshes(Model model, int matId = pair.Key; MeshGenContext meshGenContext = pair.Value; - Mesh curMesh = new Mesh(); + Mesh curMesh = MeshCycler.GetTempMeshForMeshMatId(key, matId, out bool needToPopulateMesh); Material curMaterial = animPct >= .99f ? matDict[MaterialRegistry.GetMaterialType(matId)].GetFixedMaterial() : matDict[MaterialRegistry.GetMaterialType(matId)].GetInstanceOfMaterial(); curMaterial.SetFloat("_OverrideAmount", emissiveAmount); curMaterial.SetColor("_OverrideColor", ERASE_COLOR); curMaterial.renderQueue = 3000; - curMesh.SetVertices(meshGenContext.verts); - curMesh.SetColors(meshGenContext.colors); - curMesh.SetTriangles(meshGenContext.triangles, /* subMesh */ 0); - curMesh.RecalculateNormals(); + if (needToPopulateMesh) + { + curMesh.SetVertices(meshGenContext.verts); + curMesh.SetColors(meshGenContext.colors); + curMesh.SetTriangles(meshGenContext.triangles, /* subMesh */ 0); + curMesh.RecalculateNormals(); + } Graphics.DrawMesh(curMesh, worldSpace.modelToWorld, curMaterial, 0); }