Page MenuHome

Cycles Stand Alone Node Connect Issue
Closed, ResolvedPublic

Description

I believe this is a bug in the Cycles Standalone xml reader code.

When trying to connect sockets, it uses the following code:
*similar for both inputs and outputs...input shown for example

					foreach(ShaderInput *in, tonode->inputs)
						if(string_iequals(xml_socket_name(in->name().c_str()), to_socket_name.c_str()))
							input = in;

So it's looking for the socket by the UI name. (works most of the time)
as you see ShaderInput/ShaderOutput gets "name" from this code:

	ustring name() { return socket_type.ui_name; }

however, if the socket name doesn't match the UI name = fail to connect. (example below)

Now the function: void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)

	pugi::xml_attribute attr = xml_node.attribute(socket.name.c_str());

works cause socket is type of "SocketType" not ShaderInput/ShaderOutput, so it doesn't get the "UI" name.
*value is correctly assigned from xml

Where it fails:
I found the issue using the Disney branch, so i'll use that as the example.
the node "disney_bsdf" has a socket "base_color" and UI name as "Base Color"

It has no problem assigning the base_color (xml_read_node correctly uses socket name)
But if you try to connect another node to it the xml reader doesn't find it since it's looking for a "BaseColor" socket.
*it gets the UI name "Base Color", strips the space using xml_socket_name

so the simple fix in cycles_xml.cpp, compare using socket_type.name

					foreach(ShaderOutput *out, fromnode->outputs)
						if(string_iequals(xml_socket_name(out->socket_type.name.c_str()), from_socket_name.c_str()))
							output = out;

...

					foreach(ShaderInput *in, tonode->inputs)
						if(string_iequals(xml_socket_name(in->socket_type.name.c_str()), to_socket_name.c_str()))
							input = in;

Event Timeline

2nd thought, why even use "xml_socket_name" to strip spaces since they can't have a space unlike UI name?

fixed code could be shorted more like this:

					foreach(ShaderInput *in, tonode->inputs)
						if(string_iequals(in->socket_type.name.c_str(), to_socket_name.c_str()))
							input = in;

also why is LIGHT_DISTANT missing from light.cpp
*asking here also cause I consider it a node connect issue

I always add this to the code to : NODE_DEFINE(Light)

	type_enum.insert("distant", LIGHT_DISTANT);
Bastien Montagne (mont29) lowered the priority of this task from 90 to Normal.

@Thomas Dinges (dingto) think you handle Cycles standalone, right?

This new XML reading code is more my area. There is indeed some outdated code hanging around, we should be using the name rather than the UI name. I'll also fix the missing distant light.