Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-02-16 13:57:57 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-03-14 14:39:16 +0300
commit36e8d00aec705b06008a0bc334fe266448b4f2c2 (patch)
tree02bf0290ec6423c611e3cd4ad49c69cb77acb67e /rigify/ui.py
parenteabb5cddf79e5fae3ca429242cf2c6f5a272920e (diff)
Rigify: add support for user-defined rig packages and related utilities.
As suggested by @icappielo, and after discussion with @meta-androcto, I start a public request to commit third-party contributions already accepted to https://github.com/eigen-value/rigify/tree/rigify_0.6_beta Specifically, this includes: * User-defined rig package (feature set) support by @pioverfour. This allows users to install pre-packaged rig sets via zip files, which become accessible together with built-in rigs, as discussed in T52758. https://github.com/eigen-value/rigify/pull/1 * Modularization of python script generation, allowing rigs to add their own utility functions and operators to the generated script. This is critical to make custom rig support really useful. https://github.com/eigen-value/rigify/pull/5 * The utils.py file is split into multiple modules with a backward compatibility proxy for old functions. * Automatic verification that different rigs don't try to create different rig settings with the same name to alleviate increased risk of namespace conflicts with custom rigs. https://github.com/eigen-value/rigify/pull/7 * New utility class that implements bone layer selection UI. https://github.com/eigen-value/rigify/pull/6 * New utilities to replace copy & pasted boilerplate code for creating custom properties, constraints and drivers. https://github.com/eigen-value/rigify/pull/11 Some other random changes by MAD have likely slipped through. These changes have already been extensively discussed and accepted into the branch by @luciorossi, so I see no reason not to commit them to the official repository to be tested during 2.8 beta. Reviewers: icappiello Differential Revision: https://developer.blender.org/D4364
Diffstat (limited to 'rigify/ui.py')
-rw-r--r--rigify/ui.py100
1 files changed, 49 insertions, 51 deletions
diff --git a/rigify/ui.py b/rigify/ui.py
index 3d2a1efa..c3c9f07d 100644
--- a/rigify/ui.py
+++ b/rigify/ui.py
@@ -28,7 +28,7 @@ from bpy.props import (
from mathutils import Color
-from .utils import get_rig_type, MetarigError
+from .utils import MetarigError
from .utils import write_metarig, write_widget
from .utils import unique_name
from .utils import upgradeMetarigTypes, outdated_types
@@ -38,6 +38,18 @@ from .rigs.utils import get_limb_generated_names
from . import rig_lists
from . import generate
from . import rot_mode
+from . import feature_sets
+
+
+def build_type_list(context, rigify_types):
+ rigify_types.clear()
+
+ for r in sorted(rig_lists.rigs):
+ if (context.object.data.active_feature_set in ('all', rig_lists.rigs[r]['feature_set'])
+ or len(feature_sets.feature_set_items(context.scene, context)) == 2
+ ):
+ a = rigify_types.add()
+ a.name = r
class DATA_PT_rigify_buttons(bpy.types.Panel):
@@ -65,21 +77,18 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
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
- for bone in obj.pose.bones:
- if bone.bone.layers[30] and (list(set(bone.keys()) & set(check_props))):
- show_warning = True
+ for bone in obj.pose.bones:
+ 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():
+ if outdated_types[b.rigify_type]:
+ show_update_metarig = True
+ else:
+ show_update_metarig = False
+ show_not_updatable = True
break
- for b in obj.pose.bones:
- if b.rigify_type in outdated_types.keys():
- if outdated_types[b.rigify_type]:
- show_update_metarig = True
- else:
- show_update_metarig = False
- show_not_updatable = True
- break
if show_warning:
layout.label(text=WARNING, icon='ERROR')
@@ -99,7 +108,15 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
layout.operator("pose.rigify_upgrade_types", text="Upgrade Metarig")
row = layout.row()
+ # Rig type field
+
+ col = layout.column(align=True)
+ col.active = (not 'rig_id' in C.object.data)
+
+ col.separator()
+ row = col.row()
row.operator("pose.rigify_generate", text="Generate Rig", icon='POSE_HLT')
+
row.enabled = enable_generate_and_advanced
if id_store.rigify_advanced_generation:
@@ -162,24 +179,15 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
elif obj.mode == 'EDIT':
# Build types list
- collection_name = str(id_store.rigify_collection).replace(" ", "")
-
- for i in range(0, len(id_store.rigify_types)):
- id_store.rigify_types.remove(0)
-
- for r in rig_lists.rig_list:
+ build_type_list(context, id_store.rigify_types)
- if collection_name == "All":
- a = id_store.rigify_types.add()
- a.name = r
- elif r.startswith(collection_name + '.'):
- a = id_store.rigify_types.add()
- a.name = r
- elif (collection_name == "None") and ("." not in r):
- a = id_store.rigify_types.add()
- a.name = r
+ if id_store.rigify_active_type > len(id_store.rigify_types):
+ id_store.rigify_active_type = 0
# Rig type list
+ if len(feature_sets.feature_set_items(context.scene, context)) > 2:
+ row = layout.row()
+ row.prop(context.object.data, "active_feature_set")
row = layout.row()
row.template_list("UI_UL_list", "rigify_types", id_store, "rigify_types", id_store, 'rigify_active_type')
@@ -582,38 +590,24 @@ class BONE_PT_rigify_buttons(bpy.types.Panel):
C = context
id_store = C.window_manager
bone = context.active_pose_bone
- collection_name = str(id_store.rigify_collection).replace(" ", "")
rig_name = str(context.active_pose_bone.rigify_type).replace(" ", "")
layout = self.layout
# Build types list
- for i in range(0, len(id_store.rigify_types)):
- id_store.rigify_types.remove(0)
-
- for r in rig_lists.rig_list:
- if r in rig_lists.implementation_rigs:
- continue
- # collection = r.split('.')[0] # UNUSED
- if collection_name == "All":
- a = id_store.rigify_types.add()
- a.name = r
- elif r.startswith(collection_name + '.'):
- a = id_store.rigify_types.add()
- a.name = r
- elif collection_name == "None" and len(r.split('.')) == 1:
- a = id_store.rigify_types.add()
- a.name = r
+ build_type_list(context, id_store.rigify_types)
# Rig type field
+ if len(feature_sets.feature_set_items(context.scene, context)) > 2:
+ row = layout.row()
+ row.prop(context.object.data, "active_feature_set")
row = layout.row()
- row.prop_search(bone, "rigify_type", id_store, "rigify_types", text="Rig type:")
+ row.prop_search(bone, "rigify_type", id_store, "rigify_types", text="Rig type")
# Rig type parameters / Rig type non-exist alert
if rig_name != "":
try:
- rig = get_rig_type(rig_name)
- rig.Rig
+ rig = rig_lists.rigs[rig_name]['module']
except (ImportError, AttributeError):
row = layout.row()
box = row.box()
@@ -641,6 +635,10 @@ class VIEW3D_PT_tools_rigify_dev(bpy.types.Panel):
def poll(cls, context):
return context.mode in ['EDIT_ARMATURE', 'EDIT_MESH']
+ @classmethod
+ def poll(cls, context):
+ return context.mode in ['EDIT_ARMATURE', 'EDIT_MESH']
+
def draw(self, context):
obj = context.active_object
if obj is not None:
@@ -818,7 +816,7 @@ class Sample(bpy.types.Operator):
use_global_undo = context.preferences.edit.use_global_undo
context.preferences.edit.use_global_undo = False
try:
- rig = get_rig_type(self.metarig_type)
+ rig = rig_lists.rigs[self.metarig_type]["module"]
create_sample = rig.create_sample
except (ImportError, AttributeError):
raise Exception("rig type '" + self.metarig_type + "' has no sample.")