Exemplo n.º 1
0
        void PickLine(Vector3 mouse, out int segment, out int line)
        {
            float minDist = Mathf.Infinity;

            segment = -1;
            line    = -1;

            if (mLines == null)
            {
                return;
            }
            for (int i = 0; i < mLines.Count; ++i)
            {
                LineSegement seg   = mLines[i];
                int          total = seg.LineCount;
                for (int j = 0; j < total; ++j)
                {
                    Vector3 from;
                    Vector3 to;
                    seg.GetLine(j, out from, out to);
                    float dist = ChartCommon.SegmentPointSqrDistance(from, to, mouse);
                    if (dist < minDist)
                    {
                        minDist = dist;
                        segment = i;
                        line    = j;
                    }
                }
            }
            float sensitivity = 10f;

            if (mControl != null)
            {
                sensitivity = mControl.Sensitivity;
            }
            float thresh = (Thickness + sensitivity);

            if ((ViewRect.HasValue && !ViewRect.Value.Contains(mouse)) || minDist > thresh * thresh)
            {
                segment = -1;
                line    = -1;
            }
        }