Skip to content

Commit

Permalink
Fix for custom node groups in graph editor menu (AcademySoftwareFound…
Browse files Browse the repository at this point in the history
…ation#1617)

Currently if you have node definitions added to groups that aren't in the fixed list that MaterialXGraphEditor understands, then they won't be added to the menu.
  • Loading branch information
ld-kerley authored Dec 19, 2023
1 parent 1ef4619 commit 95d9ee0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/MaterialXGraphEditor/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,7 @@ void Graph::createNodeUIList(mx::DocumentPtr doc)

auto nodeDefs = doc->getNodeDefs();
std::unordered_map<std::string, std::vector<mx::NodeDefPtr>> groupToNodeDef;
std::vector<std::string> groupList = std::vector(NODE_GROUP_ORDER.begin(), NODE_GROUP_ORDER.end());

for (const auto& nodeDef : nodeDefs)
{
Expand All @@ -1257,14 +1258,20 @@ void Graph::createNodeUIList(mx::DocumentPtr doc)
group = NODE_GROUP_ORDER.back();
}

// If the group is not in the groupList already (seeded by NODE_GROUP_ORDER) then add it.
if (std::find(groupList.begin(), groupList.end(), group) == groupList.end())
{
groupList.emplace_back(group);
}

if (groupToNodeDef.find(group) == groupToNodeDef.end())
{
groupToNodeDef[group] = std::vector<mx::NodeDefPtr>();
}
groupToNodeDef[group].push_back(nodeDef);
}

for (const auto& group : NODE_GROUP_ORDER)
for (const auto& group : groupList)
{
auto it = groupToNodeDef.find(group);
if (it != groupToNodeDef.end())
Expand Down

0 comments on commit 95d9ee0

Please sign in to comment.