public void OnReductionChange(float value) { if (disableTemporary) { return; } didApplyLosslessLast = false; if (targetObject == null) { return; } if (Mathf.Approximately(0, value)) { AssignMeshesFromPairs(); trianglesCount.text = PolyfewRuntime.CountTriangles(true, targetObject) + ""; return; } PolyfewRuntime.SimplificationOptions options = new PolyfewRuntime.SimplificationOptions(); options.simplificationStrength = value; options.enableSmartlinking = enableSmartLinking.isOn; options.preserveBorderEdges = preserveBorders.isOn; options.preserveUVSeamEdges = preserveUVSeams.isOn; options.preserveUVFoldoverEdges = preserveUVFoldover.isOn; options.recalculateNormals = recalculateNormals.isOn; options.regardCurvature = regardCurvature.isOn; if (preserveFace.isOn) { options.regardPreservationSpheres = true; options.preservationSpheres.Add(new PolyfewRuntime.PreservationSphere(preservationSphere.position, preservationSphere.lossyScale.x, preservationStrength.value)); } else { options.regardPreservationSpheres = false; } trianglesCount.text = PolyfewRuntime.SimplifyObjectDeep(objectMeshPairs, options, (GameObject go, PolyfewRuntime.MeshRendererPair mInfo) => { //Debug.Log("Simplified mesh " + mInfo.mesh.name + " on GameObject " + go.name); }) + ""; }
public void SimplifyLossless() { //System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch(); //w.Start(); disableTemporary = true; reductionStrength.value = 0; disableTemporary = false; didApplyLosslessLast = true; PolyfewRuntime.SimplificationOptions options = new PolyfewRuntime.SimplificationOptions { enableSmartlinking = enableSmartLinking.isOn, preserveBorderEdges = preserveBorders.isOn, preserveUVSeamEdges = preserveUVSeams.isOn, preserveUVFoldoverEdges = preserveUVFoldover.isOn, recalculateNormals = recalculateNormals.isOn, regardCurvature = regardCurvature.isOn, simplifyMeshLossless = true }; if (preserveFace.isOn) { options.regardPreservationSpheres = true; } else { options.regardPreservationSpheres = false; } trianglesCount.text = PolyfewRuntime.SimplifyObjectDeep(objectMeshPairs, options, (GameObject go, PolyfewRuntime.MeshRendererPair mInfo) => { //Debug.Log("Simplified mesh " + mInfo.mesh.name + " on GameObject " + go.name); }) + ""; //w.Stop(); //Debug.Log("Elapsed " + w.ElapsedMilliseconds); }