Ejemplo n.º 1
0
        private void CombineInRange(InSplineNode splineNode, float range)
        {
            InSplineNode[] inRange = splineNode.SplineController.Nodes.FindAllNoNulls(
                n => Vector3.Distance(n.transform.position, splineNode.transform.position) < range && n != splineNode);

            CombineNodes(splineNode, inRange);
        }
Ejemplo n.º 2
0
 public void ConnectTo(InSplineNode node)
 {
     if (node != this)
     {
         SplineController.AddConnection(this, node);
     }
 }
Ejemplo n.º 3
0
 public void ConnectTo(InSplineNode node)
 {
     if (node != this)
     {
         SplineController.AddConnection(this, node);
     }
 }
Ejemplo n.º 4
0
        public static void OnSceneDraw(InSpline spline)
        {
            if (spline == null)
            {
                return;
            }

            if (spline.Nodes.Count < 2)
            {
                return;
            }



            for (int i = 0; i < spline.Connections.Count; i++)
            {
                InSplineNode nodeA = spline.Connections[i].NodeA;
                InSplineNode nodeB = spline.Connections[i].NodeB;

                if (nodeA == null || nodeB == null)
                {
                    continue;
                }

                float weight = 2.0f;
                if (Selection.Contains(nodeA.gameObject) || Selection.Contains(nodeB.gameObject))
                {
                    weight = 6.0f;
                }

                Handles.DrawAAPolyLine(weight, SetPoints(nodeA.transform.position, nodeB.transform.position));
            }
        }
Ejemplo n.º 5
0
 public void UnconnectTo(InSplineNode node)
 {
     if (node != this)
     {
         if(SplineController != null)
             SplineController.RemoveConnections(this, node);
     }
 }
Ejemplo n.º 6
0
 public void UnconnectTo(InSplineNode node)
 {
     if (node != this)
     {
         if (SplineController != null)
         {
             SplineController.RemoveConnections(this, node);
         }
     }
 }
Ejemplo n.º 7
0
 public void RemoveConnections(InSplineNode nodeA, InSplineNode nodeB)
 {
     for (int i = 0; i < Connections.Count; i++)
     {
         var connection = Connections[i];
         if (connection.NodeA == nodeA && connection.NodeB == nodeB || connection.NodeA == nodeB && connection.NodeB == nodeA)
         {
             Connections.SafeRemoveAt(ref i);
         }
     }
 }
Ejemplo n.º 8
0
 public bool ContainsConnection(InSplineNode a, InSplineNode b)
 {
     for (int i = 0; i < Connections.Count; i++)
     {
         var con = Connections[i];
         if (con.NodeA == a && con.NodeB == b || con.NodeA == b && con.NodeB == a)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 9
0
 private void ConnectInRange(InSplineNode splineNode, float range)
 {
     InSplineNode[] inRange = splineNode.SplineController.Nodes.FindAllNoNulls(
         n => Vector3.Distance(n.transform.position, splineNode.transform.position) < range);
     for (int i = 0; i < inRange.Length; i++)
     {
         for (int j = i; j < inRange.Length; j++)
         {
             inRange[i].ConnectTo(inRange[j]);
         }
     }
 }
Ejemplo n.º 10
0
        private void CombineNodes(InSplineNode splineNode, InSplineNode[] conditioned)
        {
            InUndoHelper.DoInGroup(() => {
            #if UNITY_4_1 || UNITY_4_2
                Undo.RegisterSceneUndo("Combine nodes");
            #else
                UndoAll("Combine nodes");
            #endif
                HashSet <InSplineNode> periphery = new HashSet <InSplineNode>();
                foreach (var node in conditioned)
                {
                    var connected = node.SplineController.FindConnectedNodes(node);
                    for (int i = 0; i < connected.Length; i++)
                    {
                        var connectedTo = connected[i];
                        periphery.Add(connectedTo);
                    }

                    node.UnconnectAll();
                }

                foreach (var node in conditioned)
                {
                    if (node != null)
                    {
                        InUndoHelper.Destroy(node.gameObject);
                    }
                }

                foreach (var node in periphery)
                {
                    splineNode.ConnectTo(node);
                }

                var connections = splineNode.SplineController.Connections;
                for (int i = 0; i < connections.Count; i++)
                {
                    if (!connections[i].IsValid())
                    {
                        connections.SafeRemoveAt(ref i);
                    }
                }
            });
            //Selection.activeGameObject = null;
            Repaint();
        }
Ejemplo n.º 11
0
        private void CombineSelectedNodes()
        {
            InSplineNode splineNode = Selection.activeGameObject.GetComponent <InSplineNode>();

            GameObject[] selectedGO = Selection.gameObjects.FindAllNoNulls(go =>
            {
                var node = go.GetComponent <InSplineNode>();
                if (node == null || splineNode == node)
                {
                    return(false);
                }
                return(true);
            });
            InSplineNode[] selected = selectedGO.Convert(go => go.GetComponent <InSplineNode>());

            CombineNodes(splineNode, selected);
        }
Ejemplo n.º 12
0
    public InSplineNode[] FindConnectedNodes(InSplineNode node)
    {
        List <InSplineNode> nodes = new List <InSplineNode>();

        foreach (var connection in Connections)
        {
            if (connection.NodeA == node)
            {
                nodes.Add(connection.NodeB);
            }
            else if (connection.NodeB == node)
            {
                nodes.Add(connection.NodeA);
            }
        }
        return(nodes.ToArray());
    }
Ejemplo n.º 13
0
    public void AddConnection(InSplineNode nodeA, InSplineNode nodeB)
    {
        bool contains = false;

        for (int i = 0; i < Connections.Count; i++)
        {
            var connection = Connections[i];
            if ((connection.NodeA == nodeA && connection.NodeB == nodeB) || (connection.NodeA == nodeB && connection.NodeB == nodeA))
            {
                contains = true;
                break;
            }
        }
        if (!contains)
        {
            Connections.Add(new InSplineConnection(nodeA, nodeB));
        }
    }
Ejemplo n.º 14
0
    private void CombineInRange(InSplineNode splineNode, float range)
    {
        InSplineNode[] inRange = splineNode.SplineController.Nodes.FindAllNoNulls(
                n => Vector3.Distance(n.transform.position, splineNode.transform.position) < range && n != splineNode);

        CombineNodes(splineNode, inRange);
    }
Ejemplo n.º 15
0
 public InSplineConnection(InSplineNode nodeA, InSplineNode nodeB)
 {
     NodeA = nodeA;
     NodeB = nodeB;
 }
Ejemplo n.º 16
0
    private void CombineNodes(InSplineNode splineNode, InSplineNode[] conditioned)
    {
        InUndoHelper.DoInGroup(() => { 
            #if UNITY_4_1 || UNITY_4_2
                    Undo.RegisterSceneUndo("Combine nodes");
            #else
                    UndoAll("Combine nodes");
            #endif
            HashSet<InSplineNode> periphery = new HashSet<InSplineNode>();
            foreach (var node in conditioned)
            {
                var connected = node.SplineController.FindConnectedNodes(node);
                for (int i = 0; i < connected.Length; i++)
                {
                    var connectedTo = connected[i];
                    periphery.Add(connectedTo);
                }

                node.UnconnectAll();
            }

            foreach (var node in conditioned)
            {
                if(node != null)
                    InUndoHelper.Destroy(node.gameObject);
            }

            foreach (var node in periphery)
            {
                splineNode.ConnectTo(node);
            }

            var connections = splineNode.SplineController.Connections;
            for (int i = 0; i < connections.Count; i++)
            {
                if (!connections[i].IsValid())
                {
                    connections.SafeRemoveAt(ref i);
                }
            }
        });
        //Selection.activeGameObject = null;
        Repaint();
    }
Ejemplo n.º 17
0
 public void AddConnection(InSplineNode nodeA, InSplineNode nodeB)
 {
     bool contains = false;
     for (int i = 0; i < Connections.Count; i++)
     {
         var connection = Connections[i];
         if ((connection.NodeA == nodeA && connection.NodeB == nodeB) || (connection.NodeA == nodeB && connection.NodeB == nodeA))
         {
             contains = true;
             break;
         }
     }
     if(!contains)
         Connections.Add(new InSplineConnection(nodeA, nodeB));
 }
Ejemplo n.º 18
0
 public void RemoveConnections(InSplineNode nodeA, InSplineNode nodeB)
 {
     for (int i = 0; i < Connections.Count; i++)
     {
         var connection = Connections[i];
         if (connection.NodeA == nodeA && connection.NodeB == nodeB || connection.NodeA == nodeB && connection.NodeB == nodeA)
         {
             Connections.SafeRemoveAt(ref i);
         }
     }
 }
Ejemplo n.º 19
0
 public bool ContainsConnection(InSplineNode a, InSplineNode b)
 {
     for (int i = 0; i < Connections.Count; i++)
     {
         var con = Connections[i];
         if (con.NodeA == a && con.NodeB == b || con.NodeA == b && con.NodeB == a)
             return true;
     }
     return false;
 }
Ejemplo n.º 20
0
 private void ConnectInRange(InSplineNode splineNode, float range)
 {
     InSplineNode[] inRange = splineNode.SplineController.Nodes.FindAllNoNulls(
             n => Vector3.Distance(n.transform.position, splineNode.transform.position) < range);
     for (int i = 0; i < inRange.Length; i++)
     {
         for (int j = i; j < inRange.Length; j++)
         {
             inRange[i].ConnectTo(inRange[j]);
         }
     }
 }
Ejemplo n.º 21
0
 public InSplineNode[] FindConnectedNodes(InSplineNode node)
 {
     List<InSplineNode> nodes = new List<InSplineNode>();
     foreach (var connection in Connections)
     {
         if(connection.NodeA == node)
             nodes.Add(connection.NodeB);
         else if (connection.NodeB == node)
             nodes.Add(connection.NodeA);
     }
     return nodes.ToArray();
 }
Ejemplo n.º 22
0
 public InSplineConnection(InSplineNode nodeA, InSplineNode nodeB)
 {
     NodeA = nodeA;
     NodeB = nodeB;
 }