From c45eca169f4a256d8b6e94a6b6ef199552f91c2d Mon Sep 17 00:00:00 2001 From: Jonas Blattgerste Date: Fri, 1 Dec 2023 14:04:40 +0100 Subject: [PATCH] Added some validation checks in preparation of adding Tridecimator --- .../Scripts/TrainARObjectConversionWindow.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Assets/Editor/Scripts/TrainARObjectConversionWindow.cs b/Assets/Editor/Scripts/TrainARObjectConversionWindow.cs index daf2373..554ec96 100644 --- a/Assets/Editor/Scripts/TrainARObjectConversionWindow.cs +++ b/Assets/Editor/Scripts/TrainARObjectConversionWindow.cs @@ -218,12 +218,22 @@ void OnGUI() //Calculate how much the mesh would be reduced by in percent var simplificationPercentage = Math.Round((1 - (float)targetMeshPolygons / triangleCount) * 100, 2); - GUILayout.Label("Reduction: " + simplificationPercentage + "%"); + var originalPolygonCount = originalMeshes.Sum(mesh => mesh.triangles.Length / 3); + if (targetMeshPolygons <= 0) + { + targetMeshPolygons = 1; + } + else if (targetMeshPolygons >= originalPolygonCount) + { + targetMeshPolygons = originalPolygonCount; + } + + GUILayout.Label("Reduction: " + simplificationPercentage + "% (" + targetMeshPolygons + "/" + originalPolygonCount +" polygons)" ); //Simplify the mesh if (GUILayout.Button(new GUIContent("Simplify"))) { - //... + //simplify "originalMeshes"! if(pivotWasCentered) //If the pivot was centered before, center it again trainARObject.GetComponent().sharedMesh =