Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2018-10-19 21:44:04 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-10-19 21:45:34 +0300
commitcaad2d7528bc38934a90bb30b417068b71076bcd (patch)
treef08a94a170cb328f35e9ed89e6d29521a0db52ec /source/blender/editors/armature/pose_select.c
parented34e577962994cdd057bc4623aacfa867adfa3b (diff)
Multi-Objects: POSE_OT_select_grouped > POSE_SEL_SAME_KEYINGSET 3/3
Note for posterity, I couldn't figure out a way to test this mode properly. That said, it should be working with multiple-poses now.
Diffstat (limited to 'source/blender/editors/armature/pose_select.c')
-rw-r--r--source/blender/editors/armature/pose_select.c80
1 files changed, 45 insertions, 35 deletions
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index fcc57f8fa81..d655d2e3679 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -856,15 +856,13 @@ cleanup:
return changed;
}
-static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object *ob, bool extend)
+static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool extend)
{
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ bool changed_multi = false;
KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C));
KS_Path *ksp;
- bArmature *arm = (ob) ? ob->data : NULL;
- bPose *pose = (ob) ? ob->pose : NULL;
- bool changed = false;
-
/* sanity checks: validate Keying Set and object */
if (ks == NULL) {
BKE_report(reports, RPT_ERROR, "No active Keying Set to use");
@@ -884,9 +882,6 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
return false;
}
- if (ELEM(NULL, ob, pose, arm))
- return false;
-
/* if not extending selection, deselect all selected first */
if (extend == false) {
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
@@ -897,34 +892,54 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
CTX_DATA_END;
}
- /* iterate over elements in the Keying Set, setting selection depending on whether
- * that bone is visible or not...
- */
- for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
- /* only items related to this object will be relevant */
- if ((ksp->id == &ob->id) && (ksp->rna_path != NULL)) {
- if (strstr(ksp->rna_path, "bones")) {
- char *boneName = BLI_str_quoted_substrN(ksp->rna_path, "bones[");
-
- if (boneName) {
- bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName);
-
- if (pchan) {
- /* select if bone is visible and can be affected */
- if (PBONE_SELECTABLE(arm, pchan->bone)) {
- pchan->bone->flag |= BONE_SELECTED;
- changed = true;
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(view_layer, &objects_len, OB_MODE_POSE);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob = BKE_object_pose_armature_get(objects[ob_index]);
+ bArmature *arm = (ob) ? ob->data : NULL;
+ bPose *pose = (ob) ? ob->pose : NULL;
+ bool changed = false;
+
+ /* Sanity checks. */
+ if (ELEM(NULL, ob, pose, arm)) {
+ continue;
+ }
+
+ /* iterate over elements in the Keying Set, setting selection depending on whether
+ * that bone is visible or not...
+ */
+ for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+ /* only items related to this object will be relevant */
+ if ((ksp->id == &ob->id) && (ksp->rna_path != NULL)) {
+ if (strstr(ksp->rna_path, "bones")) {
+ char *boneName = BLI_str_quoted_substrN(ksp->rna_path, "bones[");
+
+ if (boneName) {
+ bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName);
+
+ if (pchan) {
+ /* select if bone is visible and can be affected */
+ if (PBONE_SELECTABLE(arm, pchan->bone)) {
+ pchan->bone->flag |= BONE_SELECTED;
+ changed = true;
+ }
}
- }
- /* free temp memory */
- MEM_freeN(boneName);
+ /* free temp memory */
+ MEM_freeN(boneName);
+ }
}
}
}
+
+ if (changed || !extend) {
+ ED_pose_bone_select_tag_update(ob);
+ changed_multi = true;
+ }
}
+ MEM_freeN(objects);
- return changed;
+ return changed_multi;
}
static int pose_select_grouped_exec(bContext *C, wmOperator *op)
@@ -934,11 +949,6 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
const bool extend = RNA_boolean_get(op->ptr, "extend");
bool changed = false;
- if (type == POSE_SEL_SAME_KEYINGSET) {
- BKE_report(op->reports, RPT_ERROR, "Mode not supported at the moment");
- return OPERATOR_CANCELLED;
- }
-
/* sanity check */
if (ob->pose == NULL)
return OPERATOR_CANCELLED;
@@ -954,7 +964,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
break;
case POSE_SEL_SAME_KEYINGSET: /* Keying Set */
- changed = pose_select_same_keyingset(C, op->reports, ob, extend);
+ changed = pose_select_same_keyingset(C, op->reports, extend);
break;
default: