[Bf-blender-cvs] [3ffc2a8330f] blender2.8: Multi-Objects: POSE_OT_paths_*

Dalai Felinto noreply at git.blender.org
Fri Oct 12 22:44:43 CEST 2018


Commit: 3ffc2a8330fd1fdfdb8d8fb40a97ef3022e6e6b7
Author: Dalai Felinto
Date:   Fri Oct 12 17:03:42 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB3ffc2a8330fd1fdfdb8d8fb40a97ef3022e6e6b7

Multi-Objects: POSE_OT_paths_*

* POSE_OT_paths_clear
* POSE_OT_paths_calculate
* POSE_OT_paths_update

Despite my personal opinion on the matter, those operators were listed
as to be converted (see T54650).

They are called from the UI, where you only see the parameters for the
active object/armature.

I will commit and revert soon after, so we can quickly bring it back
once we re-visit this design.

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

M	source/blender/editors/armature/pose_edit.c

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

diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 46e417f6452..961bc4d9175 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -279,14 +279,18 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEven
  */
 static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
 {
-	Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+	ViewLayer *view_layer = CTX_data_view_layer(C);
 	Scene *scene = CTX_data_scene(C);
 
-	if (ELEM(NULL, ob, ob->pose))
-		return OPERATOR_CANCELLED;
+	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]);
+
+		if (ELEM(NULL, ob, ob->pose)) {
+			continue;
+		}
 
-	/* grab baking settings from operator settings */
-	{
 		bAnimVizSettings *avs = &ob->pose->avs;
 		PointerRNA avs_ptr;
 
@@ -297,29 +301,40 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
 		RNA_enum_set(&avs_ptr, "bake_location", RNA_enum_get(op->ptr, "bake_location"));
 	}
 
-	/* set up path data for bones being calculated */
-	CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
+	/* Set up path data for bones being calculated. */
+	CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob)
 	{
-		/* verify makes sure that the selected bone has a bone with the appropriate settings */
+		/* Verify makes sure that the selected bone has a bone with the appropriate settings. */
 		animviz_verify_motionpaths(op->reports, scene, ob, pchan);
 	}
 	CTX_DATA_END;
 
+
+	for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+		Object *ob = BKE_object_pose_armature_get(objects[ob_index]);
+
+		if (ELEM(NULL, ob, ob->pose)) {
+			continue;
+		}
+
 #ifdef DEBUG_TIME
-	TIMEIT_START(recalc_pose_paths);
+		TIMEIT_START(recalc_pose_paths);
 #endif
 
-	/* calculate the bones that now have motionpaths... */
-	/* TODO: only make for the selected bones? */
-	ED_pose_recalculate_paths(C, scene, ob, false);
+		/* Calculate the bones that now have motionpaths... */
+		/* TODO: only make for the selected bones? */
+		ED_pose_recalculate_paths(C, scene, ob, false);
 
 #ifdef DEBUG_TIME
-	TIMEIT_END(recalc_pose_paths);
+		TIMEIT_END(recalc_pose_paths);
 #endif
 
-	/* notifiers for updates */
-	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+		/* Notifiers for updates. */
+		WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
 
+	}
+
+	MEM_freeN(objects);
 	return OPERATOR_FINISHED;
 }
 
@@ -364,20 +379,31 @@ static bool pose_update_paths_poll(bContext *C)
 
 static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
 {
-	Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+	ViewLayer *view_layer = CTX_data_view_layer(C);
 	Scene *scene = CTX_data_scene(C);
+	bool changed_multi = false;
 
-	if (ELEM(NULL, ob, scene))
-		return OPERATOR_CANCELLED;
+	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]);
 
-	/* calculate the bones that now have motionpaths... */
-	/* TODO: only make for the selected bones? */
-	ED_pose_recalculate_paths(C, scene, ob, false);
+		if (ELEM(NULL, ob, scene)) {
+			continue;
+		}
 
-	/* notifiers for updates */
-	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+		/* Calculate the bones that now have motionpaths... */
+		/* TODO: only make for the selected bones? */
+		ED_pose_recalculate_paths(C, scene, ob, false);
 
-	return OPERATOR_FINISHED;
+		/* notifiers for updates */
+		WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+
+		changed_multi = true;
+	}
+	MEM_freeN(objects);
+
+	return changed_multi ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
 
 void POSE_OT_paths_update(wmOperatorType *ot)
@@ -430,19 +456,26 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
 /* operator callback - wrapper for the backend function  */
 static int pose_clear_paths_exec(bContext *C, wmOperator *op)
 {
-	Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-	bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
+	ViewLayer *view_layer = CTX_data_view_layer(C);
+	const bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
 
-	/* only continue if there's an object */
-	if (ELEM(NULL, ob, ob->pose))
-		return OPERATOR_CANCELLED;
+	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]);
 
-	/* use the backend function for this */
-	ED_pose_clear_paths(ob, only_selected);
+		/* Only continue if there's an object. */
+		if (ELEM(NULL, ob, ob->pose)) {
+			continue;
+		}
 
-	/* notifiers for updates */
-	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+		/* Use the backend function for this. */
+		ED_pose_clear_paths(ob, only_selected);
 
+		/* Notifiers for updates. */
+		WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+	}
+	MEM_freeN(objects);
 	return OPERATOR_FINISHED;
 }



More information about the Bf-blender-cvs mailing list