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:
authorLucio Rossi <lucio.rossi75@gmail.com>2017-05-14 19:30:06 +0300
committerLucio Rossi <lucio.rossi75@gmail.com>2017-05-14 19:30:06 +0300
commitf36789d8bc728bc7ec3c9738f1ca76e8f017ce7a (patch)
treeb21bf3b259ee87b4eafb1503936b15bee38be1ca /rigify/generate.py
parent8e68bf2879d81780e51dbdc3481bb486e7430e74 (diff)
Rigify 0.5 with legacy mode
Diffstat (limited to 'rigify/generate.py')
-rw-r--r--rigify/generate.py80
1 files changed, 39 insertions, 41 deletions
diff --git a/rigify/generate.py b/rigify/generate.py
index e519c13b..3fe4e3b8 100644
--- a/rigify/generate.py
+++ b/rigify/generate.py
@@ -32,7 +32,6 @@ from .utils import create_root_widget
from .utils import random_id
from .utils import copy_attributes
from .rig_ui_template import UI_SLIDERS, layers_ui, UI_REGISTER
-from .rig_ui_pitchipoy_template import UI_P_SLIDERS, layers_P_ui, UI_P_REGISTER
RIG_MODULE = "rigs"
@@ -258,11 +257,24 @@ def generate_rig(context, metarig):
obj.data.edit_bones[root_bone].roll = 0
bpy.ops.object.mode_set(mode='OBJECT')
obj.data.bones[root_bone].layers = ROOT_LAYER
+
# Put the rig_name in the armature custom properties
rna_idprop_ui_prop_get(obj.data, "rig_id", create=True)
obj.data["rig_id"] = rig_id
t.tick("Create root bone: ")
+
+ # Create Group widget
+ wgts_group_name = "WGTS"
+ if wgts_group_name not in scene.objects:
+ if wgts_group_name in bpy.data.objects:
+ bpy.data.objects[wgts_group_name].user_clear()
+ bpy.data.objects.remove(bpy.data.objects[wgts_group_name])
+ mesh = bpy.data.meshes.new(wgts_group_name)
+ wgts_obj = bpy.data.objects.new(wgts_group_name, mesh)
+ scene.objects.link(wgts_obj)
+ t.tick("Create main WGTS: ")
+
#----------------------------------
try:
# Collect/initialize all the rigs.
@@ -302,10 +314,23 @@ def generate_rig(context, metarig):
# Parent any free-floating bones to the root excluding bones with child of constraint.
pbones = obj.pose.bones
+
+
+ ik_follow_drivers = []
+
+ if obj.animation_data:
+ for drv in obj.animation_data.drivers:
+ for var in drv.driver.variables:
+ if 'IK_follow' == var.name:
+ ik_follow_drivers.append(drv.data_path)
+
noparent_bones = []
for bone in bones:
- if 'IK_follow' in pbones[bone].keys():
- noparent_bones += [bone]
+ # if 'IK_follow' in pbones[bone].keys():
+ # noparent_bones += [bone]
+ for d in ik_follow_drivers:
+ if bone in d:
+ noparent_bones += [bone]
bpy.ops.object.mode_set(mode='EDIT')
for bone in bones:
@@ -396,35 +421,18 @@ def generate_rig(context, metarig):
print( l.name )
layer_layout += [(l.name, l.row)]
-
- if isPitchipoy(metarig):
-
- # Generate the UI Pitchipoy script
- if "rig_ui.py" in bpy.data.texts:
- script = bpy.data.texts["rig_ui.py"]
- script.clear()
- else:
- script = bpy.data.texts.new("rig_ui.py")
- script.write(UI_P_SLIDERS % rig_id)
- for s in ui_scripts:
- script.write("\n " + s.replace("\n", "\n ") + "\n")
- script.write(layers_P_ui(vis_layers, layer_layout))
- script.write(UI_P_REGISTER)
- script.use_module = True
-
+ # Generate the UI script
+ if "rig_ui.py" in bpy.data.texts:
+ script = bpy.data.texts["rig_ui.py"]
+ script.clear()
else:
- # Generate the UI script
- if "rig_ui.py" in bpy.data.texts:
- script = bpy.data.texts["rig_ui.py"]
- script.clear()
- else:
- script = bpy.data.texts.new("rig_ui.py")
- script.write(UI_SLIDERS % rig_id)
- for s in ui_scripts:
- script.write("\n " + s.replace("\n", "\n ") + "\n")
- script.write(layers_ui(vis_layers, layer_layout))
- script.write(UI_REGISTER)
- script.use_module = True
+ script = bpy.data.texts.new("rig_ui.py")
+ script.write(UI_SLIDERS % rig_id)
+ for s in ui_scripts:
+ script.write("\n " + s.replace("\n", "\n ") + "\n")
+ script.write(layers_ui(vis_layers, layer_layout))
+ script.write(UI_REGISTER)
+ script.use_module = True
# Run UI script
exec(script.as_string(), {})
@@ -479,13 +487,3 @@ def param_name(param_name, rig_type):
""" Get the actual parameter name, sans-rig-type.
"""
return param_name[len(rig_type) + 1:]
-
-def isPitchipoy(metarig):
- """ Returns True if metarig is type pitchipoy.
- """
- pbones=metarig.pose.bones
- for pb in pbones:
- words = pb.rigify_type.partition('.')
- if words[0] == 'pitchipoy':
- return True
- return False \ No newline at end of file