WIP: MaterialX addon #104594

Closed
Bogdan Nagirniak wants to merge 34 commits from BogdanNagirniak/blender-addons:materialx-addon into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 11 additions and 0 deletions
Showing only changes of commit 24186fe54c - Show all commits

View File

@ -133,6 +133,8 @@ def generate_property_code(mx_param, category):
if mx_type == 'filename' and category in ("texture2d", "texture3d"): if mx_type == 'filename' and category in ("texture2d", "texture3d"):
prop_attr_strings.insert(0, "type=bpy.types.Image") prop_attr_strings.insert(0, "type=bpy.types.Image")
prop_attr_strings.append('update=MxNode.update_prop')
return f"{prop_type}({', '.join(prop_attr_strings)})" return f"{prop_type}({', '.join(prop_attr_strings)})"

View File

@ -78,6 +78,9 @@ class MxNode(bpy.types.ShaderNode):
_ui_folders = () # list of ui folders mentioned in nodedef _ui_folders = () # list of ui folders mentioned in nodedef
category = "" category = ""
def update_prop(self, context):
self.socket_value_update(context)
@classmethod @classmethod
def get_nodedef(cls, data_type): def get_nodedef(cls, data_type):
if not cls._data_types[data_type]['nd']: if not cls._data_types[data_type]['nd']:
@ -120,6 +123,7 @@ class MxNode(bpy.types.ShaderNode):
def update(self): def update(self):
bpy.app.timers.register(self.mark_invalid_links) bpy.app.timers.register(self.mark_invalid_links)
self.socket_value_update(bpy.context)
def mark_invalid_links(self): def mark_invalid_links(self):
if not is_mx_node_valid(self): if not is_mx_node_valid(self):
@ -150,6 +154,8 @@ class MxNode(bpy.types.ShaderNode):
for i, nd_output in enumerate(nodedef.getActiveOutputs()): for i, nd_output in enumerate(nodedef.getActiveOutputs()):
self.outputs[i].name = nd_output.getName() self.outputs[i].name = nd_output.getName()
self.update_prop(context)
def init(self, context): def init(self, context):
nodedef = self.nodedef nodedef = self.nodedef
@ -368,6 +374,9 @@ class MxNode(bpy.types.ShaderNode):
if f: if f:
self.inputs[i].hide = not getattr(self, self._folder_prop_name(f)) self.inputs[i].hide = not getattr(self, self._folder_prop_name(f))
if context:
self.update_prop(context)
def check_ui_folders(self): def check_ui_folders(self):
if not self._ui_folders: if not self._ui_folders:
return return