[Bf-blender-cvs] [d01e0d1ef1c] blender2.8: CTX_DATA_BEGIN for active object only (..._from_active_object)

Dalai Felinto noreply at git.blender.org
Fri Oct 19 13:33:48 CEST 2018


Commit: d01e0d1ef1c4ddc45ee8e054aae7b08bbe57d0bf
Author: Dalai Felinto
Date:   Fri Oct 19 08:29:15 2018 -0300
Branches: blender2.8
https://developer.blender.org/rBd01e0d1ef1c4ddc45ee8e054aae7b08bbe57d0bf

CTX_DATA_BEGIN for active object only (..._from_active_object)

For now only `selected_pose_bones_from_active_object`, more options can
be added on demand.

Discussed this with Campbell Barton. We may need this only for selected
pose bones, time will tell.

===================================================================

M	release/scripts/startup/keyingsets_builtins.py
M	source/blender/blenkernel/BKE_context.h
M	source/blender/blenkernel/intern/context.c
M	source/blender/editors/armature/pose_edit.c
M	source/blender/editors/object/object_constraint.c
M	source/blender/editors/screen/screen_context.c

===================================================================

diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py
index 829473aa682..9ba32150bbe 100644
--- a/release/scripts/startup/keyingsets_builtins.py
+++ b/release/scripts/startup/keyingsets_builtins.py
@@ -538,7 +538,7 @@ class BUILTIN_KSI_WholeCharacterSelected(KeyingSetInfo):
     # iterator - all bones regardless of selection
     def iterator(ksi, context, ks):
         # Use either the selected bones, or all of them if none are selected.
-        bones = [b for b in context.active_object.pose.bones if b.bone.select] or context.active_object.pose.bones
+        bones = context.selected_pose_bones_from_active_object or context.active_object.pose.bones
 
         for bone in bones:
             if bone.name.startswith(BUILTIN_KSI_WholeCharacter.badBonePrefixes):
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index f658c07268b..89d2aef7152 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -311,6 +311,7 @@ int CTX_data_editable_bones(const bContext *C, ListBase *list);
 
 struct bPoseChannel *CTX_data_active_pose_bone(const bContext *C);
 int CTX_data_selected_pose_bones(const bContext *C, ListBase *list);
+int CTX_data_selected_pose_bones_from_active_object(const bContext *C, ListBase *list);
 int CTX_data_visible_pose_bones(const bContext *C, ListBase *list);
 
 struct bGPdata *CTX_data_gpencil_data(const bContext *C);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index ff9465378a1..b3a26087dd0 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -1198,6 +1198,11 @@ int CTX_data_selected_pose_bones(const bContext *C, ListBase *list)
 	return ctx_data_collection_get(C, "selected_pose_bones", list);
 }
 
+int CTX_data_selected_pose_bones_from_active_object(const bContext *C, ListBase *list)
+{
+	return ctx_data_collection_get(C, "selected_pose_bones_from_active_object", list);
+}
+
 int CTX_data_visible_pose_bones(const bContext *C, ListBase *list)
 {
 	return ctx_data_collection_get(C, "visible_pose_bones", list);
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 7a973e5dd2a..e60fb37b8b0 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -316,7 +316,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
 	}
 
 	/* set up path data for bones being calculated */
-	CTX_DATA_BEGIN_FOR_ID (C, bPoseChannel *, pchan, selected_pose_bones, &ob->id)
+	CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones_from_active_object)
 	{
 		/* verify makes sure that the selected bone has a bone with the appropriate settings */
 		animviz_verify_motionpaths(op->reports, scene, ob, pchan);
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 6d39ade8fd5..7b72b1eb80e 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1639,7 +1639,7 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob
 	/* if the active Object is Armature, and we can search for bones, do so... */
 	if ((obact->type == OB_ARMATURE) && (only_ob == false)) {
 		/* search in list of selected Pose-Channels for target */
-		CTX_DATA_BEGIN_FOR_ID (C, bPoseChannel *, pchan, selected_pose_bones, &obact->id)
+		CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones_from_active_object)
 		{
 			/* just use the first one that we encounter, as long as it is not the active one */
 			if (pchan != pchanact) {
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 021f5b9abd1..ff048edae9c 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -78,7 +78,8 @@ const char *screen_context_dir[] = {
 	"editable_objects", "editable_bases",
 	"selected_editable_objects", "selected_editable_bases",
 	"visible_bones", "editable_bones", "selected_bones", "selected_editable_bones",
-	"visible_pose_bones", "selected_pose_bones", "active_bone", "active_pose_bone",
+	"visible_pose_bones", "selected_pose_bones", "selected_pose_bones_from_active_object",
+	"active_bone", "active_pose_bone",
 	"active_base", "active_object", "object", "edit_object",
 	"sculpt_object", "vertex_paint_object", "weight_paint_object",
 	"image_paint_object", "particle_edit_object", "uv_sculpt_object",
@@ -347,6 +348,23 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
 			return 1;
 		}
 	}
+	else if (CTX_data_equals(member, "selected_pose_bones_from_active_object")) {
+		Object *obpose = BKE_object_pose_armature_get(obact);
+		if (obpose && obpose->pose && obpose->data) {
+			if (obpose != obact) {
+				FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (obpose, pchan) {
+					CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
+				} FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
+			}
+			else if (obact->mode & OB_MODE_POSE) {
+				FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (obact, pchan) {
+					CTX_data_list_add(result, &obact->id, &RNA_PoseBone, pchan);
+				} FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
+			}
+			CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+			return 1;
+		}
+	}
 	else if (CTX_data_equals(member, "active_bone")) {
 		if (obact && obact->type == OB_ARMATURE) {
 			bArmature *arm = obact->data;



More information about the Bf-blender-cvs mailing list