Skip to content

Commit

Permalink
Merge pull request #2353 from KhronosGroup/fix_2323
Browse files Browse the repository at this point in the history
Fix #2323 fix crash looping socket link
  • Loading branch information
julienduroure authored Sep 26, 2024
2 parents 9e5063c + 0efcbf1 commit 844b923
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions addons/io_scene_gltf2/blender/exp/material/search_node_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,16 +871,20 @@ def get_texture_transform_from_mapping_node(mapping_node, export_settings):
return texture_transform

def check_if_is_linked_to_active_output(shader_socket, group_path):

# Here, group_path must be copyed, because if there are muliply link that enter/exit a group node
# This will modify it, and we don't want to modify the original group_path (from the parameter) inside the loop
for link in shader_socket.links:

# If we are entering a node group
if link.to_node.type == "GROUP":
socket_name = link.to_socket.name
sockets = [n for n in link.to_node.node_tree.nodes if n.type == "GROUP_INPUT"][0].outputs
socket = [s for s in sockets if s.name == socket_name][0]
group_path.append(link.to_node)
new_group_path = group_path.copy()
new_group_path.append(link.to_node)
#TODOSNode : Why checking outputs[0] ? What about alpha for texture node, that is outputs[1] ????
ret = check_if_is_linked_to_active_output(socket, group_path) # recursive until find an output material node
ret = check_if_is_linked_to_active_output(socket, new_group_path) # recursive until find an output material node
if ret is True:
return True
continue
Expand All @@ -890,9 +894,9 @@ def check_if_is_linked_to_active_output(shader_socket, group_path):
socket_name = link.to_socket.name
sockets = group_path[-1].outputs
socket = [s for s in sockets if s.name == socket_name][0]
group_path = group_path[:-1]
new_group_path = group_path[:-1]
#TODOSNode : Why checking outputs[0] ? What about alpha for texture node, that is outputs[1] ????
ret = check_if_is_linked_to_active_output(socket, group_path) # recursive until find an output material node
ret = check_if_is_linked_to_active_output(socket, new_group_path) # recursive until find an output material node
if ret is True:
return True
continue
Expand Down

0 comments on commit 844b923

Please sign in to comment.