Rigify 0.5 general maintenance and bug fixing
This commit is contained in:
parent
5b1b7b9489
commit
f2b3935533
33
rigify/ui.py
33
rigify/ui.py
|
@ -24,6 +24,7 @@ from bpy.props import StringProperty
|
|||
from .utils import get_rig_type, MetarigError
|
||||
from .utils import write_metarig, write_widget
|
||||
from .utils import unique_name
|
||||
from .utils import upgradeMetarigTypes, outdated_types
|
||||
from . import rig_lists
|
||||
from . import generate
|
||||
|
||||
|
@ -46,11 +47,13 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
|
|||
id_store = C.window_manager
|
||||
|
||||
if obj.mode in {'POSE', 'OBJECT'}:
|
||||
layout.operator("pose.rigify_generate", text="Generate")
|
||||
|
||||
WARNING = "Warning: Some features may change after generation"
|
||||
show_warning = False
|
||||
show_update_metarig = False
|
||||
|
||||
check_props = ['IK_follow', 'root/parent', 'FK_limb_follow', 'IK_Stretch']
|
||||
|
||||
for obj in bpy.data.objects:
|
||||
if type(obj.data) != bpy.types.Armature:
|
||||
continue
|
||||
|
@ -58,10 +61,21 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
|
|||
if bone.bone.layers[30] and (list(set(bone.keys()) & set(check_props))):
|
||||
show_warning = True
|
||||
break
|
||||
for b in obj.pose.bones:
|
||||
if b.rigify_type in outdated_types.keys():
|
||||
show_update_metarig = True
|
||||
break
|
||||
|
||||
if show_warning:
|
||||
layout.label(text=WARNING, icon='ERROR')
|
||||
|
||||
layout.operator("pose.rigify_generate", text="Generate Rig")
|
||||
|
||||
if show_update_metarig:
|
||||
layout.label(text="Some bones have old legacy rigify_type. Click to upgrade", icon='ERROR')
|
||||
layout.operator("pose.rigify_upgrade_types", text="Upgrade Metarig")
|
||||
|
||||
|
||||
elif obj.mode == 'EDIT':
|
||||
# Build types list
|
||||
collection_name = str(id_store.rigify_collection).replace(" ", "")
|
||||
|
@ -615,6 +629,21 @@ class Generate(bpy.types.Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
|
||||
class UpgradeMetarigTypes(bpy.types.Operator):
|
||||
"""Upgrades metarig bones rigify_types"""
|
||||
|
||||
bl_idname = "pose.rigify_upgrade_types"
|
||||
bl_label = "Rigify Upgrade Metarig Types"
|
||||
bl_description = 'Upgrades the rigify types on the active metarig armature'
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
def execute(self, context):
|
||||
for obj in bpy.data.objects:
|
||||
if type(obj.data) == bpy.types.Armature:
|
||||
upgradeMetarigTypes(obj)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class Sample(bpy.types.Operator):
|
||||
"""Create a sample metarig to be modified before generating """ \
|
||||
"""the final rig"""
|
||||
|
@ -751,6 +780,7 @@ def register():
|
|||
bpy.utils.register_class(VIEW3D_PT_tools_rigify_dev)
|
||||
bpy.utils.register_class(LayerInit)
|
||||
bpy.utils.register_class(Generate)
|
||||
bpy.utils.register_class(UpgradeMetarigTypes)
|
||||
bpy.utils.register_class(Sample)
|
||||
bpy.utils.register_class(EncodeMetarig)
|
||||
bpy.utils.register_class(EncodeMetarigSample)
|
||||
|
@ -776,6 +806,7 @@ def unregister():
|
|||
bpy.utils.unregister_class(VIEW3D_PT_tools_rigify_dev)
|
||||
bpy.utils.unregister_class(LayerInit)
|
||||
bpy.utils.unregister_class(Generate)
|
||||
bpy.utils.unregister_class(UpgradeMetarigTypes)
|
||||
bpy.utils.unregister_class(Sample)
|
||||
bpy.utils.unregister_class(EncodeMetarig)
|
||||
bpy.utils.unregister_class(EncodeMetarigSample)
|
||||
|
|
|
@ -41,6 +41,17 @@ WGT_LAYERS = [x == 19 for x in range(0, 20)] # Widgets go on the last scene lay
|
|||
|
||||
MODULE_NAME = "rigify" # Windows/Mac blender is weird, so __package__ doesn't work
|
||||
|
||||
outdated_types = {"pitchipoy.limbs.super_limb": "limbs.super_limb",
|
||||
"pitchipoy.limbs.super_arm": "limbs.super_limb",
|
||||
"pitchipoy.limbs.super_leg": "limbs.super_limb",
|
||||
"pitchipoy.limbs.super_front_paw": "limbs.super_limb",
|
||||
"pitchipoy.limbs.super_rear_paw": "limbs.super_limb",
|
||||
"pitchipoy.super_torso_turbo": "spines.super_spine",
|
||||
"pitchipoy.simple_tentacle": "limbs.simple_tentacle",
|
||||
"pitchipoy.super_face": "faces.super_face",
|
||||
"pitchipoy.super_palm": "limbs.super_palm",
|
||||
"palm": "limbs.super_palm",
|
||||
"basic.copy": "basic.super_copy"}
|
||||
|
||||
#=======================================================================
|
||||
# Error handling
|
||||
|
@ -134,6 +145,24 @@ def insert_before_lr(name, text):
|
|||
return name + text
|
||||
|
||||
|
||||
def upgradeMetarigTypes(metarig, revert=False):
|
||||
"""Replaces rigify_type properties from old versions with their current names
|
||||
|
||||
:param revert: revert types to previous version (if old type available)
|
||||
"""
|
||||
|
||||
if revert:
|
||||
vals = list(outdated_types.values())
|
||||
rig_defs = {v: k for k, v in outdated_types.items() if vals.count(v) == 1}
|
||||
else:
|
||||
rig_defs = outdated_types
|
||||
|
||||
for bone in metarig.pose.bones:
|
||||
rg_type = bone.rigify_type
|
||||
if rg_type in rig_defs:
|
||||
bone.rigify_type = rig_defs[rg_type]
|
||||
|
||||
|
||||
#=======================
|
||||
# Bone manipulation
|
||||
#=======================
|
||||
|
|
Loading…
Reference in New Issue