I'm following the Redshift renderer page in the SDK for R26.1 to create nodes in a Redshift node graph. This all works fine, and adding nodes and making connections is all good. But I wondered, adding a node is simple but how do you remove a node? If adding a node works like this:
const::maxon::nodes::NodesGraphModelRef& nodeGraph = nodeMat->GetGraph(redshiftId) iferr_return;
maxon::GraphNode textureNode = nodeGraph.AddChild(maxon::Id(), textureId) iferr_return;
Then I'd have expected something like this to be available:
nodeGraph.RemoveChild(textureId); // no such function
But there is nothing like this to use. There is a Remove() function in the GraphModelInterface class but it's protected and not available from the NodesGraphModelRef class.
Is there a way to delete nodes from a Redshift material node graph? I wondered about using ReplaceChild() to replace the node to be deleted with nothing, but there doesn't seem to be a way to do that either.
GraphNode is a friend class of GraphModelInterface, so you should call textureNode.Remove()
For more information please read GraphNode Manual.
Ah...so simple in the end! Navigating this maze of interdependent classes used in the node system is not easy, that's my excuse
Many thanks for this, it solves a very tricky problem I was having.