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); }
public override void Hover(Camera camera, Vector3 pointer) { if (m_nextUpdate > Time.time) { return; } m_nextUpdate = Time.time + 0.3f; if (m_vertexSelection.MeshesCount == 0) { return; } float result = PBUtility.PickVertex(camera, pointer, 20, null, m_vertexSelection.Meshes, ref m_selection); if (result != Mathf.Infinity) { m_vertexSelection.Hover(m_selection.mesh, m_selection.vertex); } else { m_vertexSelection.Leave(); } }
public bool Click(Camera camera, Vector3 pointer) { if (!m_isEditing) { return(false); } SceneSelection selection = new SceneSelection(); float result = PBUtility.PickVertex(camera, pointer, 20, m_selection.Transform, m_selection.Positions, ref selection); if (result != Mathf.Infinity) { if (m_selection.Positions.Count >= 3) { m_selection.Unselect(); m_selection.Select(selection.vertex); return(true); } } else { if (Stage == 0) { Ray ray = camera.ScreenPointToRay(pointer); float enter; Plane plane = new Plane(m_selection.transform.up, m_selection.transform.position); if (plane.Raycast(ray, out enter)) { Vector3 position = ray.GetPoint(enter); position = m_selection.Transform.InverseTransformPoint(position); m_selection.Add(position); m_positions.Add(position); } m_target.CreateShapeFromPolygon(m_selection.Positions, 0.001f, false); } } return(false); }