diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2021-05-11 20:20:18 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2021-05-11 20:20:18 +0300 |
commit | bb16aba5bd3873794eefe167497118b6063b9a85 (patch) | |
tree | 386f8368a20452dcbf25b5152bf8b16a618c967f /rigify | |
parent | 7324beddde4695ce952188f9cdb6e21a9631eeed (diff) |
Fix addons to use PoseBone.custom_shape_scale_xyz.
Use new properties introduced in rBfc5bf09fd88c33.
Diffstat (limited to 'rigify')
-rw-r--r-- | rigify/utils/bones.py | 2 | ||||
-rw-r--r-- | rigify/utils/widgets.py | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/rigify/utils/bones.py b/rigify/utils/bones.py index 7f178481..83d42b23 100644 --- a/rigify/utils/bones.py +++ b/rigify/utils/bones.py @@ -682,4 +682,4 @@ def set_bone_widget_transform(obj, bone_name, transform_bone, use_size=True, sca bone.custom_shape_transform = None bone.use_custom_shape_bone_size = use_size - bone.custom_shape_scale = scale + bone.custom_shape_scale_xyz = (scale, scale, scale) diff --git a/rigify/utils/widgets.py b/rigify/utils/widgets.py index 964d6257..970904c1 100644 --- a/rigify/utils/widgets.py +++ b/rigify/utils/widgets.py @@ -23,7 +23,7 @@ import math import inspect import functools -from mathutils import Matrix +from mathutils import Matrix, Vector, Euler from .errors import MetarigError from .collections import ensure_widget_collection @@ -42,7 +42,10 @@ def obj_to_bone(obj, rig, bone_name, bone_transform_name=None): raise MetarigError("obj_to_bone(): does not work while in edit mode") bone = rig.pose.bones[bone_name] - scale = bone.custom_shape_scale + + loc = bone.custom_shape_translation + rot = bone.custom_shape_rotation_euler + scale = Vector(bone.custom_shape_scale_xyz) if bone.use_custom_shape_bone_size: scale *= bone.length @@ -52,8 +55,10 @@ def obj_to_bone(obj, rig, bone_name, bone_transform_name=None): elif bone.custom_shape_transform: bone = bone.custom_shape_transform + shape_mat = Matrix.Translation(loc) @ (Euler(rot).to_matrix() @ Matrix.Diagonal(scale)).to_4x4() + obj.rotation_mode = 'XYZ' - obj.matrix_basis = rig.matrix_world @ bone.bone.matrix_local @ Matrix.Scale(scale, 4) + obj.matrix_basis = rig.matrix_world @ bone.bone.matrix_local @ shape_mat def create_widget(rig, bone_name, bone_transform_name=None, *, widget_name=None, widget_force_new=False): |