Fix apply scale 0
parent
7aae48687b
commit
db5238c89e
|
@ -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:
|
||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue