Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/armature/armature_select.c
| Show First 20 Lines • Show All 357 Lines • ▼ Show 20 Lines | while (bone) { | ||||
| } | } | ||||
| } | } | ||||
| ED_outliner_select_sync_from_edit_bone_tag(C); | ED_outliner_select_sync_from_edit_bone_tag(C); | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static bool armature_select_linked_poll(bContext *C) | static bool armature_select_linked_poll(bContext *C) | ||||
| { | { | ||||
| return (ED_operator_view3d_active(C) && ED_operator_editarmature(C)); | return (ED_operator_view3d_active(C) && ED_operator_editarmature(C)); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 413 Lines • ▼ Show 20 Lines | if (ebone_select_flag(nearBone)) { | ||||
| arm->act_edbone = nearBone; | arm->act_edbone = nearBone; | ||||
| } | } | ||||
| if (vc.view_layer->basact != basact) { | if (vc.view_layer->basact != basact) { | ||||
| ED_object_base_activate(C, basact); | ED_object_base_activate(C, basact); | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object); | ||||
| DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE); | |||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Select Op From Tagged | /** \name Select Op From Tagged | ||||
| ▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones) { | ||||
| } | } | ||||
| } | } | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| ED_outliner_select_sync_from_edit_bone_tag(C); | ED_outliner_select_sync_from_edit_bone_tag(C); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); | ||||
| /* Tagging only one object to refresh drawing. */ | |||||
| Object *obedit = CTX_data_edit_object(C); | |||||
| DEG_id_tag_update(&obedit->id, ID_RECALC_SELECT); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_select_all(wmOperatorType *ot) | void ARMATURE_OT_select_all(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "(De)select All"; | ot->name = "(De)select All"; | ||||
| ot->idname = "ARMATURE_OT_select_all"; | ot->idname = "ARMATURE_OT_select_all"; | ||||
| ▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | static int armature_de_select_more_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| uint objects_len = 0; | uint objects_len = 0; | ||||
| Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( | Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( | ||||
| view_layer, CTX_wm_view3d(C), &objects_len); | view_layer, CTX_wm_view3d(C), &objects_len); | ||||
| for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | ||||
| Object *ob = objects[ob_index]; | Object *ob = objects[ob_index]; | ||||
| armature_select_more_less(ob, true); | armature_select_more_less(ob, true); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| ED_outliner_select_sync_from_edit_bone_tag(C); | ED_outliner_select_sync_from_edit_bone_tag(C); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_select_more(wmOperatorType *ot) | void ARMATURE_OT_select_more(wmOperatorType *ot) | ||||
| Show All 16 Lines | static int armature_de_select_less_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| uint objects_len = 0; | uint objects_len = 0; | ||||
| Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( | Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( | ||||
| view_layer, CTX_wm_view3d(C), &objects_len); | view_layer, CTX_wm_view3d(C), &objects_len); | ||||
| for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | for (uint ob_index = 0; ob_index < objects_len; ob_index++) { | ||||
| Object *ob = objects[ob_index]; | Object *ob = objects[ob_index]; | ||||
| armature_select_more_less(ob, false); | armature_select_more_less(ob, false); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| ED_outliner_select_sync_from_edit_bone_tag(C); | ED_outliner_select_sync_from_edit_bone_tag(C); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_select_less(wmOperatorType *ot) | void ARMATURE_OT_select_less(wmOperatorType *ot) | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { | ||||
| ED_armature_ebone_select_set(ebone, true); | ED_armature_ebone_select_set(ebone, true); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| } | } | ||||
| static void bone_direction_worldspace_get(Object *ob, EditBone *ebone, float *r_dir) | static void bone_direction_worldspace_get(Object *ob, EditBone *ebone, float *r_dir) | ||||
| { | { | ||||
| float v1[3], v2[3]; | float v1[3], v2[3]; | ||||
| Show All 33 Lines | for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { | ||||
| ED_armature_ebone_select_set(ebone, true); | ED_armature_ebone_select_set(ebone, true); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| } | } | ||||
| static void select_similar_layer(bContext *C) | static void select_similar_layer(bContext *C) | ||||
| { | { | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Show All 13 Lines | for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { | ||||
| ED_armature_ebone_select_set(ebone, true); | ED_armature_ebone_select_set(ebone, true); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| } | } | ||||
| static void select_similar_prefix(bContext *C) | static void select_similar_prefix(bContext *C) | ||||
| { | { | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Show All 25 Lines | for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { | ||||
| ED_armature_ebone_select_set(ebone, true); | ED_armature_ebone_select_set(ebone, true); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| } | } | ||||
| static void select_similar_suffix(bContext *C) | static void select_similar_suffix(bContext *C) | ||||
| { | { | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Show All 25 Lines | for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { | ||||
| ED_armature_ebone_select_set(ebone, true); | ED_armature_ebone_select_set(ebone, true); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| } | } | ||||
| /** Use for matching any pose channel data. */ | /** Use for matching any pose channel data. */ | ||||
| static void select_similar_data_pchan(bContext *C, const size_t bytes_size, const int offset) | static void select_similar_data_pchan(bContext *C, const size_t bytes_size, const int offset) | ||||
| { | { | ||||
| Show All 11 Lines | if (EBONE_SELECTABLE(arm, ebone)) { | ||||
| if (memcmp(data_active, data_test, bytes_size) == 0) { | if (memcmp(data_active, data_test, bytes_size) == 0) { | ||||
| ED_armature_ebone_select_set(ebone, true); | ED_armature_ebone_select_set(ebone, true); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| DEG_id_tag_update(&obedit->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| static void is_ancestor(EditBone *bone, EditBone *ancestor) | static void is_ancestor(EditBone *bone, EditBone *ancestor) | ||||
| { | { | ||||
| if (bone->temp.ebone == ancestor || bone->temp.ebone == NULL) { | if (bone->temp.ebone == ancestor || bone->temp.ebone == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| Show All 18 Lines | for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { | ||||
| is_ancestor(ebone_iter, ebone_act); | is_ancestor(ebone_iter, ebone_act); | ||||
| if (ebone_iter->temp.ebone == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) { | if (ebone_iter->temp.ebone == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) { | ||||
| ED_armature_ebone_select_set(ebone_iter, true); | ED_armature_ebone_select_set(ebone_iter, true); | ||||
| } | } | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| DEG_id_tag_update(&obedit->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| static void select_similar_children_immediate(bContext *C) | static void select_similar_children_immediate(bContext *C) | ||||
| { | { | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| bArmature *arm = obedit->data; | bArmature *arm = obedit->data; | ||||
| EditBone *ebone_act = CTX_data_active_bone(C); | EditBone *ebone_act = CTX_data_active_bone(C); | ||||
| for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { | for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { | ||||
| if (ebone_iter->parent == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) { | if (ebone_iter->parent == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) { | ||||
| ED_armature_ebone_select_set(ebone_iter, true); | ED_armature_ebone_select_set(ebone_iter, true); | ||||
| } | } | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| DEG_id_tag_update(&obedit->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| static void select_similar_siblings(bContext *C) | static void select_similar_siblings(bContext *C) | ||||
| { | { | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| bArmature *arm = obedit->data; | bArmature *arm = obedit->data; | ||||
| EditBone *ebone_act = CTX_data_active_bone(C); | EditBone *ebone_act = CTX_data_active_bone(C); | ||||
| if (ebone_act->parent == NULL) { | if (ebone_act->parent == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { | for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { | ||||
| if (ebone_iter->parent == ebone_act->parent && EBONE_SELECTABLE(arm, ebone_iter)) { | if (ebone_iter->parent == ebone_act->parent && EBONE_SELECTABLE(arm, ebone_iter)) { | ||||
| ED_armature_ebone_select_set(ebone_iter, true); | ED_armature_ebone_select_set(ebone_iter, true); | ||||
| } | } | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| DEG_id_tag_update(&obedit->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| static int armature_select_similar_exec(bContext *C, wmOperator *op) | static int armature_select_similar_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| /* Get props */ | /* Get props */ | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| float thresh = RNA_float_get(op->ptr, "threshold"); | float thresh = RNA_float_get(op->ptr, "threshold"); | ||||
| ▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | if (changed == false) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ED_outliner_select_sync_from_edit_bone_tag(C); | ED_outliner_select_sync_from_edit_bone_tag(C); | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) | void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) | ||||
| { | { | ||||
| static const EnumPropertyItem direction_items[] = { | static const EnumPropertyItem direction_items[] = { | ||||
| {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, | {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | if (ebone_mirror_act) { | ||||
| arm->act_edbone = ebone_mirror_act; | arm->act_edbone = ebone_mirror_act; | ||||
| } | } | ||||
| ED_outliner_select_sync_from_edit_bone_tag(C); | ED_outliner_select_sync_from_edit_bone_tag(C); | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| } | } | ||||
| MEM_freeN(objects); | MEM_freeN(objects); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ARMATURE_OT_select_mirror(wmOperatorType *ot) | void ARMATURE_OT_select_mirror(wmOperatorType *ot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | else { | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| arm->act_edbone = ebone_dst; | arm->act_edbone = ebone_dst; | ||||
| ED_outliner_select_sync_from_edit_bone_tag(C); | ED_outliner_select_sync_from_edit_bone_tag(C); | ||||
| ED_armature_edit_sync_selection(arm->edbo); | ED_armature_edit_sync_selection(arm->edbo); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); | ||||
| DEG_id_tag_update(&obedit->id, ID_RECALC_COPY_ON_WRITE); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_report(op->reports, RPT_WARNING, "Unselectable bone in chain"); | BKE_report(op->reports, RPT_WARNING, "Unselectable bone in chain"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| Show All 15 Lines | |||||