Skip to content

Commit

Permalink
Added some validation checks in preparation of adding Tridecimator
Browse files Browse the repository at this point in the history
  • Loading branch information
jblattgerste committed Dec 1, 2023
1 parent 5ce7a02 commit c45eca1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Assets/Editor/Scripts/TrainARObjectConversionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MeshFilter>().sharedMesh =
Expand Down

0 comments on commit c45eca1

Please sign in to comment.