Skip to content

Commit

Permalink
Fix some cases of node name collisions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
r-flash authored and carson-katri committed Apr 21, 2023
1 parent 258a7c5 commit f42e0ba
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions api/node_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -342,4 +347,4 @@ def transfer(self, attribute: Type, **kwargs) -> Type: return Type()

def create_docs():
create_documentation()
bpy.app.timers.register(create_docs)
bpy.app.timers.register(create_docs)

0 comments on commit f42e0ba

Please sign in to comment.