From 1d033aabfd2fdfc8d0a7a5bf7d4e2eeb585e98ff Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 10:00:52 +0200 Subject: [PATCH] ShaderNode: Fix useless variables generation --- src/ShaderNode/ShaderGraph.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 5bdfe0284..6abfe5379 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -110,17 +110,19 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() qDebug() << shaderNode->name() << node->id(); auto it = usageCount.find(node->id()); if (it == usageCount.end()) + { + for (const auto& connectionSet : node->nodeState().getEntries(QtNodes::PortType::In)) + { + for (const auto& [uuid, conn] : connectionSet) + { + DetectVariables(conn->getNode(QtNodes::PortType::Out)); + } + } + it = usageCount.insert(node->id(), 0); + } (*it)++; - - for (const auto& connectionSet : node->nodeState().getEntries(QtNodes::PortType::In)) - { - for (const auto& [uuid, conn] : connectionSet) - { - DetectVariables(conn->getNode(QtNodes::PortType::Out)); - } - } }; m_flowScene.iterateOverNodes([&](QtNodes::Node* node)