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); }
public void ConnectTo(InSplineNode node) { if (node != this) { SplineController.AddConnection(this, node); } }
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)); } }
public void UnconnectTo(InSplineNode node) { if (node != this) { if(SplineController != null) SplineController.RemoveConnections(this, node); } }
public void UnconnectTo(InSplineNode node) { if (node != this) { if (SplineController != null) { SplineController.RemoveConnections(this, node); } } }
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); } } }
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); }
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]); } } }
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(); }
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); }
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()); }
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)); } }
public InSplineConnection(InSplineNode nodeA, InSplineNode nodeB) { NodeA = nodeA; NodeB = nodeB; }
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(); }
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)); }
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; }
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(); }