예제 #1
0
    public SketchObject Hover(Vector3 mouse, Camera camera, Matrix4x4 tf, ref double objDist)
    {
        double       min           = -1.0;
        SketchObject hoveredObject = null;

        foreach (var e in entities)
        {
            if (!e.isSelectable)
            {
                continue;
            }
            var dist = e.Select(Input.mousePosition, camera, tf);
            if (dist < 0.0)
            {
                continue;
            }
            if (dist > hoverRadius)
            {
                continue;
            }
            if (min >= 0.0 && dist > min)
            {
                continue;
            }
            min           = dist;
            hoveredObject = e;
        }
        foreach (var c in constraints)
        {
            if (!c.isSelectable)
            {
                continue;
            }
            var dist = c.Select(Input.mousePosition, camera, tf);
            if (dist < 0.0)
            {
                continue;
            }
            if (dist > Sketch.hoverRadius)
            {
                continue;
            }
            if (min >= 0.0 && dist > min)
            {
                continue;
            }
            min           = dist;
            hoveredObject = c;
        }
        objDist = min;
        return(hoveredObject);
    }
예제 #2
0
 public void Remove(SketchObject sko)
 {
     if (sko.sketch != this)
     {
         Debug.Log("Can't remove this constraint!");
         return;
     }
     if (DetailEditor.instance.hovered == sko)
     {
         DetailEditor.instance.hovered = null;
     }
     if (sko is Constraint)
     {
         var c = sko as Constraint;
         if (constraints.Remove(c.guid))
         {
             c.Destroy();
             MarkDirtySketch(topo: c is PointsCoincident, constraints: true);
             constraintsTopologyChanged = true;
         }
         else
         {
             Debug.Log("Can't remove this constraint!");
         }
     }
     if (sko is Entity)
     {
         var e = sko as Entity;
         if (entities.Remove(e.guid))
         {
             e.Destroy();
             MarkDirtySketch(topo: true, entities: true);
         }
         else
         {
             Debug.Log("Can't remove this entity!");
         }
     }
 }
예제 #3
0
    public SketchObject Hover(Vector3 mouse, Camera camera, Matrix4x4 tf, ref double objDist)
    {
        double       min           = -1.0;
        SketchObject hoveredObject = null;

        foreach (var en in entities)
        {
            var e = en.Value;
            if (!e.isVisible)
            {
                continue;
            }
            if (!e.isSelectable)
            {
                continue;
            }
            var dist = e.Select(Input.mousePosition, camera, tf);
            if (dist < 0.0)
            {
                continue;
            }
            if (dist > hoverRadius)
            {
                continue;
            }
            if (min >= 0.0 && dist > min)
            {
                continue;
            }
            min           = dist;
            hoveredObject = e;
        }

        Dictionary <Constraint, double> candidates = new Dictionary <Constraint, double>();

        foreach (var c in constraints.Values)
        {
            if (!c.isVisible)
            {
                continue;
            }
            if (!c.isSelectable)
            {
                continue;
            }
            var dist = c.Select(Input.mousePosition, camera, tf);
            if (dist < 0.0)
            {
                continue;
            }
            if (dist > hoverRadius)
            {
                continue;
            }
            if (min >= 0.0 && dist >= min)
            {
                continue;
            }
            min           = dist;
            hoveredObject = c;
            candidates.Add(c, dist);
        }

        if (hoveredObject is Constraint)
        {
            if (candidates.Count > 0)
            {
                for (int i = 0; i < candidates.Count; i++)
                {
                    var current = candidates.ElementAt(i).Key;
                    if (DetailEditor.instance.selection.All(id => id.ToString() != current.id.ToString()))
                    {
                        continue;
                    }
                    var next = candidates.ElementAt((i + 1) % candidates.Count);
                    objDist = next.Value;
                    return(next.Key);
                }
            }
        }
        objDist = min;
        return(hoveredObject);
    }