/// <summary> /// Recursive function which continues calculation on this node and all the child nodes /// Usually does not need to be called manually /// Returns success/failure of this node only /// </summary> public static bool ContinueCalculation(Node node) { if (!node.shouldCalculate) { return(false); } if (node.descendantsCalculated() && node.Calculate()) { // finished Calculating, continue with the children for (int outCnt = 0; outCnt < node.Outputs.Count; outCnt++) { NodeOutput output = node.Outputs [outCnt]; for (int conCnt = 0; conCnt < output.connections.Count; conCnt++) { ContinueCalculation(output.connections [conCnt].body); } } workList.Remove(node); node.calculated = true; return(true); } else if (!workList.Contains(node)) { // failed to calculate, add it to check later workList.Add(node); } return(false); }
/// <summary> /// Recursive function which continues calculation on this node and all the child nodes /// Usually does not need to be called manually /// Returns success/failure of this node only /// </summary> public static bool ContinueCalculation(Node node) { if (node.calculated) { return(false); } if ((node.descendantsCalculated() || node.isInLoop()) && node.Calculate()) { // finished Calculating, continue with the children node.calculated = true; calculationCount++; workList.Remove(node); if (node.ContinueCalculation && calculationCount < 1000) { for (int outCnt = 0; outCnt < node.Outputs.Count; outCnt++) { NodeOutput output = node.Outputs [outCnt]; for (int conCnt = 0; conCnt < output.connections.Count; conCnt++) { ContinueCalculation(output.connections [conCnt].body); } } } else if (calculationCount >= 1000) { Debug.LogError("Stopped calculation because of suspected Recursion. Maximum calculation iteration is currently at 1000!"); } return(true); } else if (!workList.Contains(node)) { // failed to calculate, add it to check later workList.Add(node); } return(false); }
private static bool ContinueCalculation(Node node) { if (node.calculated) { return(false); } if ((node.descendantsCalculated() || node.isInLoop()) && node.Calculate()) { node.calculated = true; calculationCount++; workList.Remove(node); if (node.ContinueCalculation && calculationCount < 1000) { for (int i = 0; i < node.Outputs.Count; i++) { NodeOutput nodeOutput = node.Outputs[i]; if (!nodeOutput.calculationBlockade) { for (int j = 0; j < nodeOutput.connections.Count; j++) { ContinueCalculation(nodeOutput.connections[j].body); } } } } else if (calculationCount >= 1000) { Debug.LogError("Stopped calculation because of suspected Recursion. Maximum calculation iteration is currently at 1000!"); } return(true); } if (!workList.Contains(node)) { workList.Add(node); } return(false); }
/// <summary> /// Recursive function which continues calculation on this node and all the child nodes /// Usually does not need to be called manually /// Returns success/failure of this node only /// </summary> public static bool ContinueCalculation (Node node) { if (node.calculated) return false; if ((node.descendantsCalculated () || node.isInLoop ()) && node.Calculate ()) { // finished Calculating, continue with the children node.calculated = true; calculationCount++; workList.Remove (node); if (node.ContinueCalculation && calculationCount < 1000) { foreach (NodeOutput output in node.Outputs) { foreach (NodeInput connection in output.connections) ContinueCalculation (connection.body); } } else if (calculationCount >= 1000) Debug.LogError ("Stopped calculation because of suspected Recursion. Maximum calculation iteration is currently at 1000!"); return true; } else if (!workList.Contains (node)) { // failed to calculate, add it to check later workList.Add (node); } return false; }
/// <summary> /// Recursive function which continues calculation on this node and all the child nodes /// Usually does not need to be called manually /// Returns success/failure of this node only /// </summary> public static bool ContinueCalculation(Node node) { if (node.descendantsCalculated () && node.Calculate ()) { // finished Calculating, continue with the children for (int outCnt = 0; outCnt < node.Outputs.Count; outCnt++) { NodeOutput output = node.Outputs [outCnt]; for (int conCnt = 0; conCnt < output.connections.Count; conCnt++) ContinueCalculation (output.connections [conCnt].body); } workList.Remove (node); node.calculated = true; return true; } else if (!workList.Contains (node)) { // failed to calculate, add it to check later workList.Add (node); } return false; }
/// <summary> /// Recursive function which continues calculation on this node and all the child nodes /// Returns success/failure of this node only /// </summary> public static bool ContinueCalculation(Node node, List <Node> workList) { if (calculationCount >= 100) { return(false); } if (node.calculated) { return(false); } bool inputsCalculated = node.descendantsCalculated(); //MikeD #if DEBUG_LOOPBASIC if (InputsCalculated || node.isInLoop()) { Debug.Log(GetPad() + "about to calculate " + node + " inputs calced " + InputsCalculated); } #endif if (timer == null) { timer = new System.Diagnostics.Stopwatch(); } timer.Reset(); timer.Start(); if ((inputsCalculated || node.AllowRecursion) && (node.Calculate())) { #if DEBUG_LOOPBASIC Debug.Log(GetPad() + " " + calculationCount + " node " + node + " calc success"); #endif // finished Calculating, continue with the children node.calculated = true; /* * int indexTimer = node.name.IndexOf("::"); * if (indexTimer!=-1 && indexTimer<4) * node.name = timer.ElapsedMilliseconds+"::"+node.name.Substring(indexTimer+2, node.name.Length- indexTimer-2) ; * else * node.name = timer.ElapsedMilliseconds+ "::"+ node.name; */ calculationCount++; workList.Remove(node); if (node.ContinueCalculation && calculationCount < 10000) { for (int outCnt = 0; outCnt < node.Outputs.Count; outCnt++) { NodeOutput output = node.Outputs[outCnt]; if (!output.calculationBlockade) { for (int conCnt = 0; conCnt < output.connections.Count; conCnt++) { ContinueCalculation(output.connections[conCnt].body, workList); } } } } else if (calculationCount >= 10000) { Debug.LogError(GetPad() + "Stopped calculation because of suspected Recursion. Maximum calculation iteration is currently at 1000!"); return(false); } return(true); //we actually executed one so go through the list again to see if new ones Canvas execute } else { #if DEBUG_LOOPBASIC Debug.Log(GetPad() + " " + calculationCount + " node " + node + " fail or skipped inputsCalced: " + InputsCalculated + " in loop " + node.isInLoop() + " calc res " + res); #endif if (!inputsCalculated) { //add inputs foreach (NodeInput input in node.Inputs) { if (input == null) { continue; } if (input.connection != null && !input.connection.body.calculated) { if (!workList.Contains(input.connection.body)) { workList.Add(input.connection.body); } } } } if (!workList.Contains(node)) { // failed to calculate, add it to check later workList.Add(node); } // if (node.AllowRecursion) // return true; } return(false); }