From f42e0ba4564ebf96dde34e46c4aa7d7877503389 Mon Sep 17 00:00:00 2001 From: Adam P Date: Thu, 6 Apr 2023 17:42:59 +0200 Subject: [PATCH] Fix some cases of node name collisions Some compositor and texture nodes share names with the geometry nodes versions. This change sorts them so that the geometry ones are registered last, overriding the incorrect ones. The Math node is handled separately, because here the ShaderNodeMath is the correct one to use, for some reason. --- api/node_mapper.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/node_mapper.py b/api/node_mapper.py index 1b32b5d..e150d8d 100644 --- a/api/node_mapper.py +++ b/api/node_mapper.py @@ -107,11 +107,16 @@ class NodeNamespace: pass registered_nodes.add(node_type) denylist = {'filter'} # some nodes should be excluded. +class_denylist = {'CompositorNodeMath', 'TextureNodeMath'} +node_types_to_register = [] for node_type_name in dir(bpy.types): node_type = getattr(bpy.types, node_type_name) if isinstance(node_type, type) and issubclass(node_type, bpy.types.Node): - if node_type.is_registered_node_type() and node_type.bl_rna.name.lower() not in denylist: - register_node(node_type) + if node_type.is_registered_node_type() and node_type.bl_rna.name.lower() not in denylist and node_type.__name__ not in class_denylist: + node_types_to_register.append(node_type) +node_types_to_register.sort(key=lambda node_type: node_type.__name__.startswith("GeometryNode")) +for node_type in node_types_to_register: + register_node(node_type) def create_documentation(): temp_node_group = bpy.data.node_groups.new('temp_node_group', 'GeometryNodeTree') @@ -342,4 +347,4 @@ def transfer(self, attribute: Type, **kwargs) -> Type: return Type() def create_docs(): create_documentation() -bpy.app.timers.register(create_docs) \ No newline at end of file +bpy.app.timers.register(create_docs)