Brushstroke Tools: Initial Version #328
Binary file not shown.
@ -41,6 +41,7 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
|||||||
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)
|
utils.set_deformable(brushstrokes_object, settings.deforming_surface)
|
||||||
|
utils.set_animated(brushstrokes_object, settings.animated)
|
||||||
return brushstrokes_object
|
return brushstrokes_object
|
||||||
|
|
||||||
def new_flow_object(self, context, name, surface_object):
|
def new_flow_object(self, context, name, surface_object):
|
||||||
@ -83,6 +84,7 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
|||||||
mod['Socket_3'] = False
|
mod['Socket_3'] = False
|
||||||
|
|
||||||
utils.set_deformable(flow_object, settings.deforming_surface)
|
utils.set_deformable(flow_object, settings.deforming_surface)
|
||||||
|
utils.set_animated(flow_object, settings.animated)
|
||||||
return flow_object
|
return flow_object
|
||||||
|
|
||||||
def main(self, context):
|
def main(self, context):
|
||||||
@ -221,6 +223,9 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
|||||||
# set deformable
|
# set deformable
|
||||||
set_brushstrokes_deformable(brushstrokes_object, settings.deforming_surface)
|
set_brushstrokes_deformable(brushstrokes_object, settings.deforming_surface)
|
||||||
|
|
||||||
|
# set animated
|
||||||
|
set_brushstrokes_animated(brushstrokes_object, settings.animated)
|
||||||
|
|
||||||
for mod in brushstrokes_object.modifiers:
|
for mod in brushstrokes_object.modifiers:
|
||||||
mod.show_group_selector = False
|
mod.show_group_selector = False
|
||||||
|
|
||||||
@ -557,6 +562,39 @@ def set_brushstrokes_deformable(bs_ob, deformable):
|
|||||||
return
|
return
|
||||||
utils.set_deformable(flow_ob, deformable)
|
utils.set_deformable(flow_ob, deformable)
|
||||||
|
|
||||||
|
def set_brushstrokes_animated(bs_ob, animated):
|
||||||
|
flow_ob = utils.get_flow_object(bs_ob)
|
||||||
|
|
||||||
|
if flow_ob:
|
||||||
|
ob = flow_ob
|
||||||
|
else:
|
||||||
|
ob = bs_ob
|
||||||
|
mod = ob.modifiers.get('Animation')
|
||||||
|
if animated:
|
||||||
|
if not mod:
|
||||||
|
mod = ob.modifiers.new('Animation', 'NODES')
|
||||||
|
mod.node_group = bpy.data.node_groups['.brushstroke_tools.animation']
|
||||||
|
|
||||||
|
mod_info = ob.modifier_info.get(mod.name)
|
||||||
|
if not mod_info:
|
||||||
|
mod_info = ob.modifier_info.add()
|
||||||
|
mod_info.name = mod.name
|
||||||
|
|
||||||
|
# ui visibility settings
|
||||||
|
mod_info.hide_ui = True
|
||||||
|
else:
|
||||||
|
mod['Socket_5'] = True
|
||||||
|
mod.node_group.interface_update(bpy.context)
|
||||||
|
with bpy.context.temp_override(object=ob):
|
||||||
|
bpy.ops.object.modifier_move_to_index(modifier=mod.name, index=0)
|
||||||
|
else:
|
||||||
|
if mod:
|
||||||
|
ob.modifiers.remove(mod)
|
||||||
|
utils.set_animated(bs_ob, animated)
|
||||||
|
if not flow_ob:
|
||||||
|
return
|
||||||
|
utils.set_animated(flow_ob, animated)
|
||||||
|
|
||||||
class BSBST_OT_copy_flow(bpy.types.Operator):
|
class BSBST_OT_copy_flow(bpy.types.Operator):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
@ -666,6 +704,43 @@ class BSBST_OT_switch_deformable(bpy.types.Operator):
|
|||||||
context.view_layer.depsgraph.update()
|
context.view_layer.depsgraph.update()
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
class BSBST_OT_switch_animated(bpy.types.Operator):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
bl_idname = "brushstroke_tools.switch_animated"
|
||||||
|
bl_label = "Switch Animated"
|
||||||
|
bl_description = "Switch the atnimated state of the brushstrokes"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
animated: bpy.props.BoolProperty( default=True,
|
||||||
|
name="Animated",)
|
||||||
|
switch_all: bpy.props.BoolProperty( default=False,
|
||||||
|
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_animated(ob, self.animated)
|
||||||
|
|
||||||
|
context.view_layer.depsgraph.update()
|
||||||
|
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
class BSBST_OT_init_preset(bpy.types.Operator):
|
class BSBST_OT_init_preset(bpy.types.Operator):
|
||||||
"""
|
"""
|
||||||
@ -1079,6 +1154,7 @@ classes = [
|
|||||||
BSBST_OT_copy_brushstrokes,
|
BSBST_OT_copy_brushstrokes,
|
||||||
BSBST_OT_copy_flow,
|
BSBST_OT_copy_flow,
|
||||||
BSBST_OT_switch_deformable,
|
BSBST_OT_switch_deformable,
|
||||||
|
BSBST_OT_switch_animated,
|
||||||
BSBST_OT_select_surface,
|
BSBST_OT_select_surface,
|
||||||
BSBST_OT_assign_surface,
|
BSBST_OT_assign_surface,
|
||||||
BSBST_OT_init_preset,
|
BSBST_OT_init_preset,
|
||||||
|
@ -235,6 +235,9 @@ class BSBST_Settings(bpy.types.PropertyGroup):
|
|||||||
deforming_surface: bpy.props.BoolProperty(default=False,
|
deforming_surface: bpy.props.BoolProperty(default=False,
|
||||||
name='Deforming Surface',
|
name='Deforming Surface',
|
||||||
description='Create brushstrokes layer for a deforming surface')
|
description='Create brushstrokes layer for a deforming surface')
|
||||||
|
animated: bpy.props.BoolProperty(default=False,
|
||||||
|
name='Animated',
|
||||||
|
description='Create brushstrokes layer for animated brushstrokes/flow')
|
||||||
edit_toggle: bpy.props.BoolProperty(default=False,
|
edit_toggle: bpy.props.BoolProperty(default=False,
|
||||||
name='Edit on Selection',
|
name='Edit on Selection',
|
||||||
description="Jump into the corresponding edit mode when selecting a brushstrokes layer")
|
description="Jump into the corresponding edit mode when selecting a brushstrokes layer")
|
||||||
|
@ -334,6 +334,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, 'animated')
|
||||||
new_advanced_panel.prop(settings, 'deforming_surface')
|
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')
|
||||||
@ -455,6 +456,10 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
|
|||||||
op = style_panel.operator('brushstroke_tools.switch_deformable', text='Deforming Surface', depress=deform, icon='MOD_SIMPLEDEFORM')
|
op = style_panel.operator('brushstroke_tools.switch_deformable', text='Deforming Surface', depress=deform, icon='MOD_SIMPLEDEFORM')
|
||||||
op.deformable = not deform
|
op.deformable = not deform
|
||||||
|
|
||||||
|
anim = utils.get_animated(style_object)
|
||||||
|
op = style_panel.operator('brushstroke_tools.switch_animated', text='Animated', depress=anim, icon='GP_MULTIFRAME_EDITING')
|
||||||
|
op.animated = not anim
|
||||||
|
|
||||||
class BSBST_MT_PIE_brushstroke_data_marking(bpy.types.Menu):
|
class BSBST_MT_PIE_brushstroke_data_marking(bpy.types.Menu):
|
||||||
bl_idname= "BSBST_MT_PIE_brushstroke_data_marking"
|
bl_idname= "BSBST_MT_PIE_brushstroke_data_marking"
|
||||||
bl_label = "Mark Brushstroke Flow"
|
bl_label = "Mark Brushstroke Flow"
|
||||||
|
@ -9,6 +9,7 @@ addon_version = (0,0,0)
|
|||||||
ng_list = [
|
ng_list = [
|
||||||
".brushstroke_tools.draw_processing",
|
".brushstroke_tools.draw_processing",
|
||||||
".brushstroke_tools.pre_processing",
|
".brushstroke_tools.pre_processing",
|
||||||
|
".brushstroke_tools.animation",
|
||||||
".brushstroke_tools.surface_fill",
|
".brushstroke_tools.surface_fill",
|
||||||
".brushstroke_tools.surface_draw",
|
".brushstroke_tools.surface_draw",
|
||||||
".brushstroke_tools.geometry_input",
|
".brushstroke_tools.geometry_input",
|
||||||
@ -446,11 +447,23 @@ def get_deformable(object):
|
|||||||
return object['BSBST_deformable']
|
return object['BSBST_deformable']
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_animated(object):
|
||||||
|
if not object:
|
||||||
|
return False
|
||||||
|
if 'BSBST_animated' in object.keys():
|
||||||
|
return object['BSBST_animated']
|
||||||
|
return False
|
||||||
|
|
||||||
def set_deformable(object, deformable=True):
|
def set_deformable(object, deformable=True):
|
||||||
if not object:
|
if not object:
|
||||||
return
|
return
|
||||||
object['BSBST_deformable'] = bool(deformable)
|
object['BSBST_deformable'] = bool(deformable)
|
||||||
|
|
||||||
|
def set_animated(object, animated=True):
|
||||||
|
if not object:
|
||||||
|
return
|
||||||
|
object['BSBST_animated'] = bool(animated)
|
||||||
|
|
||||||
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