From d93c2275212fd40af3d793a814faa8e9e4561ee0 Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Mon, 20 Feb 2023 14:09:35 +0100 Subject: [PATCH] feat: initial material input support --- multi_user/bl_types/bl_material.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/multi_user/bl_types/bl_material.py b/multi_user/bl_types/bl_material.py index f016277..ef610bf 100644 --- a/multi_user/bl_types/bl_material.py +++ b/multi_user/bl_types/bl_material.py @@ -64,7 +64,7 @@ def load_node(node_data: dict, node_tree: bpy.types.ShaderNodeTree): if idx < len(inputs_data) and hasattr(inpt, "default_value"): loaded_input = inputs_data[idx] try: - if inpt.type in ['OBJECT', 'COLLECTION']: + if inpt.type in ['OBJECT', 'COLLECTION', 'MATERIAL']: inpt.default_value = get_datablock_from_uuid(loaded_input, None) else: inpt.default_value = loaded_input @@ -80,7 +80,7 @@ def load_node(node_data: dict, node_tree: bpy.types.ShaderNodeTree): if idx < len(outputs_data) and hasattr(output, "default_value"): loaded_output = outputs_data[idx] try: - if output.type in ['OBJECT', 'COLLECTION']: + if output.type in ['OBJECT', 'COLLECTION', 'MATERIAL']: output.default_value = get_datablock_from_uuid(loaded_output, None) else: output.default_value = loaded_output @@ -351,6 +351,11 @@ def get_node_tree_dependencies(node_tree: bpy.types.NodeTree) -> list: def has_texture(node): return ( node.type in ['ATTRIBUTE_SAMPLE_TEXTURE','TEXTURE'] and node.texture) + + def has_material(node): return ( + node.type == 'MATERIAL' and node.inputs[2].default_value is not None + ) + deps = [] for node in node_tree.nodes: @@ -360,7 +365,9 @@ def get_node_tree_dependencies(node_tree: bpy.types.NodeTree) -> list: deps.append(node.node_tree) elif has_texture(node): deps.append(node.texture) - + elif has_material(node): + print(node.inputs[2].default_value.name) + deps.append(node.inputs[2].default_value) return deps