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
from bpy.props import *
from bpy.props import BoolProperty, EnumProperty
from bpy.app.handlers import persistent
from .vertex_group_operators import FocusRogueDeformingWeights, DeleteEmptyDeformGroups, DeleteUnusedVertexGroups
class EASYWEIGHT_OT_wp_context_menu(bpy.types.Operator):
""" Custom Weight Paint context menu """
@ -44,24 +45,26 @@ class EASYWEIGHT_OT_wp_context_menu(bpy.types.Operator):
def poll(cls, context):
return context.mode=='PAINT_WEIGHT'
def draw(self, context):
layout = self.layout
def draw_operators(self, layout, context):
layout.label(text="Operators")
minimal = context.scene.easyweight_minimal
overlay = context.space_data.overlay
tool_settings = context.tool_settings
op = layout.operator(
'object.vertex_group_normalize_all',
text="Normalize Deform",
icon='IPO_SINE'
)
op.group_select_mode = 'BONE_DEFORM'
op.lock_active = False
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()
row.operator("object.vertex_group_clean", icon='BRUSH_DATA', text="Clean 0").group_select_mode = 'ALL'
row.operator(DeleteEmptyDeformGroups.bl_idname, text="Wipe Empty", icon='GROUP_BONE')
row.operator(DeleteUnusedVertexGroups.bl_idname, text="Wipe Unused", icon='BRUSH_DATA')
if minimal:
layout.operator(FocusRogueDeformingWeights.bl_idname, icon='ZOOM_IN')
def draw_minimal(self, layout, context):
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"):
@ -77,9 +80,31 @@ class EASYWEIGHT_OT_wp_context_menu(bpy.types.Operator):
row = layout.row(heading="Bone Display: ")
row.prop(overlay, "show_bones", text="Bones", toggle=True)
if context.pose_object:
row.prop(context.pose_object, "show_in_front", toggle=True)
return
self.draw_operators(layout, context)
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_paint_wire", text="Wireframe", toggle=True)
row.prop(overlay, "show_bones", text="Bones", toggle=True)
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")
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'):
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.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_paint_wire", text="Wireframe", toggle=True)
row.prop(overlay, "show_bones", text="Bones", toggle=True)
def draw(self, context):
layout = self.layout
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)
self.draw_brush_settings(layout, context)
layout.separator()
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):
active_brush = context.tool_settings.weight_paint.brush