Add Easy_Weight to Addons #47

Merged
Nick Alberelli merged 48 commits from feature/easy_weights into main 2023-05-17 22:13:57 +02:00
Showing only changes of commit 1f793683cf - Show all commits

View File

@ -1,6 +1,7 @@
import bpy import bpy
from bpy.props import * from bpy.props import BoolProperty, EnumProperty
from bpy.app.handlers import persistent from bpy.app.handlers import persistent
from .vertex_group_operators import FocusRogueDeformingWeights, DeleteEmptyDeformGroups, DeleteUnusedVertexGroups
class EASYWEIGHT_OT_wp_context_menu(bpy.types.Operator): class EASYWEIGHT_OT_wp_context_menu(bpy.types.Operator):
""" Custom Weight Paint context menu """ """ Custom Weight Paint context menu """
@ -44,42 +45,66 @@ class EASYWEIGHT_OT_wp_context_menu(bpy.types.Operator):
def poll(cls, context): def poll(cls, context):
return context.mode=='PAINT_WEIGHT' return context.mode=='PAINT_WEIGHT'
def draw(self, context): def draw_operators(self, layout, context):
layout = self.layout layout.label(text="Operators")
minimal = context.scene.easyweight_minimal op = layout.operator(
overlay = context.space_data.overlay 'object.vertex_group_normalize_all',
tool_settings = context.tool_settings text="Normalize Deform",
icon='IPO_SINE'
)
op.group_select_mode = 'BONE_DEFORM'
op.lock_active = False
row = layout.row() row = layout.row()
row.label(text="Brush Settings (Global)") row.operator("object.vertex_group_clean", icon='BRUSH_DATA', text="Clean 0").group_select_mode = 'ALL'
icon = 'HIDE_ON' if context.scene.easyweight_minimal else 'HIDE_OFF' row.operator(DeleteEmptyDeformGroups.bl_idname, text="Wipe Empty", icon='GROUP_BONE')
row.prop(context.scene, "easyweight_minimal", icon=icon, toggle=False, text="", emboss=False) row.operator(DeleteUnusedVertexGroups.bl_idname, text="Wipe Unused", icon='BRUSH_DATA')
layout.prop(self, "accumulate", toggle=True)
layout.prop(self, "front_faces", toggle=True) layout.operator(FocusRogueDeformingWeights.bl_idname, icon='ZOOM_IN')
row = layout.row(heading="Falloff Shape: ")
row.prop(self, "falloff_shape", expand=True) def draw_minimal(self, layout, context):
layout.separator() overlay = context.space_data.overlay
row = layout.row(heading="Symmetry: ")
# Compatibility for versions between rB5502517c3c12086c111a and rBfa9b05149c2ca3915a4fb26.
if hasattr(context.weight_paint_object.data, "use_mirror_vertex_group_x"):
row.prop(context.weight_paint_object.data, "use_mirror_vertex_group_x", text="X-Mirror", toggle=True)
else:
row.prop(context.weight_paint_object.data, "use_mirror_x", text="X-Mirror", toggle=True)
if hasattr(context.weight_paint_object.data, 'use_mirror_vertex_groups'):
row.prop(context.weight_paint_object.data, 'use_mirror_vertex_groups', text="Flip Groups", toggle=True)
if minimal: row = layout.row(heading="Mesh Display: ")
row = layout.row(heading="Symmetry: ") row.prop(overlay, "show_wpaint_contours", text="Weight Contours", toggle=True)
# Compatibility for versions between rB5502517c3c12086c111a and rBfa9b05149c2ca3915a4fb26. row.prop(overlay, "show_paint_wire", text="Wireframe", toggle=True)
if hasattr(context.weight_paint_object.data, "use_mirror_vertex_group_x"):
row.prop(context.weight_paint_object.data, "use_mirror_vertex_group_x", text="X-Mirror", toggle=True) row = layout.row(heading="Bone Display: ")
else: row.prop(overlay, "show_bones", text="Bones", toggle=True)
row.prop(context.weight_paint_object.data, "use_mirror_x", text="X-Mirror", toggle=True) if context.pose_object:
if hasattr(context.weight_paint_object.data, 'use_mirror_vertex_groups'): row.prop(context.pose_object, "show_in_front", toggle=True)
row.prop(context.weight_paint_object.data, 'use_mirror_vertex_groups', text="Flip Groups", toggle=True)
self.draw_operators(layout, context)
row = layout.row(heading="Mesh Display: ") def draw_overlay_settings(self, layout, context):
overlay = context.space_data.overlay
tool_settings = context.tool_settings
layout.label(text="Overlay")
row = layout.row()
row.use_property_split=True
row.prop(tool_settings, "vertex_group_user", text="Zero Weights Display", expand=True)
if hasattr(context.space_data, "overlay"):
row = layout.row()
row.prop(overlay, "show_wpaint_contours", text="Weight Contours", toggle=True) row.prop(overlay, "show_wpaint_contours", text="Weight Contours", toggle=True)
row.prop(overlay, "show_paint_wire", text="Wireframe", toggle=True) row.prop(overlay, "show_paint_wire", text="Wireframe", toggle=True)
row = layout.row(heading="Bone Display: ")
row.prop(overlay, "show_bones", text="Bones", toggle=True) row.prop(overlay, "show_bones", text="Bones", toggle=True)
row.prop(context.pose_object, "show_in_front", toggle=True)
return
if context.pose_object:
layout.label(text="Armature Display")
layout.prop(context.pose_object.data, "display_type", expand=True)
layout.prop(context.pose_object, "show_in_front", toggle=True)
def draw_weight_paint_settings(self, layout, context):
tool_settings = context.tool_settings
layout.label(text="Weight Paint settings") layout.label(text="Weight Paint settings")
row = layout.row() row = layout.row()
@ -95,22 +120,32 @@ class EASYWEIGHT_OT_wp_context_menu(bpy.types.Operator):
if hasattr(context.weight_paint_object.data, 'use_mirror_vertex_groups'): if hasattr(context.weight_paint_object.data, 'use_mirror_vertex_groups'):
row.prop(context.weight_paint_object.data, 'use_mirror_vertex_groups', text="Flip Groups", toggle=True) row.prop(context.weight_paint_object.data, 'use_mirror_vertex_groups', text="Flip Groups", toggle=True)
def draw_brush_settings(self, layout, context):
row = layout.row()
row.label(text="Brush Settings (Global)")
icon = 'HIDE_ON' if context.scene.easyweight_minimal else 'HIDE_OFF'
row.prop(context.scene, "easyweight_minimal", icon=icon, toggle=False, text="", emboss=False)
layout.prop(self, "accumulate", toggle=True)
layout.prop(self, "front_faces", toggle=True)
row = layout.row(heading="Falloff Shape: ")
row.prop(self, "falloff_shape", expand=True)
layout.separator() layout.separator()
layout.label(text="Overlay") def draw(self, context):
row = layout.row() layout = self.layout
row.use_property_split=True
row.prop(tool_settings, "vertex_group_user", text="Zero Weights Display", expand=True)
if hasattr(context.space_data, "overlay"):
row = layout.row()
row.prop(overlay, "show_wpaint_contours", text="Weight Contours", toggle=True)
row.prop(overlay, "show_paint_wire", text="Wireframe", toggle=True)
row.prop(overlay, "show_bones", text="Bones", toggle=True)
if context.pose_object: self.draw_brush_settings(layout, context)
layout.label(text="Armature Display") layout.separator()
layout.prop(context.pose_object.data, "display_type", expand=True)
layout.prop(context.pose_object, "show_in_front", toggle=True) if context.scene.easyweight_minimal:
self.draw_minimal(layout, context)
return
self.draw_weight_paint_settings(layout, context)
layout.separator()
self.draw_overlay_settings(layout, context)
layout.separator()
self.draw_operators(layout, context)
def invoke(self, context, event): def invoke(self, context, event):
active_brush = context.tool_settings.weight_paint.brush active_brush = context.tool_settings.weight_paint.brush