public void DestroyInvalidObjects() { Manifold manifold = Extrudable._manifold; var toDeleteV = new List <int>(_vertexHandles.Keys).FindAll(key => !manifold.IsVertexInUse(key)); foreach (var v in toDeleteV) { var obj = _vertexHandles[v]; _vertexHandles.Remove(v); Destroy(obj.gameObject); } var toDeleteF = new List <int>(_faceHandles.Keys).FindAll(key => !manifold.IsFaceInUse(key)); foreach (var f in toDeleteF) { var obj = _faceHandles[f]; _faceHandles.Remove(f); Destroy(obj.gameObject); } var toDeleteE = new List <int>(_edgeHandles.Keys).FindAll(key => !manifold.IsHalfedgeInUse(key) || key < manifold.GetOppHalfEdge(key)); foreach (var e in toDeleteE) { var obj = _edgeHandles[e]; var faces = new[] { obj.FirstFace, obj.SecondFace }; foreach (var face in faces) { FaceHandleController fhc; if (_faceHandles.TryGetValue(face, out fhc)) { fhc.ConnectedLatches.Remove(obj); } } _edgeHandles.Remove(e); Destroy(obj.gameObject); } // Brute force delete all edge controllers every cleanup, might not be effecient but circumvents bug that doesn't remove all invalid edgecontrollers. int[] ekeys = _edgeHandles.Keys.ToArray(); foreach (int key in ekeys) { var obj = _edgeHandles[key]; if (!obj.Locked) { } _edgeHandles.Remove(key); Destroy(obj.gameObject); } int[] fkeys = _faceHandles.Keys.ToArray(); foreach (int key in fkeys) { var obj = _faceHandles[key]; _faceHandles.Remove(key); Destroy(obj.gameObject); } int[] vkeys = _vertexHandles.Keys.ToArray(); foreach (int key in vkeys) { var obj = _vertexHandles[key]; _vertexHandles.Remove(key); Destroy(obj.gameObject); } }
public bool RefinementTestLoop(int halfedge1, int halfedge2) { if (!ValidateFaceLoop(halfedge1, halfedge2)) { return(false); } ExtrudableMesh _extrudableMesh = modellingObject.GetComponentInChildren <ExtrudableMesh>(); Manifold manifold = _extrudableMesh._manifold; int h = halfedge1; int initital_f = manifold.GetIncidentFace(halfedge1); int f = initital_f; List <int> faceloop = new List <int>(); List <int> edgeloop = new List <int>(); while (true) { if (manifold.IsFaceInUse(f)) { if (manifold.IsHalfedgeInUse(h)) { int h2 = manifold.GetNextHalfEdge(h); h2 = manifold.GetNextHalfEdge(h2); if (manifold.IsHalfedgeInUse(h2)) { int w = manifold.SplitEdge(h); edgeloop.Add(w); faceloop.Add(f); h = manifold.GetOppHalfEdge(h2); f = manifold.GetIncidentFace(h); if (f == initital_f) { int[] farray = faceloop.ToArray(); int[] earray = edgeloop.ToArray(); for (int i = 0; i < farray.Length; i++) { if (i == farray.Length - 1) { int output = manifold.SplitFaceByEdges(farray[i], earray[i], earray[0]); // earray[1]); } else { int output = manifold.SplitFaceByEdges(farray[i], earray[i], earray[i + 1]); } } _extrudableMesh.UpdateMesh(); return(true); } } else { return(false); } } else { return(false); } } else { return(false); } } }