private void VSListSet() // Create VerticesSet for all vertices and store in VSList. There seems to be no problem here. { List <int> counter = new List <int>(); for (int x = 0; x < AllVertices.Length; x++) { counter.Add(x); } for (int x = 0; 0 < counter.Count; x = counter[0]) { List <int> c = new List <int>(); var vs = new VerticesSet { vec = AllVertices[x], nums = new List <int>() }; for (int y = 0; y < counter.Count; y++) { if (AllVertices[x] == AllVertices[counter[y]]) { c.Add(counter[y]); vs.nums.Add(counter[y]); } } for (int z = 0; z < c.Count; z++) { counter.Remove(c[z]); } VSList.Add(vs); if (counter.Count == 0) { break; } } }
void Update() { if (Input.GetMouseButtonDown(0)) { nearestVS = SelectNearestVertice(); } if (Input.GetMouseButton(0)) { Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(mouseRay, out hit)) { Vector3 hitPoint = hit.point;// Intersection coordinates of black wall and mouseRay nearestVS.vec = hitPoint; for (int x = 0; x < nearestVS.nums.Count; x++) { AllVertices[nearestVS.nums[x]] = hitPoint; } MF.mesh.vertices = AllVertices; p.transform.position = hitPoint; Debug.Log(hitPoint); Debug.Log(nearestVS.vec); Debug.Log(AllVertices[nearestVS.nums[0]]); } } }