Esempio n. 1
0
        static int GetNearestVertices(ProBuilderMesh mesh, Vector3 mousePosition, List <VertexPickerEntry> list, float maxDistance)
        {
            var positions = mesh.positionsInternal;
            var common    = mesh.sharedVerticesInternal;
            var matches   = 0;

            for (int n = 0, c = common.Length; n < c; n++)
            {
                int     index = common[n][0];
                Vector3 v     = mesh.transform.TransformPoint(positions[index]);
                Vector3 p     = UHandleUtility.WorldToGUIPoint(v);

                float dist = (p - mousePosition).sqrMagnitude;

                if (dist < maxDistance)
                {
                    list.Add(new VertexPickerEntry()
                    {
                        mesh           = mesh,
                        screenDistance = dist,
                        worldPosition  = v,
                        vertex         = index
                    });

                    matches++;
                }
            }

            return(matches);
        }