2019-12-12 22:25:40 +08:00
|
|
|
|
#include<hgl/graph/shader/node/node.h>
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_NODE_NAMESPACE
|
2019-12-16 20:35:51 +08:00
|
|
|
|
param::InputParam *Node::AddInput(bool mj,const UTF8String &n,const param::ParamType &pt)
|
2019-12-13 17:55:20 +08:00
|
|
|
|
{
|
|
|
|
|
param::InputParam *ip=new param::InputParam(mj,n,pt);
|
|
|
|
|
|
|
|
|
|
input_params.Add(ip);
|
|
|
|
|
|
|
|
|
|
input_params_by_name.Add(n,ip);
|
2019-12-16 20:35:51 +08:00
|
|
|
|
|
|
|
|
|
return ip;
|
2019-12-13 17:55:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-16 20:35:51 +08:00
|
|
|
|
param::OutputParam *Node::AddOutput(const UTF8String &n,const param::ParamType &pt)
|
2019-12-13 17:55:20 +08:00
|
|
|
|
{
|
|
|
|
|
param::OutputParam *op=new param::OutputParam(n,pt);
|
|
|
|
|
|
|
|
|
|
output_params.Add(op);
|
|
|
|
|
|
|
|
|
|
output_params_by_name.Add(n,op);
|
2019-12-16 20:35:51 +08:00
|
|
|
|
|
|
|
|
|
return op;
|
2019-12-13 17:55:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-14 13:42:16 +08:00
|
|
|
|
bool Node::JoinInput(const UTF8String ¶m_name,node::Node *n,param::OutputParam *op)
|
2019-12-13 17:55:20 +08:00
|
|
|
|
{
|
2019-12-16 20:35:51 +08:00
|
|
|
|
if(param_name.IsEmpty()||!n||!op)
|
2019-12-13 17:55:20 +08:00
|
|
|
|
return(false);
|
|
|
|
|
|
2019-12-14 13:42:16 +08:00
|
|
|
|
if(!n->IsOutput(op))
|
2019-12-13 17:55:20 +08:00
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
|
|
param::InputParam *ip=GetInput(param_name);
|
|
|
|
|
|
|
|
|
|
if(!ip)
|
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
|
|
return ip->Join(n,op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Node::IsOutput(param::OutputParam *op)
|
2019-12-13 11:20:08 +08:00
|
|
|
|
{
|
|
|
|
|
if(!op)return(false);
|
|
|
|
|
|
|
|
|
|
return output_params.IsExist(op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Node::Check()
|
2019-12-12 22:25:40 +08:00
|
|
|
|
{
|
|
|
|
|
const int count=input_params.GetCount();
|
|
|
|
|
param::InputParam **ip=input_params.GetData();
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<count;i++)
|
|
|
|
|
if(!(*ip)->Check())
|
|
|
|
|
return(false);
|
|
|
|
|
else
|
|
|
|
|
++ip;
|
|
|
|
|
|
|
|
|
|
return(true);
|
|
|
|
|
}
|
|
|
|
|
END_SHADER_NODE_NAMESPACE
|