Brushstroke Tools: Initial Version #328
@ -4,7 +4,17 @@ from mathutils import Vector
|
|||||||
from bpy.types import WorkSpaceTool
|
from bpy.types import WorkSpaceTool
|
||||||
|
|
||||||
def preserve_draw_settings(context, restore=False):
|
def preserve_draw_settings(context, restore=False):
|
||||||
props_list = ['curve_type', 'depth_mode', 'use_pressure_radius', 'use_project_only_selected', 'radius_max', 'surface_offset']
|
props_list = ['curve_type',
|
||||||
|
'depth_mode',
|
||||||
|
'use_pressure_radius',
|
||||||
|
'use_project_only_selected',
|
||||||
|
'radius_taper_start',
|
||||||
|
'radius_taper_end',
|
||||||
|
'radius_min',
|
||||||
|
'radius_max',
|
||||||
|
'surface_offset',
|
||||||
|
'use_offset_absolute',
|
||||||
|
'use_stroke_endpoints',]
|
||||||
if restore:
|
if restore:
|
||||||
draw_settings_dict = context.scene['BSBST-TMP-draw_settings_dict']
|
draw_settings_dict = context.scene['BSBST-TMP-draw_settings_dict']
|
||||||
for k, v in draw_settings_dict.items():
|
for k, v in draw_settings_dict.items():
|
||||||
@ -25,8 +35,20 @@ class BSBST_tool_settings(bpy.types.PropertyGroup):
|
|||||||
soft_max=1,
|
soft_max=1,
|
||||||
update=None,
|
update=None,
|
||||||
)
|
)
|
||||||
radius_max: bpy.props.FloatProperty(name='Radius', default=1, min=0)
|
radius_taper_start: bpy.props.FloatProperty(name='Taper Start', default=0, min=0, max=1, subtype='FACTOR')
|
||||||
surface_offset: bpy.props.FloatProperty(name='Surface Offset', default=0)
|
radius_taper_end: bpy.props.FloatProperty(name='Taper End', default=0, min=0, max=1, subtype='FACTOR')
|
||||||
|
radius_min: bpy.props.FloatProperty(name='Radius Min', default=0, min=0, soft_max=10)
|
||||||
|
radius_max: bpy.props.FloatProperty(name='Radius Max', default=1, min=0, soft_max=10)
|
||||||
|
surface_offset: bpy.props.FloatProperty(name='Surface Offset', default=0, soft_max=10)
|
||||||
|
use_project_only_selected: bpy.props.BoolProperty(name='Project Onto Selected',
|
||||||
|
default=True,
|
||||||
|
description='Project the strokes only on selected objects if applicable.')
|
||||||
|
use_pressure_radius: bpy.props.BoolProperty(name='Use Pressure',
|
||||||
|
default=True,
|
||||||
|
description='Map tablet pressure to curve radius',)
|
||||||
|
use_offset_absolute: bpy.props.BoolProperty(name='Absolute Offset',
|
||||||
|
default=False,
|
||||||
|
description="Apply a fixed offset. (Don't scale by the radius.)")
|
||||||
|
|
||||||
class BSBST_OT_draw(bpy.types.Macro):
|
class BSBST_OT_draw(bpy.types.Macro):
|
||||||
"""
|
"""
|
||||||
@ -49,14 +71,24 @@ class BSBST_OT_pre_process_brushstroke(bpy.types.Operator):
|
|||||||
|
|
||||||
preserve_draw_settings(context)
|
preserve_draw_settings(context)
|
||||||
|
|
||||||
|
# fix some settings
|
||||||
context.tool_settings.curve_paint_settings.curve_type = 'POLY'
|
context.tool_settings.curve_paint_settings.curve_type = 'POLY'
|
||||||
context.tool_settings.curve_paint_settings.depth_mode = 'SURFACE'
|
context.tool_settings.curve_paint_settings.depth_mode = 'SURFACE'
|
||||||
context.tool_settings.curve_paint_settings.use_pressure_radius = True
|
context.tool_settings.curve_paint_settings.use_stroke_endpoints = False
|
||||||
is_other_object_selected = len(set(context.selected_objects) - {context.object}) > 0
|
|
||||||
context.tool_settings.curve_paint_settings.use_project_only_selected = is_other_object_selected
|
|
||||||
|
|
||||||
context.tool_settings.curve_paint_settings.radius_max = tool_settings.radius_max
|
is_other_object_selected = len(set(context.selected_objects) - {context.object}) > 0
|
||||||
context.tool_settings.curve_paint_settings.surface_offset = tool_settings.surface_offset
|
context.tool_settings.curve_paint_settings.use_project_only_selected = is_other_object_selected and tool_settings.use_project_only_selected
|
||||||
|
|
||||||
|
# propagate some settings from custom tool
|
||||||
|
props_list = ['use_pressure_radius',
|
||||||
|
'radius_taper_start',
|
||||||
|
'radius_taper_end',
|
||||||
|
'radius_min',
|
||||||
|
'radius_max',
|
||||||
|
'surface_offset',
|
||||||
|
'use_offset_absolute',]
|
||||||
|
for prop in props_list:
|
||||||
|
setattr(context.tool_settings.curve_paint_settings, prop, getattr(tool_settings, prop))
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
@ -116,12 +148,36 @@ class BrushstrokesCurves(WorkSpaceTool):
|
|||||||
{"properties": []}),
|
{"properties": []}),
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_settings(context, layout, tool):
|
def draw_settings(context, layout, tool, *, extra=False):
|
||||||
props = tool.operator_properties("brushstroke_tools.draw")
|
props = tool.operator_properties("brushstroke_tools.draw")
|
||||||
tool_settings = context.scene.BSBST_tool_settings
|
tool_settings = context.scene.BSBST_tool_settings
|
||||||
|
region_type = context.region.type
|
||||||
|
|
||||||
|
if region_type == 'TOOL_HEADER':
|
||||||
|
if not extra:
|
||||||
layout.prop(tool_settings , "radius_max")
|
layout.prop(tool_settings , "radius_max")
|
||||||
layout.prop(tool_settings , "surface_offset")
|
layout.prop(tool_settings , "surface_offset")
|
||||||
layout.prop(tool_settings, "brush_color")
|
layout.prop(tool_settings, "brush_color")
|
||||||
|
layout.popover("TOPBAR_PT_tool_settings_extra", text="...")
|
||||||
|
return
|
||||||
|
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = False
|
||||||
|
|
||||||
|
col = layout.column(align=True)
|
||||||
|
col.prop(tool_settings, "radius_taper_start", text="Taper Start", slider=True)
|
||||||
|
col.prop(tool_settings, "radius_taper_end", text="End", slider=True)
|
||||||
|
col = layout.column(align=True)
|
||||||
|
col.prop(tool_settings, "radius_min", text="Radius Min")
|
||||||
|
col.prop(tool_settings, "radius_max", text="Max")
|
||||||
|
col.prop(tool_settings, "use_pressure_radius", icon='STYLUS_PRESSURE', emboss=True)
|
||||||
|
|
||||||
|
layout.separator()
|
||||||
|
|
||||||
|
col = layout.column()
|
||||||
|
col.prop(tool_settings, "use_project_only_selected")
|
||||||
|
col.prop(tool_settings, "surface_offset")
|
||||||
|
col.prop(tool_settings, "use_offset_absolute")
|
||||||
|
|
||||||
classes = [
|
classes = [
|
||||||
BSBST_tool_settings,
|
BSBST_tool_settings,
|
||||||
|
Loading…
Reference in New Issue
Block a user