Exemplo n.º 1
0
        float IClickable3D.DistanceToObject(Ray pointer)
        {
            mouseHovering = false;
            float   distance   = drawSlice.Plane.Distance(pointer);
            Vector3 mousePoint = pointer.Start + pointer.Direction * distance - locationOffset;

            hovered = false;
            float   closestPointDistance = float.PositiveInfinity;
            Vector3 closestPoint         = Vector3.Zero;

            if (distance > 0)
            {
                selectedTabIndex = -1;
                float minDistanceToTab = tabRadius;
                for (int i = 0; i < tabLocations.Count; i++)
                {
                    float d = (mousePoint - tabLocations[i]).Length;
                    if (d < minDistanceToTab)
                    {
                        selectedTabIndex = i;
                        minDistanceToTab = d;
                        hovered          = true;
                    }
                }
                if (selectedTabIndex < 0)
                {
                    foreach (var segment in TabPath.Segments(LineStrip.Type.Closed))
                    {
                        Vector3 test = segment.ClosestPoint(mousePoint);
                        float   d    = (mousePoint - test).Length;
                        if (d < closestPointDistance)
                        {
                            closestPoint         = test;
                            closestPointDistance = d;
                        }
                    }
                    if (closestPointDistance < toolRadius)
                    {
                        hovered      = true;
                        hoveredPoint = closestPoint;
                    }
                }
            }

            if (!hovered)
            {
                return(float.PositiveInfinity);
            }
            return(distance);
        }
Exemplo n.º 2
0
        void IClickable3D.MouseMove(Ray pointer)
        {
            float   distance   = drawSlice.Plane.Distance(pointer);
            Vector3 mousePoint = pointer.Start + pointer.Direction * distance + mouseOffset - locationOffset;

            selectedTabDraggedOff = true;
            float   closestPointDistance = tabRadius;
            Vector3 closestPoint         = mousePoint;

            foreach (var segment in TabPath.Segments(LineStrip.Type.Closed))
            {
                Vector3 test = segment.ClosestPoint(mousePoint);
                float   d    = (mousePoint - test).Length;
                if (d < closestPointDistance)
                {
                    selectedTabDraggedOff = false;
                    closestPoint          = test;
                    closestPointDistance  = d;
                }
            }

            tabLocations[selectedTabIndex] = closestPoint;
        }