[Bf-extensions-cvs] [bb16aba5] master: Fix addons to use PoseBone.custom_shape_scale_xyz.

Alexander Gavrilov noreply at git.blender.org
Tue May 11 19:20:39 CEST 2021


Commit: bb16aba5bd3873794eefe167497118b6063b9a85
Author: Alexander Gavrilov
Date:   Tue May 11 20:20:18 2021 +0300
Branches: master
https://developer.blender.org/rBAbb16aba5bd3873794eefe167497118b6063b9a85

Fix addons to use PoseBone.custom_shape_scale_xyz.

Use new properties introduced in rBfc5bf09fd88c33.

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

M	rigify/utils/bones.py
M	rigify/utils/widgets.py
M	space_view3d_copy_attributes.py

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

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):
diff --git a/space_view3d_copy_attributes.py b/space_view3d_copy_attributes.py
index 93dfaa38..2d1fff59 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



More information about the Bf-extensions-cvs mailing list