public virtual MeshSelection Select(Camera camera, Rect rect, GameObject[] gameObjects, MeshEditorSelectionMode mode) { return(null); }
public override MeshSelection Select(Camera camera, Rect rect, GameObject[] gameObjects, MeshEditorSelectionMode mode) { Dictionary <ProBuilderMesh, HashSet <Edge> > pickResult = PBUtility.PickEdges(camera, rect, gameObjects); if (pickResult.Count == 0) { return(null); } MeshSelection selection = new MeshSelection(); foreach (KeyValuePair <ProBuilderMesh, HashSet <Edge> > kvp in pickResult) { ProBuilderMesh mesh = kvp.Key; m_edgeSelection.FindCoincidentEdges(mesh); IList <Edge> edges = m_edgeSelection.GetCoincidentEdges(kvp.Value); IList <Edge> selected = edges.Where(edge => m_edgeSelection.IsSelected(mesh, edge)).ToArray(); IList <Edge> notSelected = edges.Where(edge => !m_edgeSelection.IsSelected(mesh, edge)).ToArray(); if (mode == MeshEditorSelectionMode.Substract || mode == MeshEditorSelectionMode.Difference) { selection.UnselectedEdges.Add(mesh, selected); m_edgeSelection.Remove(mesh, selected); } if (mode == MeshEditorSelectionMode.Add || mode == MeshEditorSelectionMode.Difference) { selection.SelectedEdges.Add(mesh, notSelected); m_edgeSelection.Add(mesh, notSelected); } } return(selection); }
public override MeshSelection Select(Camera camera, Rect rect, Rect uiRootRect, GameObject[] gameObjects, bool depthTest, MeshEditorSelectionMode mode) { Dictionary <ProBuilderMesh, HashSet <int> > pickResult = PBUtility.PickVertices(camera, rect, uiRootRect, gameObjects, depthTest); if (pickResult.Count == 0) { return(null); } MeshSelection selection = new MeshSelection(); foreach (KeyValuePair <ProBuilderMesh, HashSet <int> > kvp in pickResult) { ProBuilderMesh mesh = kvp.Key; HashSet <int> sharedIndexes = kvp.Value; IList <SharedVertex> sharedVertices = mesh.sharedVertices; HashSet <int> indices = new HashSet <int>(); foreach (int sharedIndex in sharedIndexes) { SharedVertex sharedVertex = sharedVertices[sharedIndex]; for (int j = 0; j < sharedVertex.Count; ++j) { if (!indices.Contains(sharedVertex[j])) { indices.Add(sharedVertex[j]); } } } if (mode == MeshEditorSelectionMode.Substract || mode == MeshEditorSelectionMode.Difference) { IList <int> selected = mesh.GetCoincidentVertices(indices).Where(index => m_vertexSelection.IsSelected(mesh, index)).ToArray(); selection.UnselectedIndices.Add(mesh.gameObject, selected); m_vertexSelection.Remove(mesh, selected); } if (mode == MeshEditorSelectionMode.Add || mode == MeshEditorSelectionMode.Difference) { IList <int> notSelected = mesh.GetCoincidentVertices(indices).Where(index => !m_vertexSelection.IsSelected(mesh, index)).ToArray(); selection.SelectedIndices.Add(mesh.gameObject, notSelected); m_vertexSelection.Add(mesh, notSelected); } } return(selection); }
public override MeshSelection Select(Camera camera, Rect rect, GameObject[] gameObjects, MeshEditorSelectionMode mode) { MeshSelection selection = new MeshSelection(); m_faceSelection.BeginChange(); Dictionary <ProBuilderMesh, HashSet <Face> > result = PBUtility.PickFaces(camera, rect, gameObjects); if (mode == MeshEditorSelectionMode.Add) { foreach (KeyValuePair <ProBuilderMesh, HashSet <Face> > kvp in result) { ProBuilderMesh mesh = kvp.Key; IList <Face> faces = mesh.faces; IList <int> faceIndices = kvp.Value.Select(f => faces.IndexOf(f)).ToArray(); IList <int> notSelected = faceIndices.Where(f => !m_faceSelection.IsSelected(f)).ToArray(); foreach (int face in notSelected) { m_faceSelection.Add(mesh, face); } selection.SelectedFaces.Add(mesh, notSelected); } } else if (mode == MeshEditorSelectionMode.Substract) { foreach (KeyValuePair <ProBuilderMesh, HashSet <Face> > kvp in result) { ProBuilderMesh mesh = kvp.Key; IList <Face> faces = mesh.faces; IList <int> faceIndices = kvp.Value.Select(f => faces.IndexOf(f)).ToArray(); IList <int> selected = faceIndices.Where(f => m_faceSelection.IsSelected(f)).ToArray(); foreach (int face in selected) { m_faceSelection.Remove(face); } selection.UnselectedFaces.Add(mesh, selected); } } else if (mode == MeshEditorSelectionMode.Difference) { foreach (KeyValuePair <ProBuilderMesh, HashSet <Face> > kvp in result) { ProBuilderMesh mesh = kvp.Key; IList <Face> faces = mesh.faces; IList <int> faceIndices = kvp.Value.Select(f => faces.IndexOf(f)).ToArray(); IList <int> selected = faceIndices.Where(f => m_faceSelection.IsSelected(f)).ToArray(); IList <int> notSelected = faceIndices.Where(f => !m_faceSelection.IsSelected(f)).ToArray(); foreach (int face in selected) { m_faceSelection.Remove(face); } foreach (int face in notSelected) { m_faceSelection.Add(mesh, face); } selection.UnselectedFaces.Add(mesh, selected); selection.SelectedFaces.Add(mesh, notSelected); } } m_faceSelection.EndChange(); if (selection.SelectedFaces.Count == 0 && selection.UnselectedFaces.Count == 0) { selection = null; } return(selection); }
public virtual MeshSelection Select(Camera camera, Rect rect, Rect uiRootRect, GameObject[] gameObjects, bool depthTest, MeshEditorSelectionMode mode) { return(null); }