Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_context.c
| Show All 24 Lines | |||||
| /** \file blender/editors/screen/screen_context.c | /** \file blender/editors/screen/screen_context.c | ||||
| * \ingroup edscr | * \ingroup edscr | ||||
| */ | */ | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_sequence_types.h" | #include "DNA_sequence_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_sequencer.h" | #include "BKE_sequencer.h" | ||||
| ▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | else if (CTX_data_equals(member, "editable_bases")) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| else if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { | else if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { | ||||
| bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; | bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; | ||||
| EditBone *ebone, *flipbone = NULL; | EditBone *ebone, *flipbone = NULL; | ||||
| const bool editable_bones = CTX_data_equals(member, "editable_bones"); | const bool editable_bones = CTX_data_equals(member, "editable_bones"); | ||||
| if (arm && arm->edbo) { | if (arm && arm->edbo) { | ||||
| uint objects_len; | |||||
| Object **objects = BKE_view_layer_array_from_objects_in_mode( | |||||
| view_layer, &objects_len, { | |||||
| .object_mode = OB_MODE_EDIT, | |||||
| .no_dup_data = true}); | |||||
| for (uint i = 0; i < objects_len; i++) { | |||||
| Object *ob = objects[i]; | |||||
| arm = ob->data; | |||||
| /* Attention: X-Axis Mirroring is also handled here... */ | /* Attention: X-Axis Mirroring is also handled here... */ | ||||
| for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { | for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { | ||||
| /* first and foremost, bone must be visible and selected */ | /* first and foremost, bone must be visible and selected */ | ||||
| if (EBONE_VISIBLE(arm, ebone)) { | if (EBONE_VISIBLE(arm, ebone)) { | ||||
| /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled | /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled | ||||
| * so that most users of this data don't need to explicitly check for it themselves. | * so that most users of this data don't need to explicitly check for it themselves. | ||||
| * | * | ||||
| * We need to make sure that these mirrored copies are not selected, otherwise some | * We need to make sure that these mirrored copies are not selected, otherwise some | ||||
| Show All 16 Lines | if (arm && arm->edbo) { | ||||
| /* only include bones if visible */ | /* only include bones if visible */ | ||||
| CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); | CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); | ||||
| if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0) | if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0) | ||||
| CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); | CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } /* no indent */ | |||||
| MEM_freeN(objects); | |||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| else if (CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) { | else if (CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) { | ||||
| bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; | bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; | ||||
| EditBone *ebone, *flipbone = NULL; | EditBone *ebone, *flipbone = NULL; | ||||
| const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones"); | const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones"); | ||||
| if (arm && arm->edbo) { | if (arm && arm->edbo) { | ||||
| uint objects_len; | |||||
| Object **objects = BKE_view_layer_array_from_objects_in_mode( | |||||
| view_layer, &objects_len, { | |||||
| .object_mode = OB_MODE_EDIT, | |||||
| .no_dup_data = true}); | |||||
| for (uint i = 0; i < objects_len; i++) { | |||||
| Object *ob = objects[i]; | |||||
| arm = ob->data; | |||||
| /* Attention: X-Axis Mirroring is also handled here... */ | /* Attention: X-Axis Mirroring is also handled here... */ | ||||
| for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { | for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { | ||||
| /* first and foremost, bone must be visible and selected */ | /* first and foremost, bone must be visible and selected */ | ||||
| if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) { | if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) { | ||||
| /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled | /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled | ||||
| * so that most users of this data don't need to explicitly check for it themselves. | * so that most users of this data don't need to explicitly check for it themselves. | ||||
| * | * | ||||
| * We need to make sure that these mirrored copies are not selected, otherwise some | * We need to make sure that these mirrored copies are not selected, otherwise some | ||||
| Show All 16 Lines | if (arm && arm->edbo) { | ||||
| /* only include bones if selected */ | /* only include bones if selected */ | ||||
| CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); | CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); | ||||
| if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) | if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) | ||||
| CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); | CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } /* no indent */ | |||||
| MEM_freeN(objects); | |||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| else if (CTX_data_equals(member, "visible_pose_bones")) { | else if (CTX_data_equals(member, "visible_pose_bones")) { | ||||
| Object *obpose = BKE_object_pose_armature_get(obact); | Object *obpose = BKE_object_pose_armature_get(obact); | ||||
| bArmature *arm = (obpose) ? obpose->data : NULL; | bArmature *arm = (obpose) ? obpose->data : NULL; | ||||
| bPoseChannel *pchan; | bPoseChannel *pchan; | ||||
| if (obpose && obpose->pose && arm) { | if (obpose && obpose->pose && arm) { | ||||
| if (obpose != obact) { | |||||
| for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { | for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { | ||||
| /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ | /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ | ||||
| if (PBONE_VISIBLE(arm, pchan->bone)) { | if (PBONE_VISIBLE(arm, pchan->bone)) { | ||||
| CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); | CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| else if (obact->mode & OB_MODE_POSE) { | |||||
| FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, obact->mode, ob_iter) { | |||||
| for (pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { | |||||
| /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ | |||||
| if (PBONE_VISIBLE(arm, pchan->bone)) { | |||||
| CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan); | |||||
| } | |||||
| } | |||||
| } FOREACH_OBJECT_IN_MODE_END; | |||||
| } | |||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| else if (CTX_data_equals(member, "selected_pose_bones")) { | else if (CTX_data_equals(member, "selected_pose_bones")) { | ||||
| Object *obpose = BKE_object_pose_armature_get(obact); | Object *obpose = BKE_object_pose_armature_get(obact); | ||||
| bArmature *arm = (obpose) ? obpose->data : NULL; | bArmature *arm = (obpose) ? obpose->data : NULL; | ||||
| bPoseChannel *pchan; | bPoseChannel *pchan; | ||||
| if (obpose && obpose->pose && arm) { | if (obpose && obpose->pose && arm) { | ||||
| if (obpose != obact) { | |||||
| /* TODO(de-duplicate!) */ | |||||
| for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { | for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { | ||||
| /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ | /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ | ||||
| if (PBONE_VISIBLE(arm, pchan->bone)) { | if (PBONE_VISIBLE(arm, pchan->bone)) { | ||||
| if (pchan->bone->flag & BONE_SELECTED) | if (pchan->bone->flag & BONE_SELECTED) | ||||
| CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); | CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| else if (obact->mode & OB_MODE_POSE) { | |||||
| /* TODO(de-duplicate!) */ | |||||
| FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, OB_MODE_POSE, ob_iter) { | |||||
| for (pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) { | |||||
| /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ | |||||
| if (PBONE_VISIBLE(arm, pchan->bone)) { | |||||
| if (pchan->bone->flag & BONE_SELECTED) | |||||
| CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan); | |||||
| } | |||||
| } | |||||
| } FOREACH_OBJECT_IN_MODE_END; | |||||
| } | |||||
| CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| else if (CTX_data_equals(member, "active_bone")) { | else if (CTX_data_equals(member, "active_bone")) { | ||||
| if (obact && obact->type == OB_ARMATURE) { | if (obact && obact->type == OB_ARMATURE) { | ||||
| bArmature *arm = obact->data; | bArmature *arm = obact->data; | ||||
| if (arm->edbo) { | if (arm->edbo) { | ||||
| ▲ Show 20 Lines • Show All 318 Lines • Show Last 20 Lines | |||||