Fix apply scale 0
This commit is contained in:
		
							parent
							
								
									7aae48687b
								
							
						
					
					
						commit
						db5238c89e
					
				| @ -86,6 +86,41 @@ def custom_shape_matrix(bone): | |||||||
| 
 | 
 | ||||||
|     return Matrix.LocRotScale(loc, rot, scale) |     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,  | def get_clean_shape(bone, shape, separate=True, rename=True,  | ||||||
|         col=None, match=True, prefix='', apply_transforms=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 |     bone.custom_shape = shape | ||||||
|      |      | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     if apply_transforms: |     if apply_transforms: | ||||||
|         if bpy.app.version_string < '3.0.0': |         apply_custom_shape_transform(bone) | ||||||
|             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) |  | ||||||
|          |  | ||||||
|         bone.use_custom_shape_bone_size = True |         bone.use_custom_shape_bone_size = True | ||||||
| 
 | 
 | ||||||
|     if match: |     if match: | ||||||
|  | |||||||
							
								
								
									
										
											BIN
										
									
								
								widgets/custom_tmp/weird.blend
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								widgets/custom_tmp/weird.blend
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								widgets/custom_tmp/weird.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								widgets/custom_tmp/weird.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.1 KiB | 
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user