diff options
author | Paolo Acampora <pkrime> | 2022-02-08 20:08:12 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2022-02-08 20:09:48 +0300 |
commit | 452a7f673190e5161c96ec8a53631a1c89d127b9 (patch) | |
tree | c164155ea9a7425097d808da2be73355417b22a7 /source/blender | |
parent | 55c90df316c7f5106b4ff97f1a6d6bcac3b195a3 (diff) |
Fix T91871: Symmetrize Armature on custom bone shape
Symmetrize Armature now also symmetrizes the transform of custom bone
shapes.
Adds a new property to `bpy.ops.armature.symmetrize`:
//Parameters//:
- **direction **(enum in ['NEGATIVE_X', 'POSITIVE_X'], (optional)) –
**Direction**, Which sides to copy from and to (when both are selected)
- **custom_shape **(enum in ['SYMMETRIZE_SAME', 'SYMMETRIZE_ALL',
'SYMMETRIZE_NONE'], (optional)) – **Custom Shapes**, Wether to
symmetrize non symmetric custom bone shapes, all custom shapes, or
none at all
//Rationale//:
Reviewed By: #animation_rigging, Mets, sybren
Maniphest Tasks: T91871
Differential Revision: https://developer.blender.org/D13416
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/armature/armature_add.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 4a327904ddd..b8a4351357d 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -859,14 +859,28 @@ static void updateDuplicateCustomBoneShapes(bContext *C, EditBone *dup_bone, Obj Main *bmain = CTX_data_main(C); char name_flip[MAX_ID_NAME - 2]; + /* Invert the X location */ + pchan->custom_translation[0] *= -1; + /* Invert the Y rotation */ + pchan->custom_rotation_euler[1] *= -1; + /* Invert the Z rotation */ + pchan->custom_rotation_euler[2] *= -1; + /* Skip the first two chars in the object name as those are used to store object type */ BLI_string_flip_side_name(name_flip, pchan->custom->id.name + 2, false, sizeof(name_flip)); Object *shape_ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name_flip); + /* If name_flip doesn't exist, BKE_libblock_find_name() returns pchan->custom (best match) */ + shape_ob = shape_ob == pchan->custom ? NULL : shape_ob; + if (shape_ob != NULL) { /* A flipped shape object exists, use it! */ pchan->custom = shape_ob; } + else { + /* Flip shape */ + pchan->custom_scale_xyz[0] *= -1; + } } } |