auto clean when edit shape
parent
73e9fa2cd9
commit
32abe225f3
38
operators.py
38
operators.py
|
@ -314,6 +314,7 @@ class BW_OT_paste_bone_groups(Operator):
|
|||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class BW_OT_add_folder(Operator):
|
||||
bl_idname = 'bonewidget.add_folder'
|
||||
bl_label = "Add Folder"
|
||||
|
@ -421,10 +422,6 @@ class BW_OT_create_widget(Operator):
|
|||
def poll(cls, context):
|
||||
return ctx.bone and ctx.active_widget
|
||||
|
||||
def invoke(self, context, event):
|
||||
self.symmetrize = ctx.prefs.symmetrize
|
||||
return self.execute(context)
|
||||
|
||||
def execute(self, context):
|
||||
folder = ctx.active_folder
|
||||
blend = folder.get_widget_path(folder.active_widget)
|
||||
|
@ -488,6 +485,8 @@ class BW_OT_edit_widget(Operator):
|
|||
bl_label = "Edit Widget"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
clean: BoolProperty(name='Clean', default=True)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return ctx.bone and ctx.bone.custom_shape
|
||||
|
@ -495,8 +494,12 @@ class BW_OT_edit_widget(Operator):
|
|||
def execute(self, context):
|
||||
#ctx._rig = ctx.rig
|
||||
widgets = ctx.selected_widgets
|
||||
|
||||
bones = ctx.selected_bones
|
||||
rig = ctx.rig
|
||||
prefs = ctx.prefs
|
||||
|
||||
if self.clean:
|
||||
bpy.ops.bonewidget.clean_widget()
|
||||
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
|
@ -507,10 +510,12 @@ class BW_OT_edit_widget(Operator):
|
|||
ctx.widget_layer_col.exclude = False
|
||||
ctx.widget_layer_col.hide_viewport = False
|
||||
|
||||
for w in widgets:
|
||||
link_to_col(w, ctx.widget_col)
|
||||
w.select_set(True)
|
||||
context.view_layer.objects.active = w
|
||||
for bone in bones:
|
||||
if not bone.custom_shape:
|
||||
continue
|
||||
#link_to_col(w, ctx.widget_col)
|
||||
bone.custom_shape.select_set(True)
|
||||
context.view_layer.objects.active = bone.custom_shape
|
||||
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
|
||||
|
@ -523,10 +528,10 @@ class BW_OT_return_to_rig(Operator):
|
|||
bl_label = "Return to rig"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
symmetrize: BoolProperty(name='Symmetrize', default=True)
|
||||
clean: BoolProperty(name='Clean', default=True)
|
||||
|
||||
def invoke(self, context, event):
|
||||
self.symmetrize = ctx.prefs.symmetrize
|
||||
self.symmetrize = ctx.prefs.auto_symmetrize
|
||||
return self.execute(context)
|
||||
|
||||
def execute(self, context):
|
||||
|
@ -553,9 +558,8 @@ class BW_OT_return_to_rig(Operator):
|
|||
for b in rig.pose.bones:
|
||||
b.bone.select = b in bones+[bone]
|
||||
|
||||
if self.symmetrize:
|
||||
for b in bones:
|
||||
symmetrize_bone_shape(b, prefix=ctx.prefs.prefix)
|
||||
if self.clean:
|
||||
bpy.ops.bonewidget.clean_widget()
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
@ -703,7 +707,7 @@ class BW_OT_clean_widget(Operator):
|
|||
return context.object and context.object.mode == 'POSE'
|
||||
|
||||
def invoke(self, context, event):
|
||||
self.symmetrize = ctx.prefs.symmetrize
|
||||
self.symmetrize = ctx.prefs.auto_symmetrize
|
||||
return self.execute(context)
|
||||
|
||||
def execute(self, context):
|
||||
|
@ -720,8 +724,8 @@ class BW_OT_clean_widget(Operator):
|
|||
if not shape:
|
||||
continue
|
||||
|
||||
bone.custom_shape = get_clean_shape(bone, shape, separate=True,
|
||||
rename=prefs.rename, col=ctx.widget_col, prefix=prefs.prefix)
|
||||
bone.custom_shape = get_clean_shape(bone, shape, separate=prefs.auto_separate,
|
||||
rename=prefs.auto_rename, col=ctx.widget_col, prefix=prefs.prefix, match=prefs.auto_match_transform)
|
||||
|
||||
if self.symmetrize:
|
||||
symmetrize_bone_shape(bone, prefix=ctx.prefs.prefix)
|
||||
|
|
|
@ -34,7 +34,7 @@ def transform_widgets(self, context):
|
|||
transform_mesh(shape.data, self.loc, self.rot, self.scale,
|
||||
self.xz_scale, self.size, self.slide, coords=coords)
|
||||
|
||||
if ctx.prefs.symmetrize:
|
||||
if ctx.prefs.auto_symmetrize:
|
||||
for bone in ctx.selected_bones:
|
||||
flipped_bone = get_flipped_bone(bone)
|
||||
if flipped_bone and flipped_bone.custom_shape in shapes:
|
||||
|
@ -212,10 +212,10 @@ class BW_prefs(AddonPreferences):
|
|||
prefix: StringProperty(name='Prefix', default='WGT-', description='Prefix for the shape object and data name')
|
||||
category: StringProperty(name='Tab', default='Rigging', update=lambda s,c: update_tab())
|
||||
|
||||
symmetrize: BoolProperty(name='Symmetrize', default=True, update=undo_redo)
|
||||
separate: BoolProperty(default=True, name="Separate", update=undo_redo)
|
||||
match_transform: BoolProperty(default=True, name="Match Transform", update=undo_redo)
|
||||
rename: BoolProperty(default=True, name="Rename", update=undo_redo)
|
||||
auto_symmetrize: BoolProperty(name='Symmetrize', default=True, update=undo_redo)
|
||||
auto_separate: BoolProperty(default=True, name="Separate", update=undo_redo)
|
||||
auto_match_transform: BoolProperty(default=True, name="Match Transform", update=undo_redo)
|
||||
auto_rename: BoolProperty(default=True, name="Rename", update=undo_redo)
|
||||
|
||||
show_transforms: BoolProperty(default=False)
|
||||
show_preferences: BoolProperty(default=False)
|
||||
|
|
8
ui.py
8
ui.py
|
@ -84,12 +84,12 @@ def draw_prefs(layout):
|
|||
split.label(text='Auto:')
|
||||
|
||||
col = split.column(align=True)
|
||||
add_bool_row(col, 'symmetrize', name='Symmetrize', icon='MOD_MIRROR')
|
||||
add_bool_row(col, 'separate', name='Separate', icon='UNLINKED')
|
||||
add_bool_row(col, 'auto_symmetrize', name='Symmetrize', icon='MOD_MIRROR')
|
||||
add_bool_row(col, 'auto_separate', name='Separate', icon='UNLINKED')
|
||||
|
||||
#col = row.column(align=True)
|
||||
add_bool_row(col, 'match_transform', name='Match Transform', icon='TRANSFORM_ORIGINS')
|
||||
add_bool_row(col, 'rename', name='Rename', icon='SYNTAX_OFF')
|
||||
add_bool_row(col, 'auto_match_transform', name='Match Transform', icon='TRANSFORM_ORIGINS')
|
||||
add_bool_row(col, 'auto_rename', name='Rename', icon='SYNTAX_OFF')
|
||||
|
||||
#bpy.ops.wm.save_userpref()
|
||||
prefs_unsaved = bpy.context.preferences.is_dirty
|
||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in New Issue