Cycles Stand Alone Node Connect Issue #49985

Closed
opened 2016-11-10 13:29:18 +01:00 by David · 12 comments

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;
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; >
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @bocs

Added subscriber: @bocs
Author

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);
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); ```

Added subscribers: @ThomasDinges, @mont29

Added subscribers: @ThomasDinges, @mont29
Thomas Dinges was assigned by Bastien Montagne 2016-11-11 12:09:29 +01:00

@ThomasDinges think you handle Cycles standalone, right?

@ThomasDinges think you handle Cycles standalone, right?

This issue was referenced by blender/cycles@72fca011cb

This issue was referenced by blender/cycles@72fca011cbbe690c3c62e00b9f178cad2b1a3e53

This issue was referenced by 188ecee642

This issue was referenced by 188ecee6424f0eae1cf94ca9256795d068aa4200

This issue was referenced by blender/cycles@a5f1927f94

This issue was referenced by blender/cycles@a5f1927f94220654ab5f2d2237d2f10db1e7a5a0

This issue was referenced by 478e59a04e

This issue was referenced by 478e59a04ec8eec36217fbc0302e0fbe5ed519a9

Added subscriber: @brecht

Added subscriber: @brecht
Thomas Dinges was unassigned by Brecht Van Lommel 2016-11-12 17:01:08 +01:00
Brecht Van Lommel self-assigned this 2016-11-12 17:01:08 +01:00

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.

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.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#49985
No description provided.