Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/armature/armature_select.c
| Context not available. | |||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BKE_armature.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| Context not available. | |||||
| SIMEDBONE_PREFIX, | SIMEDBONE_PREFIX, | ||||
| SIMEDBONE_SUFFIX, | SIMEDBONE_SUFFIX, | ||||
| SIMEDBONE_LAYER, | SIMEDBONE_LAYER, | ||||
| SIMEDBONE_GROUP, | |||||
| SIMEDBONE_CUSTOM_SHAPE | |||||
| }; | }; | ||||
| static EnumPropertyItem prop_similar_types[] = { | static EnumPropertyItem prop_similar_types[] = { | ||||
| Context not available. | |||||
| {SIMEDBONE_PREFIX, "PREFIX", 0, "Prefix", ""}, | {SIMEDBONE_PREFIX, "PREFIX", 0, "Prefix", ""}, | ||||
| {SIMEDBONE_SUFFIX, "SUFFIX", 0, "Suffix", ""}, | {SIMEDBONE_SUFFIX, "SUFFIX", 0, "Suffix", ""}, | ||||
| {SIMEDBONE_LAYER, "LAYER", 0, "Layer", ""}, | {SIMEDBONE_LAYER, "LAYER", 0, "Layer", ""}, | ||||
| {SIMEDBONE_GROUP, "GROUP", 0, "Group", ""}, | |||||
| {SIMEDBONE_CUSTOM_SHAPE, "CUSTOM_SHAPE", 0, "Custom shape", ""}, | |||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| static void select_similar_group(bPose *pose, bArmature *arm, EditBone *ebone_act) | |||||
| { | |||||
| int agroup; | |||||
| Bone *bone_act; | |||||
| EditBone *ebone; | |||||
| bPoseChannel *pchan; | |||||
| if(!pose) | |||||
| return; | |||||
| bone_act = BKE_armature_find_bone_name(arm, ebone_act->name); | |||||
| if(!bone_act) { | |||||
| return; | |||||
| } | |||||
| agroup = 0; | |||||
| for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | |||||
| if (pchan->bone == bone_act) | |||||
| agroup = pchan->agrp_index; | |||||
| } | |||||
| for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | |||||
| if (pchan->agrp_index == agroup) { | |||||
| ebone = ED_armature_bone_find_name(arm->edbo, pchan->bone->name); | |||||
| if(EBONE_SELECTABLE(arm, ebone)) | |||||
| ED_armature_ebone_select_set(ebone, true); | |||||
| } | |||||
| } | |||||
| return; | |||||
| } | |||||
| static void select_similar_custom_shape(bPose *pose, bArmature *arm, EditBone *ebone_act) | |||||
| { | |||||
| Object *custom_shape; | |||||
| Bone *bone_act; | |||||
| EditBone *ebone; | |||||
| bPoseChannel *pchan; | |||||
| if(!pose) | |||||
| return; | |||||
| bone_act = BKE_armature_find_bone_name(arm, ebone_act->name); | |||||
| if(!bone_act) { | |||||
| return; | |||||
| } | |||||
| custom_shape = NULL; | |||||
| for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | |||||
| if (pchan->bone == bone_act) | |||||
| custom_shape = pchan->custom; | |||||
| } | |||||
| for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | |||||
| if (pchan->custom == custom_shape) { | |||||
| ebone = ED_armature_bone_find_name(arm->edbo, pchan->bone->name); | |||||
| if(EBONE_SELECTABLE(arm, ebone)) | |||||
| ED_armature_ebone_select_set(ebone, true); | |||||
| } | |||||
| } | |||||
| return; | |||||
| } | |||||
| static int armature_select_similar_exec(bContext *C, wmOperator *op) | static int armature_select_similar_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| bArmature *arm = obedit->data; | bArmature *arm = obedit->data; | ||||
| bPose *pose = obedit->pose; | |||||
| EditBone *ebone_act = CTX_data_active_bone(C); | EditBone *ebone_act = CTX_data_active_bone(C); | ||||
| /* Get props */ | /* Get props */ | ||||
| Context not available. | |||||
| case SIMEDBONE_LAYER: | case SIMEDBONE_LAYER: | ||||
| select_similar_layer(arm, ebone_act); | select_similar_layer(arm, ebone_act); | ||||
| break; | break; | ||||
| case SIMEDBONE_GROUP: | |||||
| select_similar_group(pose, arm, ebone_act); | |||||
| break; | |||||
| case SIMEDBONE_CUSTOM_SHAPE: | |||||
| select_similar_custom_shape(pose, arm, ebone_act); | |||||
| break; | |||||
| } | } | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| Context not available. | |||||