Brushstroke Tools: Initial Version #328

Merged
Simon Thommes merged 229 commits from SimonThommes/blender-studio-tools:brushstroke_tools-initial-version into main 2024-11-06 15:03:47 +01:00
5 changed files with 5 additions and 22 deletions
Showing only changes of commit 72bf473bf9 - Show all commits

View File

@ -9,8 +9,6 @@ def node_group_settings(ng_settings, op_settings):
ng_settings.nodes['Smear'].outputs[0].default_value = op_settings.brush_smear
#ng_settings.nodes["Object Info"].inputs[0].default_value = surface_object
return
class BSBST_OT_draw(bpy.types.Operator):
"""
Custom draw operation for hair curves

View File

@ -214,8 +214,6 @@ class BSBST_OT_init_preset(bpy.types.Operator):
utils.mark_socket_context_type(mod_info, 'Socket_2', 'FLOW_OBJECT')
utils.mark_socket_context_type(mod_info, 'Socket_3', 'UVMAP')
return
def init_draw(self, context):
settings = context.scene.BSBST_settings
@ -244,8 +242,6 @@ class BSBST_OT_init_preset(bpy.types.Operator):
utils.mark_socket_context_type(mod_info, 'Socket_2', 'SURFACE_OBJECT')
return
def execute(self, context):
settings = context.scene.BSBST_settings

View File

@ -38,7 +38,6 @@ def find_context_brushstrokes(dummy):
settings.active_context_brushstrokes_index = idx
SimonThommes marked this conversation as resolved Outdated

Generally, the code would be easier to read if line lengths were more limited. E.g. for Blender we have a 120 line length limit. That also makes it easier to have two files open next to each other. Such limits can be enforced automatically with auto-formatters like autopep8 (what we currently use in Blender) or e.g. black.

Generally, the code would be easier to read if line lengths were more limited. E.g. for Blender we have a 120 line length limit. That also makes it easier to have two files open next to each other. Such limits can be enforced automatically with auto-formatters like `autopep8` (what we currently use in Blender) or e.g. `black`.
settings.active_context_brushstrokes_index = max(min(settings.active_context_brushstrokes_index, len(settings.context_brushstrokes)-1), 0)
return
def update_active_brushstrokes(self, context):
settings = context.scene.BSBST_settings
@ -47,18 +46,15 @@ def update_active_brushstrokes(self, context):
if not ob:
continue
ob['BSBST_active'] = i == settings.active_context_brushstrokes_index
return
def update_brushstroke_method(self, context):
settings = context.scene.BSBST_settings
preset_name = f'BSBST-PRESET_{settings.brushstroke_method}'
preset_object = bpy.data.objects.get(preset_name)
settings.preset_object = preset_object
return
def update_link_context_type(self, context):
self.link_context = True
return
def get_brushstroke_name(self):
return self["name"]
@ -79,8 +75,6 @@ def set_brushstroke_name(self, value):
flow_ob.name = flow_name
flow_ob.data.name = flow_name
return
def get_active_context_brushstrokes_index(self):
if not self.get('active_context_brushstrokes_index'):
return 0

View File

@ -46,7 +46,7 @@ def draw_panel_ui_recursive(panel, panel_name, mod, items):
input_row.prop(mod, f'["{v.identifier}"]', text=k)
if not mod_info:
continue
if type(v) in utils.linkable_sockets and (attribute_toggle or not f'{v.identifier}_use_attribute' in mod.keys()):
if type(v) in utils.linkable_sockets and (attribute_toggle or f'{v.identifier}_use_attribute' not in mod.keys()):
s = mod_info.socket_info.get(v.identifier)
if not s:
continue
@ -59,7 +59,6 @@ def draw_panel_ui_recursive(panel, panel_name, mod, items):
row.prop(s, 'link_context', text='', icon=icon)
else:
row.prop(s, 'link_context_type', text='', emboss=True, icon='LINKED', icon_only=True)
return
class BSBST_UL_brushstroke_objects(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
@ -185,7 +184,6 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
style_panel.operator('brushstroke_tools.preset_add_mod', icon='ADD')
else:
style_panel.operator('object.modifier_add', text='Add Modifier', icon='ADD')
return
classes = [
BSBST_UL_brushstroke_objects,

View File

@ -35,7 +35,6 @@ def refresh_preset(dummy):
n = mod_info.socket_info.add()
n.name = v.identifier
# TODO: clean up old settings
return
def mark_socket_context_type(mod_info, socket_name, link_type):
socket_info = mod_info.socket_info.get(socket_name)
@ -43,7 +42,6 @@ def mark_socket_context_type(mod_info, socket_name, link_type):
socket_info = mod_info.socket_info.add()
socket_info.name = socket_name
socket_info.link_context_type = link_type
return
def get_addon_directory() -> str:
"""
@ -70,7 +68,6 @@ def ensure_resources():
if ng_missing:
import_resources(list(ng_missing))
return
def transfer_modifier(modifier_name, target_obj, source_obj):
"""
@ -104,7 +101,7 @@ def is_brushstrokes_object(object):
def is_surface_object(object):
for ob in bpy.data.objects:
if not 'BSBST_surface_object' in ob.keys():
if 'BSBST_surface_object' not in ob.keys():
continue
if ob['BSBST_surface_object'] == object:
return True
@ -112,19 +109,19 @@ def is_surface_object(object):
def is_flow_object(object):
for ob in bpy.data.objects:
if not 'BSBST_flow_object' in ob.keys():
if 'BSBST_flow_object' not in ob.keys():
continue
if ob['BSBST_flow_object'] == object:
return True
return False
def get_surface_object(bs):
if not 'BSBST_surface_object' in bs.keys():
if 'BSBST_surface_object' not in bs.keys():
return None
return bs['BSBST_surface_object']
def get_flow_object(bs):
if not 'BSBST_flow_object' in bs.keys():
if 'BSBST_flow_object' not in bs.keys():
return None
return bs['BSBST_flow_object']
SimonThommes marked this conversation as resolved Outdated

Would recommend using x not in y instead of not x in y for improved readability.

https://stackoverflow.com/a/3481700

Would recommend using `x not in y` instead of `not x in y` for improved readability. https://stackoverflow.com/a/3481700