[Bf-extensions-cvs] [985f6d8c] master: Rigify: add an operator to upgrade the old face rig to modular face.

Alexander Gavrilov noreply at git.blender.org
Sun Aug 15 19:11:57 CEST 2021


Commit: 985f6d8c304630c155133e9b368fdb7a29cac216
Author: Alexander Gavrilov
Date:   Sun Aug 15 20:09:18 2021 +0300
Branches: master
https://developer.blender.org/rBA985f6d8c304630c155133e9b368fdb7a29cac216

Rigify: add an operator to upgrade the old face rig to modular face.

Converted from the script originally included in the feature set.

This operator aims to preserve compatibility with the existing weight
painting, but not animations, since the latter is impossible anyway
due to major differences in the rig chains.

===================================================================

M	rigify/operators/__init__.py
A	rigify/operators/upgrade_face.py
M	rigify/rigs/faces/super_face.py
M	rigify/ui.py

===================================================================

diff --git a/rigify/operators/__init__.py b/rigify/operators/__init__.py
index 4263c8dd..6c96f908 100644
--- a/rigify/operators/__init__.py
+++ b/rigify/operators/__init__.py
@@ -24,6 +24,7 @@ import importlib
 # Submodules to load during register
 submodules = (
     'copy_mirror_parameters',
+    'upgrade_face',
 )
 
 loaded_submodules = []
diff --git a/rigify/operators/upgrade_face.py b/rigify/operators/upgrade_face.py
new file mode 100644
index 00000000..a6cb70c2
--- /dev/null
+++ b/rigify/operators/upgrade_face.py
@@ -0,0 +1,450 @@
+# ====================== BEGIN GPL LICENSE BLOCK ======================
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ======================= END GPL LICENSE BLOCK ========================
+
+# <pep8 compliant>
+
+import bpy
+
+from math import radians
+from functools import partial
+from mathutils import Vector
+
+from ..utils.errors import MetarigError
+from ..utils.bones import align_bone_roll
+from ..utils.rig import get_rigify_type
+
+
+def find_face_bone(obj):
+    pbone = obj.pose.bones.get('face')
+    if pbone and get_rigify_type(pbone) == 'faces.super_face':
+        return pbone.name
+
+
+def process_all(process):
+    process('face', layer='*', rig='')
+
+    process('nose', rig='skin.stretchy_chain', connect_ends='next', priority=1)
+    process('nose.001')
+    process('nose.002', parent='nose_master',
+            rig='skin.stretchy_chain', connect_ends=True, priority=1)
+    process('nose.003')
+    process('nose.004', parent='face', rig='skin.basic_chain', connect_ends='prev')
+
+    process('lip.T.L', parent='jaw_master', layer=1, rig='skin.stretchy_chain', sharpen=(0, 90),
+            falloff=(0.7, 1, 0.1), spherical=(True, False, True), scale=True)
+    process('lip.T.L.001')
+
+    process('lip.B.L', parent='jaw_master', layer=1, rig='skin.stretchy_chain', sharpen=(0, 90),
+            falloff=(0.7, 1, 0.1), spherical=(True, False, True), scale=True)
+    process('lip.B.L.001')
+
+    process('jaw', parent='jaw_master', layer=1, rig='skin.basic_chain', connect_ends='next')
+    process('chin', parent='jaw_master', rig='skin.stretchy_chain', connect_ends='prev')
+    process('chin.001')
+
+    process('ear.L', layer=0, rig='basic.super_copy', params={'super_copy_widget_type': 'sphere'})
+
+    process('ear.L.001', parent='ear.L', rig='skin.basic_chain', connect_ends=True)
+    process('ear.L.002', parent='ear.L', rig='skin.stretchy_chain', connect_ends=True)
+    process('ear.L.003')
+    process('ear.L.004', parent='ear.L', rig='skin.basic_chain', connect_ends=True)
+
+    process('ear.R', layer=0, rig='basic.super_copy', params={'super_copy_widget_type': 'sphere'})
+
+    process('ear.R.001', parent='ear.R', rig='skin.basic_chain', connect_ends=True)
+    process('ear.R.002', parent='ear.R', rig='skin.stretchy_chain', connect_ends=True)
+    process('ear.R.003')
+    process('ear.R.004', parent='ear.R', rig='skin.basic_chain', connect_ends=True)
+
+    process('lip.T.R', parent='jaw_master', layer=1, rig='skin.stretchy_chain', sharpen=(0, 90),
+            falloff=(0.7, 1, 0.1), spherical=(True, False, True), scale=True)
+    process('lip.T.R.001')
+
+    process('lip.B.R', parent='jaw_master', layer=1, rig='skin.stretchy_chain', sharpen=(0, 90),
+            falloff=(0.7, 1, 0.1), spherical=(True, False, True), scale=True)
+    process('lip.B.R.001')
+
+    process('brow.B.L', rig='skin.stretchy_chain', middle=2, connect_ends='next')
+    process('brow.B.L.001')
+    process('brow.B.L.002')
+    process('brow.B.L.003')
+
+    # ,connect_ends=True,sharpen=(120,120))
+    process('lid.T.L', parent='eye.L', sec_layer=1, rig='skin.stretchy_chain', middle=2,
+            spherical=(False, True, False))
+    process('lid.T.L.001')
+    process('lid.T.L.002')
+    process('lid.T.L.003')
+    # ,connect_ends=True,sharpen=(120,120))
+    process('lid.B.L', parent='eye.L', sec_layer=1, rig='skin.stretchy_chain', middle=2)
+    process('lid.B.L.001')
+    process('lid.B.L.002')
+    process('lid.B.L.003')
+
+    process('brow.B.R', rig='skin.stretchy_chain', middle=2, connect_ends='next')
+    process('brow.B.R.001')
+    process('brow.B.R.002')
+    process('brow.B.R.003')
+
+    # ,connect_ends=True,sharpen=(120,120))
+    process('lid.T.R', parent='eye.R', sec_layer=1, rig='skin.stretchy_chain', middle=2,
+            spherical=(False, True, False))
+    process('lid.T.R.001')
+    process('lid.T.R.002')
+    process('lid.T.R.003')
+    # ,connect_ends=True,sharpen=(120,120))
+    process('lid.B.R', parent='eye.R', sec_layer=1, rig='skin.stretchy_chain', middle=2)
+    process('lid.B.R.001')
+    process('lid.B.R.002')
+    process('lid.B.R.003')
+
+    process('forehead.L', parent='face', rig='skin.basic_chain')
+    process('forehead.L.001', parent='face', rig='skin.basic_chain')
+    process('forehead.L.002', parent='face', rig='skin.basic_chain')
+
+    process('temple.L', parent='face', rig='skin.basic_chain', connect_ends=False, priority=1)
+    process('jaw.L', parent='jaw_master', rig='skin.basic_chain', connect_ends='prev')
+    process('jaw.L.001')
+    process('chin.L')
+    process('cheek.B.L', parent='face', layer=1, rig='skin.stretchy_chain', connect_ends='next')
+    process('cheek.B.L.001')
+    process('brow.T.L', parent='face', rig='skin.basic_chain', connect_ends=True)
+    process('brow.T.L.001', parent='face', layer=1, rig='skin.stretchy_chain', connect_ends=True)
+    process('brow.T.L.002')
+    process('brow.T.L.003', parent='face', rig='skin.basic_chain', connect_ends='prev')
+
+    process('forehead.R', parent='face', rig='skin.basic_chain')
+    process('forehead.R.001', parent='face', rig='skin.basic_chain')
+    process('forehead.R.002', parent='face', rig='skin.basic_chain')
+
+    process('temple.R', parent='face', rig='skin.basic_chain', connect_ends=False, priority=1)
+    process('jaw.R', parent='jaw_master', rig='skin.basic_chain', connect_ends='prev')
+    process('jaw.R.001')
+    process('chin.R')
+    process('cheek.B.R', parent='face', layer=1, rig='skin.stretchy_chain', connect_ends='next')
+    process('cheek.B.R.001')
+    process('brow.T.R', parent='face', rig='skin.basic_chain', connect_ends=True)
+    process('brow.T.R.001', parent='face', layer=1, rig='skin.stretchy_chain', connect_ends=True)
+    process('brow.T.R.002')
+    process('brow.T.R.003', parent='face', rig='skin.basic_chain', connect_ends='prev')
+
+    process('eye.L', layer=0, rig='face.skin_eye')
+    process('eye.R', layer=0, rig='face.skin_eye')
+
+    process('cheek.T.L', rig='skin.basic_chain')
+    process('cheek.T.L.001')
+
+    process('nose.L', parent='brow.B.L.004', connect=True)
+    process('nose.L.001', parent='nose_master', rig='skin.basic_chain', layer=1)
+
+    process('cheek.T.R', rig='skin.basic_chain')
+    process('cheek.T.R.001')
+
+    process('nose.R', parent='brow.B.R.004', connect=True)
+    process('nose.R.001', parent='nose_master', rig='skin.basic_chain', layer=1)
+
+    process('teeth.T', layer=0, rig='basic.super_copy', params={'super_copy_widget_type': 'teeth'})
+    process('teeth.B', layer=0, parent='jaw_master', rig='basic.super_copy',
+            params={'super_copy_widget_type': 'teeth'})
+
+    process('tongue', pri_layer=0, parent='jaw_master', rig='face.basic_tongue')
+    process('tongue.001')
+    process('tongue.002')
+
+    # New bones
+    process('jaw_master', layer=0, parent='face', rig='face.skin_jaw',
+            params={'jaw_mouth_influence': 1.0})
+    process('nose_master', layer=0, parent='face', rig='basic.super_copy',
+            params={'super_copy_widget_type': 'diamond', 'make_deform': False})
+
+    process('brow.B.L.004', parent='face', rig='skin.stretchy_chain',
+            connect_ends='prev', falloff=(-10, 1, 0))
+    process('brow.B.R.004', parent='face', rig='skin.stretchy_chain',
+            connect_ends='prev', falloff=(-10, 1, 0))
+
+    process('brow_glue.B.L.002', parent='face', rig='skin.glue', glue_copy=0.25, glue_reparent=True)
+    process('brow_glue.B.R.002', parent='face', rig='skin.glue', glue_copy=0.25, glue_reparent=True)
+
+    process('lid_glue.B.L.002', parent='face', rig='skin.glue', glue_copy=0.1)
+    process('lid_glue.B.R.002', parent='face', rig='skin.glue', glue_copy=0.1)
+
+    process('cheek_glue.T.L.001', parent='face',
+            rig='skin.glue', glue_copy=0.5, glue_reparent=True)
+    process('cheek_glue.T.R.001', parent='face',
+            rig='skin.glue', glue_copy=0.5, glue_reparent=True)
+
+    process('nose_glue.L.001', parent='face', rig='skin.glue', glue_copy=0.2, glue_reparent=True)
+    process('nose_glue.R.001', parent='face', rig='skin.glue', glue_copy=0.2, glue_reparent=True)
+
+    process('nose_glue.004', parent='face', rig='skin.glue', glue_copy=0.2, glue_reparent=True)
+    process('nose_end_glue.004', parent='face', rig='skin.glue', glue_copy=0.5, glue_reparent=True)
+    process('chin_end_glue.001', parent='jaw_master', rig='skin.glue', glue_copy=0.5, glue_reparent=True)
+
+
+def make_new_bones(obj, name_map):
+    eb = obj.data.edit_bones
+    face_bone = name_map['face']
+
+    bone = eb.new(name='jaw_master')
+    bone.head = (eb['jaw.R'].head + eb['jaw.L'].head) / 2
+    bone.tail = eb['jaw'].tail
+    bone.roll = 0
+    name_map['jaw_master'] = bone.name
+
+    bone = eb.new(name='nose_master')
+    bone.head = (eb['nose.L.001'].head + eb['nose.R.001'].head) / 2
+    nose_width = (eb['nose.L.001'].head - eb['nose.R.001'].head).length
+    nose_length = (eb['nose.001'].tail - bone.head).

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list