X-Git-Url: https://harrygodden.com/git/?p=convexer.git;a=blobdiff_plain;f=__init__.py;fp=__init__.py;h=c8fbad983495b7a3f434666bba8aa79b79cee504;hp=65e29e90811ea1940c26fe571539dd63a8984784;hb=4c8d56259c110af8a97ff44402ed6152921727b2;hpb=76fe1eb39ca36eb0b7e6123c0a3a7912817eee9c diff --git a/__init__.py b/__init__.py index 65e29e9..c8fbad9 100644 --- a/__init__.py +++ b/__init__.py @@ -986,12 +986,13 @@ def material_info(mat): def _variant_apply( val ): nonlocal mat - if isinstance( val, str ): - return val - else: + if isinstance( val, list ): for shader_variant in val: if shader_variant[0] == mat.cxr_data.shader: return shader_variant[1] + return val[0][1] + else: + return val # Find rootnodes if node == None: @@ -999,36 +1000,38 @@ def material_info(mat): for node_idname in node_def: for n in mat.node_tree.nodes: - if n.bl_idname == node_idname: + if n.name == node_idname: node_def = node_def[node_idname] node = n break for link in node_def: - if isinstance( node_def[link], dict ): - inputt = node.inputs[link] - inputt_def = node_def[link] + link_def = _variant_apply( node_def[link] ) + + if isinstance( link_def, dict ): + node_link = node.inputs[link] - if inputt.is_linked: + if node_link.is_linked: # look for definitions for the connected node type - con = inputt.links[0].from_node + from_node = node_link.links[0].from_node - for node_idname in inputt_def: - if con.bl_idname == node_idname: - con_def = inputt_def[ node_idname ] - _graph_read( con_def, con, depth+1 ) + node_name = from_node.name.split('.')[0] + if node_name in link_def: + from_node_def = link_def[ node_name ] + + _graph_read( from_node_def, from_node, depth+1 ) - # No definition found! :( + # No definition! :( # TODO: Make a warning for this? else: - if "default" in inputt_def: - prop = _variant_apply( inputt_def['default'] ) - info[prop] = inputt.default_value + if "default" in link_def: + prop = _variant_apply( link_def['default'] ) + info[prop] = node_link.default_value else: - prop = _variant_apply( node_def[link] ) - info[prop] = getattr(node,link) + prop = _variant_apply( link_def ) + info[prop] = getattr( node, link ) _graph_read(cxr_graph_mapping)