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
path: root/rigify
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-10-21 17:44:21 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-10-23 13:18:42 +0300
commitd12c4a40175c2a8a3d409ec1c115dd27b932ff7d (patch)
tree9c553717c3e638e4cf04a4b41f1e404d66fd0c6f /rigify
parent69ada355ca003733ac0e69ec1e884f3e2199e97f (diff)
Rigify: copy rigs can now rename the bone to DEF instead of copying.
This is necessary to fully preserve complex custom rigging (especially with B-Bones) included directly in the metarig. Doing this otherwise would require implementing correct copying of all possible constraints and bone settings.
Diffstat (limited to 'rigify')
-rw-r--r--rigify/rigs/basic/copy_chain.py33
-rw-r--r--rigify/rigs/basic/super_copy.py27
2 files changed, 57 insertions, 3 deletions
diff --git a/rigify/rigs/basic/copy_chain.py b/rigify/rigs/basic/copy_chain.py
index 5145d735..a3920ced 100644
--- a/rigify/rigs/basic/copy_chain.py
+++ b/rigify/rigs/basic/copy_chain.py
@@ -22,9 +22,10 @@ import bpy
from ..chain_rigs import SimpleChainRig
+from ...utils.layers import DEF_LAYER
from ...utils.errors import MetarigError
from ...utils.rig import connected_children_names
-from ...utils.naming import strip_org, make_deformer_name
+from ...utils.naming import make_derived_name
from ...utils.widgets_basic import create_bone_widget
from ...base_rig import BaseRig, stage
@@ -41,7 +42,12 @@ class Rig(SimpleChainRig):
""" Gather and validate data about the rig.
"""
self.make_controls = self.params.make_controls
- self.make_deforms = self.params.make_deforms
+
+ deform = self.params.make_deforms
+ rename = self.params.rename_to_deform
+
+ self.make_deforms = deform and not rename
+ self.rename_deforms = deform and rename
##############################
# Control chain
@@ -92,6 +98,20 @@ class Rig(SimpleChainRig):
if self.make_deforms:
super().rig_deform_chain()
+ ##############################
+ # Rename To Deform
+
+ def finalize(self):
+ if self.rename_deform:
+ new_names = [ self.rename_bone(name, make_derived_name(name, 'def')) for name in self.bones.org ]
+
+ for name in new_names:
+ bone = self.get_bone(name).bone
+ bone.use_deform = True
+ bone.layers = DEF_LAYER
+
+ ##############################
+ # Parameter UI
@classmethod
def add_parameters(self, params):
@@ -101,6 +121,11 @@ class Rig(SimpleChainRig):
params.make_controls = bpy.props.BoolProperty(name="Controls", default=True, description="Create control bones for the copy")
params.make_deforms = bpy.props.BoolProperty(name="Deform", default=True, description="Create deform bones for the copy")
+ params.rename_to_deform = bpy.props.BoolProperty(
+ name = "Rename To Deform",
+ default = False,
+ description = "Rename the original bone itself to use as deform bone (advanced feature)"
+ )
@classmethod
def parameters_ui(self, layout, params):
@@ -111,6 +136,10 @@ class Rig(SimpleChainRig):
r = layout.row()
r.prop(params, "make_deforms")
+ if params.make_deforms:
+ r = layout.row()
+ r.prop(params, "rename_to_deform")
+
def create_sample(obj):
""" Create a sample metarig for this rig type.
diff --git a/rigify/rigs/basic/super_copy.py b/rigify/rigs/basic/super_copy.py
index 5abbf22e..5fc589c4 100644
--- a/rigify/rigs/basic/super_copy.py
+++ b/rigify/rigs/basic/super_copy.py
@@ -22,6 +22,7 @@ import bpy
from ...base_rig import BaseRig
+from ...utils.layers import DEF_LAYER
from ...utils.naming import strip_org, make_deformer_name
from ...utils.widgets_basic import create_bone_widget, create_circle_widget
@@ -43,7 +44,12 @@ class Rig(BaseRig):
self.make_control = self.params.make_control
self.make_widget = self.params.make_widget
- self.make_deform = self.params.make_deform
+
+ deform = self.params.make_deform
+ rename = self.params.rename_to_deform
+
+ self.make_deform = deform and not rename
+ self.rename_deform = deform and rename
def generate_bones(self):
@@ -91,6 +97,15 @@ class Rig(BaseRig):
create_bone_widget(self.obj, bones.ctrl)
+ def finalize(self):
+ if self.rename_deform:
+ new_name = self.rename_bone(self.bones.org, make_deformer_name(self.org_name))
+
+ bone = self.get_bone(new_name).bone
+ bone.use_deform = True
+ bone.layers = DEF_LAYER
+
+
@classmethod
def add_parameters(self, params):
""" Add the parameters of this rig type to the
@@ -114,6 +129,12 @@ class Rig(BaseRig):
description = "Create a deform bone for the copy"
)
+ params.rename_to_deform = bpy.props.BoolProperty(
+ name = "Rename To Deform",
+ default = False,
+ description = "Rename the original bone itself to use as deform bone (advanced feature)"
+ )
+
@classmethod
def parameters_ui(self, layout, params):
@@ -127,6 +148,10 @@ class Rig(BaseRig):
r = layout.row()
r.prop(params, "make_deform")
+ if params.make_deform:
+ r = layout.row()
+ r.prop(params, "rename_to_deform")
+
def create_sample(obj):
""" Create a sample metarig for this rig type.