diff --git a/shape_utils.py b/shape_utils.py index cb02e05..63e2b32 100644 --- a/shape_utils.py +++ b/shape_utils.py @@ -86,6 +86,41 @@ def custom_shape_matrix(bone): return Matrix.LocRotScale(loc, rot, scale) +def apply_custom_shape_transform(bone): + shape = bone.custom_shape + + if not shape: + return + + if bpy.app.version_string < '3.0.0': + scale = bone.custom_shape_scale + + if round(scale, 5) == 0: + return + + if not bone.use_custom_shape_bone_size: + scale /= bone.bone.length + + mat = transform_matrix(scale=(1/scale,)*3) + + shape.data.transform(mat) + bone.custom_shape_scale = 1 + + else: + mat = custom_shape_matrix(bone) + + scale = (1, 1, 1) + if round(mat.to_scale().length, 5) == 0: + loc, rot, scale = mat.decompose() + mat = Matrix.LocRotScale(loc, rot, (1, 1, 1)) + scale = bone.custom_shape_scale_xyz + + shape.data.transform(mat) + + bone.custom_shape_translation = (0, 0, 0) + bone.custom_shape_rotation_euler = (0, 0, 0) + bone.custom_shape_scale_xyz = scale + def get_clean_shape(bone, shape, separate=True, rename=True, col=None, match=True, prefix='', apply_transforms=True): @@ -109,30 +144,8 @@ def get_clean_shape(bone, shape, separate=True, rename=True, bone.custom_shape = shape - - if apply_transforms: - if bpy.app.version_string < '3.0.0': - scale = bone.custom_shape_scale - - if not bone.use_custom_shape_bone_size: - scale /= bone.bone.length - - mat = transform_matrix(scale=(1/scale,)*3) - - shape.data.transform(mat) - - bone.custom_shape_scale = 1 - #mirror_bone.custom_shape_scale = - else: - - mat = custom_shape_matrix(bone) - shape.data.transform(mat) - - bone.custom_shape_translation = (0, 0, 0) - bone.custom_shape_rotation_euler = (0, 0, 0) - bone.custom_shape_scale_xyz = (1, 1, 1) - + apply_custom_shape_transform(bone) bone.use_custom_shape_bone_size = True if match: diff --git a/widgets/custom_tmp/weird.blend b/widgets/custom_tmp/weird.blend new file mode 100644 index 0000000..7f5afc1 Binary files /dev/null and b/widgets/custom_tmp/weird.blend differ diff --git a/widgets/custom_tmp/weird.png b/widgets/custom_tmp/weird.png new file mode 100644 index 0000000..ad9d672 Binary files /dev/null and b/widgets/custom_tmp/weird.png differ