Brushstroke Tools: Initial Version #328
Binary file not shown.
@ -91,6 +91,7 @@ class BSBST_OT_post_process_brushstroke(bpy.types.Operator):
|
|||||||
self.ng_process.nodes['settings.color'].value = [*tool_settings.brush_color, 1.]
|
self.ng_process.nodes['settings.color'].value = [*tool_settings.brush_color, 1.]
|
||||||
self.ng_process.nodes['view_vector'].vector = context.space_data.region_3d.view_rotation @ Vector((0.0, 0.0, 1.0))
|
self.ng_process.nodes['view_vector'].vector = context.space_data.region_3d.view_rotation @ Vector((0.0, 0.0, 1.0))
|
||||||
self.ng_process.nodes['new_key'].boolean = context.scene.tool_settings.use_keyframe_insert_auto
|
self.ng_process.nodes['new_key'].boolean = context.scene.tool_settings.use_keyframe_insert_auto
|
||||||
|
self.ng_process.nodes['deform'].boolean = utils.get_deformable(context.object)
|
||||||
if 'BSBST_surface_object' in context.object.keys():
|
if 'BSBST_surface_object' in context.object.keys():
|
||||||
if context.object['BSBST_surface_object']:
|
if context.object['BSBST_surface_object']:
|
||||||
self.ng_process.nodes['surface_object'].inputs[0].default_value = context.object['BSBST_surface_object']
|
self.ng_process.nodes['surface_object'].inputs[0].default_value = context.object['BSBST_surface_object']
|
||||||
|
@ -44,6 +44,7 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
|||||||
context.collection.objects.link(brushstrokes_object)
|
context.collection.objects.link(brushstrokes_object)
|
||||||
brushstrokes_object.visible_shadow = False
|
brushstrokes_object.visible_shadow = False
|
||||||
brushstrokes_object['BSBST_version'] = utils.addon_version
|
brushstrokes_object['BSBST_version'] = utils.addon_version
|
||||||
|
utils.set_deformable(brushstrokes_object, settings.deforming_surface)
|
||||||
return brushstrokes_object
|
return brushstrokes_object
|
||||||
|
|
||||||
def new_flow_object(self, context, name, surface_object):
|
def new_flow_object(self, context, name, surface_object):
|
||||||
@ -85,7 +86,7 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
|||||||
mod['Socket_2'] = surface_object
|
mod['Socket_2'] = surface_object
|
||||||
mod['Socket_3'] = False
|
mod['Socket_3'] = False
|
||||||
|
|
||||||
#utils.set_deformable()
|
utils.set_deformable(flow_object, settings.deforming_surface)
|
||||||
return flow_object
|
return flow_object
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
@ -216,7 +217,9 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
|||||||
with context.temp_override(**override):
|
with context.temp_override(**override):
|
||||||
bpy.ops.object.material_slot_add()
|
bpy.ops.object.material_slot_add()
|
||||||
brushstrokes_object.material_slots[-1].material = mat
|
brushstrokes_object.material_slots[-1].material = mat
|
||||||
|
|
||||||
|
# set deformable
|
||||||
|
set_brushstrokes_deformable(brushstrokes_object, settings.deforming_surface)
|
||||||
|
|
||||||
for mod in brushstrokes_object.modifiers:
|
for mod in brushstrokes_object.modifiers:
|
||||||
mod.show_group_selector = False
|
mod.show_group_selector = False
|
||||||
@ -446,6 +449,63 @@ class BSBST_OT_select_surface(bpy.types.Operator):
|
|||||||
surface_object.select_set(True)
|
surface_object.select_set(True)
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
def set_brushstrokes_deformable(bs_ob, deformable):
|
||||||
|
|
||||||
|
flow_ob = utils.get_flow_object(bs_ob)
|
||||||
|
|
||||||
|
for mod in bs_ob.modifiers:
|
||||||
|
if not mod.type == 'NODES':
|
||||||
|
continue
|
||||||
|
if not mod.node_group:
|
||||||
|
continue
|
||||||
|
if mod.node_group.name == '.brushstroke_tools.pre_processing':
|
||||||
|
mod['Socket_3'] = deformable
|
||||||
|
elif mod.node_group.name == '.brushstroke_tools.surface_fill':
|
||||||
|
mod['Socket_27'] = deformable
|
||||||
|
elif mod.node_group.name == '.brushstroke_tools.surface_draw':
|
||||||
|
mod['Socket_15'] = deformable
|
||||||
|
utils.set_deformable(bs_ob, deformable)
|
||||||
|
if not flow_ob:
|
||||||
|
return
|
||||||
|
utils.set_deformable(flow_ob, deformable)
|
||||||
|
|
||||||
|
class BSBST_OT_switch_deformable(bpy.types.Operator):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
bl_idname = "brushstroke_tools.switch_deformable"
|
||||||
|
bl_label = "Switch Deformable"
|
||||||
|
bl_description = "Switch the deformable state of the brushstrokes"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
deformable: bpy.props.BoolProperty( default=True,
|
||||||
|
name="Deformable",)
|
||||||
|
switch_all: bpy.props.BoolProperty( default=True,
|
||||||
|
name="All Brushstrokes",
|
||||||
|
description="Switch all Brushstroke Layers of Current Surface Object.")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
settings = context.scene.BSBST_settings
|
||||||
|
return bool(settings.context_brushstrokes)
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
settings = context.scene.BSBST_settings
|
||||||
|
|
||||||
|
if self.switch_all:
|
||||||
|
bs_objects = [bpy.data.objects.get(bs.name) for bs in settings.context_brushstrokes]
|
||||||
|
bs_objects = [bs for bs in bs_objects if bs]
|
||||||
|
else:
|
||||||
|
bs_objects = [utils.get_active_context_brushstrokes_object(context)]
|
||||||
|
if not bs_objects:
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
for ob in bs_objects:
|
||||||
|
set_brushstrokes_deformable(ob, self.switch_all)
|
||||||
|
|
||||||
|
context.view_layer.depsgraph.update()
|
||||||
|
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
class BSBST_OT_init_preset(bpy.types.Operator):
|
class BSBST_OT_init_preset(bpy.types.Operator):
|
||||||
"""
|
"""
|
||||||
@ -809,6 +869,7 @@ classes = [
|
|||||||
BSBST_OT_delete_brushstrokes,
|
BSBST_OT_delete_brushstrokes,
|
||||||
BSBST_OT_duplicate_brushstrokes,
|
BSBST_OT_duplicate_brushstrokes,
|
||||||
BSBST_OT_copy_brushstrokes,
|
BSBST_OT_copy_brushstrokes,
|
||||||
|
BSBST_OT_switch_deformable,
|
||||||
BSBST_OT_select_surface,
|
BSBST_OT_select_surface,
|
||||||
BSBST_OT_init_preset,
|
BSBST_OT_init_preset,
|
||||||
BSBST_OT_make_preset,
|
BSBST_OT_make_preset,
|
||||||
|
@ -273,6 +273,9 @@ class BSBST_Settings(bpy.types.PropertyGroup):
|
|||||||
reuse_flow: bpy.props.BoolProperty(default=False,
|
reuse_flow: bpy.props.BoolProperty(default=False,
|
||||||
name='Re-use Flow Object',
|
name='Re-use Flow Object',
|
||||||
description="Re-use flow object from active brushstrokes when creating new brushstrokes")
|
description="Re-use flow object from active brushstrokes when creating new brushstrokes")
|
||||||
|
deforming_surface: bpy.props.BoolProperty(default=False,
|
||||||
|
name='Deforming Surface',
|
||||||
|
description='Create brushstrokes layer for a deforming surface')
|
||||||
edit_toggle: bpy.props.BoolProperty(default=True,
|
edit_toggle: bpy.props.BoolProperty(default=True,
|
||||||
name='Edit Active Brushstrokes',
|
name='Edit Active Brushstrokes',
|
||||||
description="Jump into the corresponding edit mode when selecting/creating a brushstrokes layer")
|
description="Jump into the corresponding edit mode when selecting/creating a brushstrokes layer")
|
||||||
|
@ -225,6 +225,8 @@ class BSBST_MT_bs_context_menu(bpy.types.Menu):
|
|||||||
op.copy_all = False
|
op.copy_all = False
|
||||||
op = layout.operator('brushstroke_tools.copy_brushstrokes', text='Copy All to Selected Objects')
|
op = layout.operator('brushstroke_tools.copy_brushstrokes', text='Copy All to Selected Objects')
|
||||||
op.copy_all = True
|
op.copy_all = True
|
||||||
|
op = layout.operator('brushstroke_tools.switch_deformable')
|
||||||
|
op.switch_all = False
|
||||||
|
|
||||||
class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
|
class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
@ -273,6 +275,7 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
|
|||||||
if settings.curve_mode in ['CURVE', 'GP']:
|
if settings.curve_mode in ['CURVE', 'GP']:
|
||||||
new_advanced_panel.label(text='Curve mode does not support drawing on deformed geometry', icon='ERROR')
|
new_advanced_panel.label(text='Curve mode does not support drawing on deformed geometry', icon='ERROR')
|
||||||
|
|
||||||
|
new_advanced_panel.prop(settings, 'deforming_surface')
|
||||||
new_advanced_panel.prop(settings, 'assign_materials')
|
new_advanced_panel.prop(settings, 'assign_materials')
|
||||||
new_advanced_panel.prop(settings, 'reuse_flow')
|
new_advanced_panel.prop(settings, 'reuse_flow')
|
||||||
new_advanced_panel.prop(settings, 'estimate_dimensions')
|
new_advanced_panel.prop(settings, 'estimate_dimensions')
|
||||||
|
@ -261,6 +261,18 @@ def is_flow_object(object):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_deformable(object):
|
||||||
|
if not object:
|
||||||
|
return False
|
||||||
|
if 'BSBST_deformable' in object.keys():
|
||||||
|
return object['BSBST_deformable']
|
||||||
|
return False
|
||||||
|
|
||||||
|
def set_deformable(object, deformable=True):
|
||||||
|
if not object:
|
||||||
|
return
|
||||||
|
object['BSBST_deformable'] = bool(deformable)
|
||||||
|
|
||||||
def get_surface_object(bs):
|
def get_surface_object(bs):
|
||||||
if not bs:
|
if not bs:
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user