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-10-01 09:59:51 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-10-01 14:29:30 +0300
commit50c493fb22869e0e08936c4b7a44624887b1de58 (patch)
tree59c571688b6e09f9d41cf6053924f7a3dfdb377d /rigify/utils/widgets.py
parente57714f3a2805b5ca71d68f967961950e707e191 (diff)
Rigify: add more parent switching and 2.81 inherit scale features.
- Add a parent switch to the main spine control, to allow using the key baking operator to convert between moving and fixed root bone. - Add hips, chest and head as parents for children of the spine. - Use 'Fix Shear' Inherit Scale and 'Make Uniform' Copy Scale in limbs. - Switch code to use the new inherit_scale parameter of set_bone_parent. - Allow local matrices in adjust_widget_transform_mesh.
Diffstat (limited to 'rigify/utils/widgets.py')
-rw-r--r--rigify/utils/widgets.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/rigify/utils/widgets.py b/rigify/utils/widgets.py
index f7e796b6..f4713372 100644
--- a/rigify/utils/widgets.py
+++ b/rigify/utils/widgets.py
@@ -50,16 +50,8 @@ def obj_to_bone(obj, rig, bone_name, bone_transform_name=None):
elif bone.custom_shape_transform:
bone = bone.custom_shape_transform
- mat = rig.matrix_world @ bone.bone.matrix_local
-
- obj.location = mat.to_translation()
-
obj.rotation_mode = 'XYZ'
- obj.rotation_euler = mat.to_euler()
-
- scl = mat.to_scale()
- scl_avg = (scl[0] + scl[1] + scl[2]) / 3
- obj.scale = (scale * scl_avg), (scale * scl_avg), (scale * scl_avg)
+ obj.matrix_basis = rig.matrix_world @ bone.bone.matrix_local @ Matrix.Scale(scale, 4)
def create_widget(rig, bone_name, bone_transform_name=None):
@@ -159,11 +151,22 @@ def adjust_widget_axis(obj, axis='y', offset=0.0):
vert.co = matrix @ vert.co
-def adjust_widget_transform(obj, matrix):
- """Adjust the generated widget by applying a world space correction matrix to the mesh."""
+def adjust_widget_transform_mesh(obj, matrix, local=None):
+ """Adjust the generated widget by applying a correction matrix to the mesh.
+ If local is false, the matrix is in world space.
+ If local is True, it's in the local space of the widget.
+ If local is a bone, it's in the local space of the bone.
+ """
if obj:
- obmat = obj.matrix_basis
- matrix = obmat.inverted() @ matrix @ obmat
+ if local is not True:
+ if local:
+ assert isinstance(local, bpy.types.PoseBone)
+ bonemat = local.id_data.matrix_world @ local.bone.matrix_local
+ matrix = bonemat @ matrix @ bonemat.inverted()
+
+ obmat = obj.matrix_basis
+ matrix = obmat.inverted() @ matrix @ obmat
+
obj.data.transform(matrix)