public override MeshSelection Select(Camera camera, Vector3 pointer, bool shift) { MeshSelection selection = null; MeshAndFace result = PBUtility.PickFace(camera, pointer); if (result.face != null) { int faceIndex = result.mesh.faces.IndexOf(result.face); if (m_faceSelection.IsSelected(faceIndex)) { if (shift) { m_faceSelection.Remove(faceIndex); selection = new MeshSelection(); selection.UnselectedFaces.Add(result.mesh, new[] { faceIndex }); } else { selection = ReadSelection(); selection = null; } } else { if (shift) { selection = new MeshSelection(); } else { selection = ReadSelection(); m_faceSelection.Clear(); } m_faceSelection.Add(result.mesh, faceIndex); selection.SelectedFaces.Add(result.mesh, new[] { faceIndex }); } } else { if (!shift) { selection = ReadSelection(); if (selection.UnselectedFaces.Count == 0) { selection = null; } m_faceSelection.Clear(); } } return(selection); }
public override MeshSelection Select(Camera camera, Vector3 pointer, bool shift) { MeshSelection selection = null; MeshAndFace result = PBUtility.PickFace(camera, pointer); if (result.face != null) { if (m_faceSelection.IsSelected(result.face)) { if (shift) { m_faceSelection.Remove(result.face); selection = new MeshSelection(); selection.UnselectedFaces.Add(result.mesh, new[] { result.face }); } else { selection = ReadSelection(); //if(selection.SelectedFaces.Count > 1) //{ // selection.UnselectedFaces[result.mesh] = selection.UnselectedFaces[result.mesh].Where(f => f != result.face).ToArray(); // selection.SelectedFaces.Add(result.mesh, new[] { result.face }); // m_faceSelection.Clear(); // m_faceSelection.Add(result.mesh, result.face); //} //else { selection = null; } } } else { if (shift) { selection = new MeshSelection(); } else { selection = ReadSelection(); m_faceSelection.Clear(); } m_faceSelection.Add(result.mesh, result.face); selection.SelectedFaces.Add(result.mesh, new[] { result.face }); } } else { if (!shift) { selection = ReadSelection(); if (selection.UnselectedFaces.Count == 0) { selection = null; } m_faceSelection.Clear(); } } return(selection); }
public override MeshSelection Select(Camera camera, Vector3 pointer, bool shift, bool ctrl) { MeshSelection selection = null; MeshAndFace result = PBUtility.PickFace(camera, pointer); if (result.face != null) { if (ctrl) { int submeshIndex = result.face.submeshIndex; IList <Face> faces = result.mesh.faces; List <int> sameMaterialFaces = new List <int>(); bool wasSelected = false; bool wasUnselected = false; m_faceSelection.BeginChange(); for (int i = 0; i < faces.Count; ++i) { Face face = faces[i]; if (face.submeshIndex == submeshIndex) { sameMaterialFaces.Add(i); if (!m_faceSelection.IsSelected(result.mesh, i)) { m_faceSelection.Add(result.mesh, i); wasUnselected = true; } else { wasSelected = true; } } } if (wasSelected && !wasUnselected) { for (int i = 0; i < sameMaterialFaces.Count; ++i) { m_faceSelection.Remove(result.mesh, sameMaterialFaces[i]); } selection = new MeshSelection(); selection.UnselectedFaces.Add(result.mesh, sameMaterialFaces.ToArray()); } else { selection = new MeshSelection(); selection.SelectedFaces.Add(result.mesh, sameMaterialFaces.ToArray()); } m_faceSelection.EndChange(); } else { int faceIndex = result.mesh.faces.IndexOf(result.face); if (m_faceSelection.IsSelected(result.mesh, faceIndex)) { if (shift) { m_faceSelection.Remove(result.mesh, faceIndex); selection = new MeshSelection(); selection.UnselectedFaces.Add(result.mesh, new[] { faceIndex }); } else { //selection = ReadSelection(); selection = null; } } else { if (shift) { selection = new MeshSelection(); } else { selection = ReadSelection(); m_faceSelection.Clear(); } m_faceSelection.Add(result.mesh, faceIndex); selection.SelectedFaces.Add(result.mesh, new[] { faceIndex }); } } } else { if (!shift) { selection = ReadSelection(); if (selection.UnselectedFaces.Count == 0) { selection = null; } m_faceSelection.Clear(); } } return(selection); }