diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-17 21:18:40 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-17 21:18:40 +0300 |
commit | 65ea9ec948ff6f80dbabc46e3a17b55b0c03893c (patch) | |
tree | 9d99500bbcd5fb01c36231ba3eacb92d9a9bb524 /release/scripts/modules | |
parent | 5c038a69300b154ef06fc8e410ecdf1b7a90f164 (diff) |
node_shader_utils: Proper fix for node_normalmap accessor returning ellipsis value.
Ellipsis value is internal ingredient only, to tag hidden _node_normalmap
'real' property as not yet initialized. Public node_normalmap accessor
should never ever have that value, it's either None or a valid node!
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/bpy_extras/node_shader_utils.py | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/release/scripts/modules/bpy_extras/node_shader_utils.py b/release/scripts/modules/bpy_extras/node_shader_utils.py index 89e3585e621..d06d66d3cb5 100644 --- a/release/scripts/modules/bpy_extras/node_shader_utils.py +++ b/release/scripts/modules/bpy_extras/node_shader_utils.py @@ -230,29 +230,28 @@ class PrincipledBSDFWrapper(ShaderWrapper): def node_normalmap_get(self): - if not self.use_nodes: + if not self.use_nodes or self.node_principled_bsdf is None: return None - if self.node_principled_bsdf is not None: - node_principled = self.node_principled_bsdf + node_principled = self.node_principled_bsdf + if self._node_normalmap is ...: + # Running only once, trying to find a valid normalmap node. + if node_principled.inputs["Normal"].is_linked: + node_normalmap = node_principled.inputs["Normal"].links[0].from_node + if node_normalmap.bl_idname == 'ShaderNodeNormalMap': + self._node_normalmap = node_normalmap + self._grid_to_location(0, 0, ref_node=node_normalmap) if self._node_normalmap is ...: - # Running only once, trying to find a valid normalmap node. - if node_principled.inputs["Normal"].is_linked: - node_normalmap = node_principled.inputs["Normal"].links[0].from_node - if node_normalmap.bl_idname == 'ShaderNodeNormalMap': - self._node_normalmap = node_normalmap - self._grid_to_location(0, 0, ref_node=node_normalmap) - if self._node_normalmap is ...: - self._node_normalmap = None - if self._node_normalmap is None and not self.is_readonly: - tree = self.material.node_tree - nodes = tree.nodes - links = tree.links - - node_normalmap = nodes.new(type='ShaderNodeNormalMap') - node_normalmap.label = "Normal/Map" - self._grid_to_location(-1, -2, dst_node=node_normalmap, ref_node=node_principled) - # Link - links.new(node_normalmap.outputs["Normal"], node_principled.inputs["Normal"]) + self._node_normalmap = None + if self._node_normalmap is None and not self.is_readonly: + tree = self.material.node_tree + nodes = tree.nodes + links = tree.links + + node_normalmap = nodes.new(type='ShaderNodeNormalMap') + node_normalmap.label = "Normal/Map" + self._grid_to_location(-1, -2, dst_node=node_normalmap, ref_node=node_principled) + # Link + links.new(node_normalmap.outputs["Normal"], node_principled.inputs["Normal"]) return self._node_normalmap node_normalmap = property(node_normalmap_get) |