public void OnReductionChange(float value) { if (disableTemporary) { return; } didApplyLosslessLast = false; //System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch(); //w.Start(); if (targetObject == null) { return; } if (Mathf.Approximately(0, value)) { return; } SimplificationOptions options = new SimplificationOptions(); options.simplificationStrength = value; options.enableSmartlinking = enableSmartLinking.isOn; options.preserveBorderEdges = preserveBorders.isOn; options.preserveUVSeamEdges = preserveUVSeams.isOn; options.preserveUVFoldoverEdges = preserveUVFoldover.isOn; if (preserveFace.isOn) { options.regardPreservationSphere = true; options.preservationSphereCenterWorldSpace = preservationSphere.position; options.preservationSphereWorldScale = preservationSphere.lossyScale; } else { options.regardPreservationSphere = false; } trianglesCount.text = PolyfewRuntime.SimplifyObjectDeep(objectMeshPairs, options, (GameObject go, MeshRendererPair mInfo) => { //Debug.Log("Simplified mesh " + mInfo.mesh.name + " on GameObject " + go.name); }) + ""; //w.Stop(); //Debug.Log("Elapsed " + w.ElapsedMilliseconds); }
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; } SimplificationOptions options = new 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 PreservationSphere(preservationSphere.position, preservationSphere.lossyScale.x, preservationStrength.value)); } else { options.regardPreservationSpheres = false; } trianglesCount.text = PolyfewRuntime.SimplifyObjectDeep(objectMeshPairs, options, (GameObject go, MeshRendererPair mInfo) => { //Debug.Log("Simplified mesh " + mInfo.mesh.name + " on GameObject " + go.name); }) + ""; }
private void SimplifyTree(ITree tree) { bool simplify = !Options.PreventSimplification; if (!simplify) { return; } // Simplify the tree. SimplificationOptions simplificationOptions = SimplificationOptions.Default; simplificationOptions.LeaveTails = Options.LeaveHeads; simplificationOptions.FirstBranchNodeMayBeRemoved = Options.RemoveTails; simplificationOptions.KeepAllOrphans = Options.KeepAllOrphans; _simplifier.Simplify(tree, simplificationOptions); }
public void SimplifyLossless() { //System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch(); //w.Start(); disableTemporary = true; reductionStrength.value = 0; disableTemporary = false; didApplyLosslessLast = true; SimplificationOptions options = new SimplificationOptions { enableSmartlinking = enableSmartLinking.isOn, preserveBorderEdges = preserveBorders.isOn, preserveUVSeamEdges = preserveUVSeams.isOn, preserveUVFoldoverEdges = preserveUVFoldover.isOn, simplifyMeshLossless = true }; if (preserveFace.isOn) { options.regardPreservationSphere = true; options.preservationSphereCenterWorldSpace = preservationSphere.position; options.preservationSphereWorldScale = preservationSphere.lossyScale; } else { options.regardPreservationSphere = false; } trianglesCount.text = PolyfewRuntime.SimplifyObjectDeep(objectMeshPairs, options, (GameObject go, MeshRendererPair mInfo) => { Debug.Log("Simplified mesh " + mInfo.mesh.name + " on GameObject " + go.name); }) + ""; //w.Stop(); //Debug.Log("Elapsed " + w.ElapsedMilliseconds); }