| 438 | } |
| 439 | |
| 440 | ShaderGraphPtr ShaderGraph::create(const ShaderGraph* parent, const NodeGraph& nodeGraph, GenContext& context) |
| 441 | { |
| 442 | NodeDefPtr nodeDef = nodeGraph.getNodeDef(); |
| 443 | if (!nodeDef) |
| 444 | { |
| 445 | throw ExceptionShaderGenError("Can't find nodedef '" + nodeGraph.getNodeDefString() + "' referenced by nodegraph '" + nodeGraph.getName() + "'"); |
| 446 | } |
| 447 | |
| 448 | string graphName = nodeGraph.getName(); |
| 449 | context.getShaderGenerator().getSyntax().makeValidName(graphName); |
| 450 | ShaderGraphPtr graph = std::make_shared<ShaderGraph>(parent, graphName, nodeGraph.getDocument(), context); |
| 451 | |
| 452 | // Clear classification |
| 453 | graph->_classification = 0; |
| 454 | |
| 455 | // Create input sockets from the nodedef |
| 456 | graph->addInputSockets(*nodeDef, context); |
| 457 | |
| 458 | // Create output sockets from the nodegraph |
| 459 | graph->addOutputSockets(nodeGraph, context); |
| 460 | |
| 461 | // Traverse all outputs and create all internal nodes |
| 462 | for (OutputPtr graphOutput : nodeGraph.getActiveOutputs()) |
| 463 | { |
| 464 | graph->addUpstreamDependencies(*graphOutput, context); |
| 465 | } |
| 466 | |
| 467 | // Finalize the graph |
| 468 | graph->finalize(context); |
| 469 | |
| 470 | return graph; |
| 471 | } |
| 472 | |
| 473 | ShaderGraphPtr ShaderGraph::create(const ShaderGraph* parent, const string& name, ElementPtr element, GenContext& context) |
| 474 | { |
nothing calls this directly
no test coverage detected