Exemple #1
0
 public override void SetSelection(MeshSelection selection)
 {
     m_vertexSelection.Clear();
     m_selection.Clear();
     foreach (KeyValuePair <ProBuilderMesh, IList <int> > kvp in selection.SelectedIndices)
     {
         m_vertexSelection.Add(kvp.Key, kvp.Value);
     }
 }
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.PickVertex(camera, pointer, 20, pickedObject, m_vertexSelection.Meshes, 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, indices);
                    }
                    else
                    {
                        List <int> indices = m_selection.mesh.GetCoincidentVertices(new[] { m_selection.vertex });

                        selection = ReadSelection();
                        selection.UnselectedIndices[m_selection.mesh] = selection.UnselectedIndices[m_selection.mesh].Where(i => i != m_selection.vertex).ToArray();
                        selection.SelectedIndices.Add(m_selection.mesh, 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, indices);
                }
            }
            else
            {
                if (!shift)
                {
                    selection = ReadSelection();
                    if (selection.UnselectedIndices.Count == 0)
                    {
                        selection = null;
                    }
                    m_vertexSelection.Clear();
                }
            }
            return(selection);
        }
        public override void SetSelection(MeshSelection selection)
        {
            m_vertexSelection.Clear();
            m_selection.Clear();

            if (selection != null)
            {
                selection = selection.ToVertices(false);
                foreach (KeyValuePair <GameObject, IList <int> > kvp in selection.SelectedIndices)
                {
                    PBMesh pbMesh = kvp.Key.GetComponent <PBMesh>();
                    if (pbMesh.IsMarkedAsDestroyed)
                    {
                        continue;
                    }

                    m_vertexSelection.Add(kvp.Key.GetComponent <ProBuilderMesh>(), kvp.Value);
                }
            }
        }