public void RebuildSelectedVertexIndexByVertexIndex() { selectedVertexIndexByVertexIndex.Clear(); for (int i = 0; i < selectedVertices.Count; i++) { SelectedVertex selectedVertex = selectedVertices[i]; selectedVertexIndexByVertexIndex.Add(selectedVertex.index, i); } }
public string SelectedVerticesString() { List <string> result = new List <string>(); for (int i = 0; i < selectedVertices.Count; i++) { SelectedVertex x = selectedVertices[i]; result.Add("(i=" + i + ",index:" + x.index + ",ID:" + x.vertex.instance.GetInstanceID().ToString() + ")"); } return(string.Join(",", result.ToArray())); }
public void DeleteSelectedVertices() { //Debug.Log("DeleteSelectedVertices before selectedVertices.Count=" + selectedVertices.Count + ",selectedVertices="+ SelectedVerticesString()); while (selectedVertices.Count > 0) { SelectedVertex selectedVertex = selectedVertices[0]; //Debug.Log("DeleteSelectedVertices index="+selectedVertex.index+",ID=" + selectedVertex.vertex.instance.GetInstanceID()); selectedVertex.vertex.instance.GetComponent <VertexController>().RemoveVertex(); } //Debug.Log("DeleteSelectedVertices after selectedVertices.Count=" + selectedVertices.Count); selectedVertexIndexByVertexIndex.Clear(); }
public void RemovedVerticesManagerVertexAtIndex(int index) { selectedVertexIndexByVertexIndex.Clear(); for (int i = 0; i < selectedVertices.Count; i++) { SelectedVertex selectedVertex = selectedVertices[i]; if (selectedVertex.index > index) { //Debug.Log("RemovedVerticesManagerVertexAtIndex minus minus index=" + index + ",i="+i+",selectedVertex.index=" + selectedVertex.index); selectedVertex.index--; } //Debug.Log("RemovedVerticesManagerVertexAtIndex Adding index=" + index + ",i=" + i + ",selectedVertex.index=" + selectedVertex.index); selectedVertexIndexByVertexIndex.Add(selectedVertex.index, i); } }
public void DeselectVertex(GameObject vertexInstance) { SelectedVertex selectedVertex = SelectedVertexByInstance(vertexInstance); if (selectedVertex == null) { return; // not selected } //Debug.Log("UnSelectVertex selectVertex.index=" + selectedVertex.index + ",selectedVertexIndexByVertexIndex[selectedVertex.index]=" + selectedVertexIndexByVertexIndex[selectedVertex.index]); int selectedVertexIndex = selectedVertexIndexByVertexIndex[selectedVertex.index]; bool isLastItem = selectedVertexIndex == selectedVertices.Count - 1; selectedVertices.Remove(selectedVertex); selectedVertexIndexByVertexIndex.Remove(selectedVertex.index); if (!isLastItem) { RebuildSelectedVertexIndexByVertexIndex(); } vertexInstance.GetComponent <VertexController>().SetStickySelected(false); ClearSelectedTriangles(); StickySelectTriangles(); }
public void SelectVertex(GameObject vertexInstance) { SelectedVertex selectedVertex = SelectedVertexByInstance(vertexInstance); if (selectedVertex != null) { return; // already selected } selectedVertex = new SelectedVertex(); selectedVertex.index = mesh.vertices.IndexOfInstance(vertexInstance); if (selectedVertex.index == -1) { Debug.Log("SelectVertex index=-1, vertexInstance.GetInstanceID=" + vertexInstance.GetInstanceID() + ",position=" + vertexInstance.GetComponent <VertexController>().lastPosition); return; } selectedVertex.vertex = mesh.vertices.vertices[selectedVertex.index]; selectedVertices.Add(selectedVertex); selectedVertexIndexByVertexIndex.Add(selectedVertex.index, selectedVertices.Count - 1); //Debug.Log("SelectVertex selectedVertex.index=" + selectedVertex.index + ",selectedVertices.Count-1=" + (selectedVertices.Count - 1)); vertexInstance.GetComponent <VertexController>().SetStickySelected(true); selectedTriangles.Clear(); StickySelectTriangles(); }