public override MeshSelection Select(Camera camera, Vector3 pointer, bool shift, bool ctrl, bool depthTest)
        {
            MeshSelection selection    = null;
            GameObject    pickedObject = PBUtility.PickObject(camera, pointer);
            float         result       = PBUtility.PickVertex(camera, pointer, 20, pickedObject, m_vertexSelection.Meshes, depthTest, ref m_selection);

            if (result != Mathf.Infinity)
            {
                if (m_vertexSelection.IsSelected(m_selection.mesh, m_selection.vertex))
                {
                    if (shift)
                    {
                        List <int> indices = m_selection.mesh.GetCoincidentVertices(new[] { m_selection.vertex });
                        m_vertexSelection.Remove(m_selection.mesh, indices);
                        selection = new MeshSelection();
                        selection.UnselectedIndices.Add(m_selection.mesh.gameObject, indices);
                    }
                    else
                    {
                        List <int> indices = m_selection.mesh.GetCoincidentVertices(new[] { m_selection.vertex });

                        selection = ReadSelection();
                        selection.UnselectedIndices[m_selection.mesh.gameObject] = selection.UnselectedIndices[m_selection.mesh.gameObject].Where(i => i != m_selection.vertex).ToArray();
                        selection.SelectedIndices.Add(m_selection.mesh.gameObject, indices);
                        m_vertexSelection.Clear();
                        m_vertexSelection.Add(m_selection.mesh, indices);
                    }
                }
                else
                {
                    if (shift)
                    {
                        selection = new MeshSelection();
                    }
                    else
                    {
                        selection = ReadSelection();
                        m_vertexSelection.Clear();
                    }

                    List <int> indices = m_selection.mesh.GetCoincidentVertices(new[] { m_selection.vertex });

                    m_vertexSelection.Add(m_selection.mesh, indices);
                    selection.SelectedIndices.Add(m_selection.mesh.gameObject, indices);
                }
            }
            else
            {
                if (!shift)
                {
                    selection = ReadSelection();
                    if (selection.UnselectedIndices.Count == 0)
                    {
                        selection = null;
                    }
                    m_vertexSelection.Clear();
                }
            }
            return(selection);
        }
Exemple #2
0
        public override MeshSelection Select(Camera camera, Vector3 pointer, bool shift)
        {
            MeshSelection selection    = null;
            GameObject    pickedObject = PBUtility.PickObject(camera, pointer);
            float         result       = PBUtility.PickEdge(camera, pointer, 20, pickedObject, m_edgeSelection.Meshes, ref m_selection);

            if (result != Mathf.Infinity)
            {
                if (m_edgeSelection.IsSelected(m_selection.mesh, m_selection.edge))
                {
                    if (shift)
                    {
                        m_edgeSelection.FindCoincidentEdges(m_selection.mesh);

                        IList <Edge> edges = m_edgeSelection.GetCoincidentEdges(new[] { m_selection.edge });
                        m_edgeSelection.Remove(m_selection.mesh, edges);
                        selection = new MeshSelection();
                        selection.UnselectedEdges.Add(m_selection.mesh, edges);
                    }
                    else
                    {
                        m_edgeSelection.FindCoincidentEdges(m_selection.mesh);

                        IList <Edge> edges = m_edgeSelection.GetCoincidentEdges(new[] { m_selection.edge });
                        selection = ReadSelection();
                        selection.UnselectedEdges[m_selection.mesh] = selection.UnselectedEdges[m_selection.mesh].Where(e => e != m_selection.edge).ToArray();
                        selection.SelectedEdges.Add(m_selection.mesh, edges);
                        m_edgeSelection.Clear();
                        m_edgeSelection.Add(m_selection.mesh, edges);
                    }
                }
                else
                {
                    if (shift)
                    {
                        selection = new MeshSelection();
                    }
                    else
                    {
                        selection = ReadSelection();
                        m_edgeSelection.Clear();
                    }

                    m_edgeSelection.FindCoincidentEdges(m_selection.mesh);

                    IList <Edge> edges = m_edgeSelection.GetCoincidentEdges(new[] { m_selection.edge });
                    m_edgeSelection.Add(m_selection.mesh, edges);
                    selection.SelectedEdges.Add(m_selection.mesh, edges);
                }
            }
            else
            {
                if (!shift)
                {
                    selection = ReadSelection();
                    if (selection.UnselectedEdges.Count == 0)
                    {
                        selection = null;
                    }
                    m_edgeSelection.Clear();
                }
            }
            return(selection);
        }