From bb16aba5bd3873794eefe167497118b6063b9a85 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov <angavrilov@gmail.com> Date: Tue, 11 May 2021 20:20:18 +0300 Subject: [PATCH] Fix addons to use PoseBone.custom_shape_scale_xyz. Use new properties introduced in rBfc5bf09fd88c33. --- rigify/utils/bones.py | 2 +- rigify/utils/widgets.py | 11 ++++++++--- space_view3d_copy_attributes.py | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/rigify/utils/bones.py b/rigify/utils/bones.py index 7f178481b..83d42b23d 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 964d62570..970904c19 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): diff --git a/space_view3d_copy_attributes.py b/space_view3d_copy_attributes.py index 93dfaa389..2d1fff59d 100644 --- a/space_view3d_copy_attributes.py +++ b/space_view3d_copy_attributes.py @@ -177,7 +177,9 @@ def pVisScaExec(bone, active, context): def pDrwExec(bone, active, context): bone.custom_shape = active.custom_shape bone.use_custom_shape_bone_size = active.use_custom_shape_bone_size - bone.custom_shape_scale = active.custom_shape_scale + bone.custom_shape_translation = active.custom_shape_translation + bone.custom_shape_rotation_euler = active.custom_shape_rotation_euler + bone.custom_shape_scale_xyz = active.custom_shape_scale_xyz bone.bone.show_wire = active.bone.show_wire -- GitLab