Merge pull request #29 from taoria/working-in-process

fix:delay a feature cause losing output data during runtime
main
taoria 3 years ago committed by GitHub
commit e8aafd00cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      TNode/TNodeCore/Runtime/Attributes/PortTypeConversion.cs
  2. 31
      TNode/TNodeCore/Runtime/Components/RuntimeGraph.cs
  3. 2
      TNode/TNodeCore/Runtime/RuntimeNode.cs

@ -1,3 +1,3 @@
namespace TNodeCore.Attribute{ namespace TNode.TNodeCore.Runtime.Attributes{
} }

@ -185,6 +185,7 @@ namespace TNodeCore.Components{
/// Build the graph tool and other dependencies for the runtime graph /// Build the graph tool and other dependencies for the runtime graph
/// </summary> /// </summary>
public void Build(){ public void Build(){
if (_build) return;
var link = graphData.NodeLinks; var link = graphData.NodeLinks;
//iterate links and create runtime nodes //iterate links and create runtime nodes
@ -259,15 +260,35 @@ namespace TNodeCore.Components{
public List<RuntimeNode> GetRuntimeNodesOfType(Type type){ public List<RuntimeNode> GetRuntimeNodesOfType(Type type){
return RuntimeNodes.Values.Where(x => type.IsAssignableFrom(type)).ToList(); return RuntimeNodes.Values.Where(x => type.IsAssignableFrom(type)).ToList();
} }
public void RunNodesOfType(Type t){ public void RunNodesOfType(Type t,bool isCaching= false){
var nodes = GetRuntimeNodesOfType(t); var nodes = GetRuntimeNodesOfType(t);
_graphTool.StartCachingPort(); if(isCaching)
_graphTool.StartCachingPort();
foreach (var runtimeNode in nodes){ foreach (var runtimeNode in nodes){
RunOnDependency(runtimeNode.NodeData); RunOnDependency(runtimeNode.NodeData);
} }
_graphTool.EndCachingPort(); if(isCaching)
_graphTool.EndCachingPort();
}
/// <summary>
/// Run some nodes ,if the node is not in the graph ,then pass
/// </summary>
/// <param name="runtimeNodes"></param>
/// <param name="isCaching"></param>
public void RunNodes(List<RuntimeNode> runtimeNodes,bool isCaching= false){
if (isCaching){
_graphTool.StartCachingPort();
}
foreach (var runtimeNode in runtimeNodes){
if(!RuntimeNodes.ContainsKey(runtimeNode.NodeData.id)){
continue;
}
RunOnDependency(runtimeNode.NodeData);
}
if (isCaching){
_graphTool.EndCachingPort();
}
} }
private void ModifyOrCreateOutNode(NodeLink linkData){ private void ModifyOrCreateOutNode(NodeLink linkData){
var outNodeId = linkData.outPort.nodeDataId; var outNodeId = linkData.outPort.nodeDataId;

@ -21,8 +21,6 @@ namespace TNodeCore.Runtime{
public void SetInput(string portName,object value){ public void SetInput(string portName,object value){
var valueType = value.GetType(); var valueType = value.GetType();
var portType = _portAccessors[portName].Type; var portType = _portAccessors[portName].Type;
Debug.Log(valueType);
Debug.Log(portType);
if(portType!=valueType && !portType.IsAssignableFrom(valueType)){ if(portType!=valueType && !portType.IsAssignableFrom(valueType)){
var res =RuntimeCache.RuntimeCache.Instance.GetConvertedValue(valueType, portType, value); var res =RuntimeCache.RuntimeCache.Instance.GetConvertedValue(valueType, portType, value);
_portAccessors[portName].SetValue(this.NodeData, res); _portAccessors[portName].SetValue(this.NodeData, res);

Loading…
Cancel
Save