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
3 changed files with 11 additions and 27 deletions
Showing only changes of commit 47d0dc77eb - Show all commits

View File

@ -18,12 +18,8 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
@classmethod
def poll(cls, context):
object = context.object
if not object:
return False
if not object in context.selected_objects:
return False
return object.type in ['MESH', 'CURVE', 'CURVES', 'GREASEPENCIL']
surface_object = utils.get_active_context_surface_object(context)
return bool(surface_object)
def new_brushstrokes_object(self, context, name):
settings = context.scene.BSBST_settings
@ -97,11 +93,7 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
utils.ensure_resources()
bpy.ops.object.mode_set(mode='OBJECT')
context_object = context.object
surf_ob = utils.get_surface_object(context_object)
if surf_ob:
context_object = surf_ob
surface_object = context_object if context.object in context.selected_objects else None
surface_object = utils.get_active_context_surface_object(context)
flow_object = None
if not surface_object.data.uv_layers.active:

View File

@ -310,25 +310,10 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
layout = self.layout
settings = context.scene.BSBST_settings
surface_object = None
if settings.context_brushstrokes:
active_brushstrokes_object = bpy.data.objects.get(settings.context_brushstrokes[settings.active_context_brushstrokes_index].name)
if active_brushstrokes_object:
if 'BSBST_surface_object' in active_brushstrokes_object.keys():
surface_object = active_brushstrokes_object['BSBST_surface_object']
else:
surface_object = context.object
else:
surface_object = context.object
else:
surface_object = context.object
surface_object = utils.get_active_context_surface_object(context)
surface_row = layout.row()
if surface_object:
valid_surface = surface_object.type in ['MESH'] and (surface_object in context.selected_objects or context.object in context.selected_objects)
else:
valid_surface = False
if valid_surface:
surface_row.label(text=f'{surface_object.name}', icon='OUTLINER_OB_SURFACE')
else:
surface_row.alert = True

View File

@ -510,6 +510,13 @@ def get_active_context_brushstrokes_object(context):
bs_ob = bpy.data.objects.get(bs.name)
return bs_ob
def get_active_context_surface_object(context):
bs_ob = get_active_context_brushstrokes_object(context)
if bs_ob:
return get_surface_object(bs_ob)
if context.object.type == 'MESH':
return context.object
def flow_name(name):
return f'{name}-FLOW'