Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/armature/armature_utils.c
| Show First 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* ------------------------------------- */ | /* ------------------------------------- */ | ||||
| void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bool check_select) | void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bool check_select) | ||||
| { | { | ||||
| /* TODO When this function is called by property updates, cancelling the value change will not restore mirrored bone correctly. */ | |||||
| /* Currently check_select==true when this function is called from a transform operator, eg. from 3d viewport. */ | |||||
| /* no layer check, correct mirror is more important */ | /* no layer check, correct mirror is more important */ | ||||
| if (!check_select || ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) { | if (!check_select || ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) { | ||||
| EditBone *eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo); | EditBone *eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo); | ||||
| if (eboflip) { | if (eboflip) { | ||||
| /* we assume X-axis flipping for now */ | /* We assume X-axis flipping for now. */ | ||||
| if (check_select && ebo->flag & BONE_TIPSEL) { | |||||
| EditBone *children; | /* Always mirror roll, since it can be changed by moving either head or tail. */ | ||||
| eboflip->roll = -ebo->roll; | |||||
| if (!check_select || ebo->flag & BONE_TIPSEL) { | |||||
| /* Mirror tail properties. */ | |||||
| eboflip->tail[0] = -ebo->tail[0]; | eboflip->tail[0] = -ebo->tail[0]; | ||||
| eboflip->tail[1] = ebo->tail[1]; | eboflip->tail[1] = ebo->tail[1]; | ||||
| eboflip->tail[2] = ebo->tail[2]; | eboflip->tail[2] = ebo->tail[2]; | ||||
| eboflip->rad_tail = ebo->rad_tail; | eboflip->rad_tail = ebo->rad_tail; | ||||
| eboflip->roll = -ebo->roll; | |||||
| eboflip->curve_out_x = -ebo->curve_out_x; | eboflip->curve_out_x = -ebo->curve_out_x; | ||||
| eboflip->curve_out_y = ebo->curve_out_y; | |||||
| eboflip->scale_out_x = ebo->scale_out_x; | |||||
| eboflip->scale_out_y = ebo->scale_out_y; | |||||
| eboflip->ease2 = ebo->ease2; | |||||
| eboflip->roll2 = -ebo->roll2; | eboflip->roll2 = -ebo->roll2; | ||||
| /* Also move connected children, in case children's name aren't mirrored properly */ | /* Also move connected children, in case children's name aren't mirrored properly. */ | ||||
| EditBone *children; | |||||
| for (children = arm->edbo->first; children; children = children->next) { | for (children = arm->edbo->first; children; children = children->next) { | ||||
| if (children->parent == eboflip && children->flag & BONE_CONNECTED) { | if (children->parent == eboflip && children->flag & BONE_CONNECTED) { | ||||
| copy_v3_v3(children->head, eboflip->tail); | copy_v3_v3(children->head, eboflip->tail); | ||||
| children->rad_head = ebo->rad_tail; | children->rad_head = ebo->rad_tail; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (!check_select || ebo->flag & BONE_ROOTSEL) { | if (!check_select || ebo->flag & BONE_ROOTSEL) { | ||||
| /* Mirror head properties. */ | |||||
| eboflip->head[0] = -ebo->head[0]; | eboflip->head[0] = -ebo->head[0]; | ||||
| eboflip->head[1] = ebo->head[1]; | eboflip->head[1] = ebo->head[1]; | ||||
| eboflip->head[2] = ebo->head[2]; | eboflip->head[2] = ebo->head[2]; | ||||
| eboflip->rad_head = ebo->rad_head; | eboflip->rad_head = ebo->rad_head; | ||||
| eboflip->roll = -ebo->roll; | |||||
| eboflip->curve_in_x = -ebo->curve_in_x; | eboflip->curve_in_x = -ebo->curve_in_x; | ||||
| eboflip->curve_in_y = ebo->curve_in_y; | |||||
| eboflip->scale_in_x = ebo->scale_in_x; | |||||
| eboflip->scale_in_y = ebo->scale_in_y; | |||||
| eboflip->ease1 = ebo->ease1; | |||||
| eboflip->roll1 = -ebo->roll1; | eboflip->roll1 = -ebo->roll1; | ||||
| /* Also move connected parent, in case parent's name isn't mirrored properly */ | /* Also move connected parent, in case parent's name isn't mirrored properly. */ | ||||
| if (eboflip->parent && eboflip->flag & BONE_CONNECTED) { | if (eboflip->parent && eboflip->flag & BONE_CONNECTED) { | ||||
| EditBone *parent = eboflip->parent; | EditBone *parent = eboflip->parent; | ||||
| copy_v3_v3(parent->tail, eboflip->head); | copy_v3_v3(parent->tail, eboflip->head); | ||||
| parent->rad_tail = ebo->rad_head; | parent->rad_tail = ebo->rad_head; | ||||
| } | } | ||||
| } | } | ||||
| if (!check_select || ebo->flag & BONE_SELECTED) { | if (!check_select || ebo->flag & BONE_SELECTED) { | ||||
| /* Mirror bone body properties (both head and tail are selected). */ | |||||
| /* TODO: These values can also be changed from pose mode, so only mirroring them in edit mode is not ideal. */ | |||||
| eboflip->dist = ebo->dist; | eboflip->dist = ebo->dist; | ||||
brecht: Follow comment style:
https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Comments | |||||
| eboflip->roll = -ebo->roll; | eboflip->weight = ebo->weight; | ||||
| eboflip->segments = ebo->segments; | |||||
| eboflip->xwidth = ebo->xwidth; | eboflip->xwidth = ebo->xwidth; | ||||
| eboflip->zwidth = ebo->zwidth; | eboflip->zwidth = ebo->zwidth; | ||||
| eboflip->curve_in_x = -ebo->curve_in_x; | |||||
| eboflip->curve_out_x = -ebo->curve_out_x; | |||||
| eboflip->roll1 = -ebo->roll1; | |||||
| eboflip->roll2 = -ebo->roll2; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* if editbone (partial) selected, copy data */ | /* if editbone (partial) selected, copy data */ | ||||
| /* context; editmode armature, with mirror editing enabled */ | /* context; editmode armature, with mirror editing enabled */ | ||||
| void ED_armature_edit_transform_mirror_update(Object *obedit) | void ED_armature_edit_transform_mirror_update(Object *obedit) | ||||
| { | { | ||||
| bArmature *arm = obedit->data; | bArmature *arm = obedit->data; | ||||
| for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) { | for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) { | ||||
| ED_armature_ebone_transform_mirror_update(arm, ebo, true); | ED_armature_ebone_transform_mirror_update(arm, ebo, true); | ||||
Done Inline ActionsThis is redundant. brecht: This is redundant. | |||||
| } | } | ||||
| } | } | ||||
| /* *************************************************************** */ | /* *************************************************************** */ | ||||
| /* Armature EditMode Conversions */ | /* Armature EditMode Conversions */ | ||||
| /* converts Bones to EditBone list, used for tools as well */ | /* converts Bones to EditBone list, used for tools as well */ | ||||
| static EditBone *make_boneList_rec(ListBase *edbo, | static EditBone *make_boneList_rec(ListBase *edbo, | ||||
| ▲ Show 20 Lines • Show All 477 Lines • Show Last 20 Lines | |||||
Follow comment style:
https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Comments