Skip to content

Commit

Permalink
Some simple fixes to get the addon ready for Blender 2.93.
Browse files Browse the repository at this point in the history
* We cannot use deepcopy for the __annotations__ dictionary for our
backwards compatible OSL nodes,
so build it manually.
* For our node sockets, make
"default_value" a real StringProperty instead of a regular python str.
  • Loading branch information
ian-hsieh committed Jun 17, 2021
1 parent e5d2a0c commit f334414
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
9 changes: 7 additions & 2 deletions rman_bl_nodes/__init__.py
Expand Up @@ -24,7 +24,6 @@
import traceback
import nodeitems_utils
from operator import attrgetter
from copy import deepcopy

# registers
from . import rman_bl_nodes_sockets
Expand Down Expand Up @@ -474,7 +473,13 @@ def free(self):
osl_node_type.init = init
osl_node_type.free = free
osl_node_type.bl_description = ntype.bl_description
osl_node_type.__annotations__ = deepcopy(ntype.__annotations__)
if "__annotations__" not in osl_node_type.__dict__:
setattr(osl_node_type, "__annotations__", {})
osl_node_type.__annotations__['rman_fake_node_group'] = StringProperty('__rman_ramps__', default='')

osl_node_type.__annotations__['plugin_name'] = StringProperty(name='Plugin Name',
default=name, options={'HIDDEN'})

class_generate_properties(osl_node_type, name, node_desc)
bpy.utils.register_class(osl_node_type)

Expand Down
53 changes: 29 additions & 24 deletions rman_bl_nodes/rman_bl_nodes_sockets.py
Expand Up @@ -40,18 +40,18 @@ def update_func(self, context):
),
('struct', 'Struct', bpy.types.NodeSocketString, (1.0, 0.344, 0.0, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
'struct_name': StringProperty(default='')
}
),
('vstruct', 'VStruct', bpy.types.NodeSocketString, (1.0, 0.0, 1.0, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('bxdf', 'Bxdf', bpy.types.NodeSocketString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('color', 'Color', bpy.types.NodeSocketColor, (1.0, 1.0, .5, 1.0), False,
Expand All @@ -76,42 +76,42 @@ def update_func(self, context):
),
('light', 'Light', bpy.types.NodeSocketString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('lightfilter', 'LightFilter', bpy.types.NodeSocketString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('displacement', 'Displacement', bpy.types.NodeSocketString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('samplefilter', 'SampleFilter', bpy.types.NodeSocketString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('displayfilter', 'DisplayFilter', bpy.types.NodeSocketString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('integrator', 'Integrator', bpy.types.NodeSocketString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('shader', 'Shader', bpy.types.NodeSocketShader, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('projection', 'Projection', bpy.types.NodeSocketString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
]
Expand Down Expand Up @@ -139,18 +139,18 @@ def update_func(self, context):
),
('struct', 'Struct', bpy.types.NodeSocketInterfaceString, (1.0, 0.344, 0.0, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
'struct_name': StringProperty(default='')
}
),
('vstruct', 'VStruct', bpy.types.NodeSocketInterfaceString, (1.0, 0.0, 1.0, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('bxdf', 'Bxdf', bpy.types.NodeSocketInterfaceString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('color', 'Color', bpy.types.NodeSocketInterfaceColor, (1.0, 1.0, .5, 1.0), False,
Expand All @@ -175,42 +175,42 @@ def update_func(self, context):
),
('light', 'Light', bpy.types.NodeSocketInterfaceString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('lightfilter', 'LightFilter', bpy.types.NodeSocketInterfaceString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('displacement', 'Displacement', bpy.types.NodeSocketInterfaceString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('samplefilter', 'SampleFilter', bpy.types.NodeSocketInterfaceString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('displayfilter', 'DisplayFilter', bpy.types.NodeSocketInterfaceString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('integrator', 'Integrator', bpy.types.NodeSocketInterfaceString, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('shader', 'Shader', bpy.types.NodeSocketInterfaceShader, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
('projection', 'Projection', bpy.types.NodeSocketInterfaceShader, (0.25, 1.0, 0.25, 1.0), True,
{
'default_value': '',
'default_value': StringProperty(default=''),
}
),
]
Expand Down Expand Up @@ -240,14 +240,19 @@ def draw(self, context, layout, node, text):

if self.hide and self.hide_value:
pass
elif self.is_linked or self.is_output or not hasattr(self, 'default_value'):
elif self.hide_value:
layout.label(text=self.get_pretty_name(node))
elif self.is_linked or self.is_output:
layout.label(text=self.get_pretty_name(node))
elif node.bl_idname in __CYCLES_GROUP_NODES__ or node.bl_idname == "PxrOSLPatternNode":
layout.prop(self, 'default_value',
text=self.get_pretty_name(node), slider=True)
else:
elif hasattr(node, self.name):
layout.prop(node, self.name,
text=self.get_pretty_name(node), slider=True)
else:
layout.label(text=self.get_pretty_name(node))

mat = getattr(context, 'material')
if mat:
output_node = shadergraph_utils.is_renderman_nodetree(mat)
Expand Down

0 comments on commit f334414

Please sign in to comment.